Tanay Abhra [off-list ref] writes:
quoted hunk
diff --git a/test-config.c b/test-config.c
new file mode 100644
index 0000000..dc313c2
--- /dev/null
+++ b/test-config.c
+int main(int argc, char **argv)
+{
+ int i, val;
+ const char *v;
+ const struct string_list *strptr;
+ struct config_set cs;
+ git_configset_init(&cs);
The configset is initialized, but never cleared.
As a result, valgrind --leak-check=full complains with "definitely lost"
items.
I think it would make sense to apply something like this to get a
valgrind-clean test-config.c (I checked, it now passes without
warnings):
diff --git a/test-config.c b/test-config.c
index dc313c2..07b61ef 100644
--- a/test-config.c
+++ b/test-config.c
@@ -41,17 +41,17 @@ int main(int argc, char **argv)
if (argc < 2) {
fprintf(stderr, "Please, provide a command name on the command-line\n");
- return 1;
+ goto exit1;
} else if (argc == 3 && !strcmp(argv[1], "get_value")) {
if (!git_config_get_value(argv[2], &v)) {
if (!v)
printf("(NULL)\n");
else
printf("%s\n", v);
- return 0;
+ goto exit0;
[...]
fprintf(stderr, "%s: Please check the syntax and the function name\n", argv[0]);
+ goto exit1;
+
+exit0:
+ git_configset_clear(&cs);
+ return 0;
+
+exit1:
+ git_configset_clear(&cs);
return 1;
+
+exit2:
+ git_configset_clear(&cs);
+ return 2;
}
I'll resend as a proper "git am"-able patch right after.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/