Re: [PATCH v8 2/2] test-config: add tests for the config_set API
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jul 11, 2014, 14:24 UTC
- Message-ID
- <vpqwqbk0y8n.fsf@anie.imag.fr>
- In-Reply-To
- <1405049655-4265-3-git-send-email-tanayabh@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
Show 5 quoted lines
> diff --git a/test-config.c b/test-config.c > new file mode 100644 > index 0000000..dc313c2 > --- /dev/null > +++ b/test-config.c
Show 7 quoted lines
> +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/