From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Tanay Abhra <tanayabh@gmail.com>
Cc: git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>
Subject: Re: [PATCH v8 2/2] test-config: add tests for the config_set API
Date: Fri, 11 Jul 2014 16:24:40 +0200 [thread overview]
Message-ID: <vpqwqbk0y8n.fsf@anie.imag.fr> (raw)
In-Reply-To: <1405049655-4265-3-git-send-email-tanayabh@gmail.com> (Tanay Abhra's message of "Thu, 10 Jul 2014 20:34:15 -0700")
Tanay Abhra <tanayabh@gmail.com> writes:
> 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/
next prev parent reply other threads:[~2014-07-11 14:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 3:34 [PATCH v8 0/3] git config cache & special querying api utilizing the cache Tanay Abhra
2014-07-11 3:34 ` [PATCH v8 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-11 14:21 ` Matthieu Moy
2014-07-11 16:31 ` Tanay Abhra
2014-07-11 16:59 ` Matthieu Moy
2014-07-15 10:54 ` Tanay Abhra
2014-07-15 11:32 ` Matthieu Moy
2014-07-11 17:25 ` Junio C Hamano
2014-07-11 3:34 ` [PATCH v8 2/2] test-config: add tests for the config_set API Tanay Abhra
2014-07-11 14:24 ` Matthieu Moy [this message]
2014-07-11 14:27 ` [fixup PATCH 1/2] Call configset_clear Matthieu Moy
2014-07-11 14:27 ` [PATCH 2/2] Better tests for error cases Matthieu Moy
2014-07-11 18:18 ` [PATCH v8 2/2] test-config: add tests for the config_set API Junio C Hamano
2014-07-15 11:10 ` Tanay Abhra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpqwqbk0y8n.fsf@anie.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=tanayabh@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).