From: Junio C Hamano <gitster@pobox.com>
To: David Aguilar <davvid@gmail.com>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH] submodule.c: Squelch a "use before assignment" warning
Date: Fri, 20 Nov 2009 00:05:18 -0800 [thread overview]
Message-ID: <7v8we17ha9.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1258680785-42235-1-git-send-email-davvid@gmail.com> (David Aguilar's message of "Thu\, 19 Nov 2009 17\:33\:05 -0800")
David Aguilar <davvid@gmail.com> writes:
> i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493) compiler
> (and probably others) mistakenly thinks variable 'right' is used
> before assigned. Work it around by giving it a fake initialization.
We see the same "fake initialization" of 'left' on the same line. By
initializing it to NULL, you are hinting that initializing 'right' to
NULL actually means something.
> diff --git a/submodule.c b/submodule.c
> index 461faf0..0145a62 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -38,7 +38,7 @@ void show_submodule_summary(FILE *f, const char *path,
> const char *del, const char *add, const char *reset)
> {
> struct rev_info rev;
> - struct commit *commit, *left = left, *right;
> + struct commit *commit, *left = left, *right = NULL;
next prev parent reply other threads:[~2009-11-20 8:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 1:33 [PATCH] submodule.c: Squelch a "use before assignment" warning David Aguilar
2009-11-20 8:05 ` Junio C Hamano [this message]
2009-11-20 11:33 ` David Aguilar
2009-11-21 18:46 ` Christoph Bartoschek
2009-11-22 2:59 ` Junio C Hamano
2009-11-22 3:32 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v8we17ha9.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox