From: Junio C Hamano Date: Fri, 20 Nov 2009 08:05:18 GMT Subject: Re: [PATCH] submodule.c: Squelch a "use before assignment" warning Message-ID: <7v8we17ha9.fsf@alter.siamese.dyndns.org> In-Reply-To: <1258680785-42235-1-git-send-email-davvid@gmail.com> David Aguilar 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;