# [PATCH] checkout: squelch "'mode' may be used uninitialized in this function" warning

3 messages from 2012-04-30 to 2012-05-08. Participants: dsp@php.net, David Soria Parra, Jeff King.
Thread: https://gitlist.dev/t/30373

## dsp@php.net, 2012-04-30 22:39

Subject: [PATCH] checkout: squelch "'mode' may be used uninitialized in this function" warning
Message-ID: <1335825567-7831-1-git-send-email-dsp@php.net>
URL: https://gitlist.dev/e/1335825567-7831-1-git-send-email-dsp%40php.net

```
From: David Soria Parra <dsp@php.net>

Use a 'fake' initialization for the 'mode' variable to work around a
GCC warning as in 5a7a367. The necessary condition to initialize 'mode'
will always be true but cannot be checked by the compiler.

Signed-off-by: David Soria Parra <dsp@php.net>
---
 builtin/checkout.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 84d3eb3..6b8bf31 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -157,7 +157,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	unsigned char sha1[20];
 	mmbuffer_t result_buf;
 	unsigned char threeway[3][20];
-	unsigned mode;
+	unsigned mode = mode;
 
 	memset(threeway, 0, sizeof(threeway));
 	while (pos < active_nr) {
-- 
1.7.8.GIT

```

## David Soria Parra, 2012-05-03 10:59

Subject: Re: [PATCH] checkout: squelch "'mode' may be used uninitialized in this function" warning
Message-ID: <slrnjq4p8c.i00.dsp@experimentalworks.net>
URL: https://gitlist.dev/e/slrnjq4p8c.i00.dsp%40experimentalworks.net
In-Reply-To: <1335825567-7831-1-git-send-email-dsp@php.net>

```
Any update on this patch? Is it going to maint?

On 2012-04-30, dsp@php.net <dsp@php.net> wrote:
> From: David Soria Parra <dsp@php.net>
>
> Use a 'fake' initialization for the 'mode' variable to work around a
> GCC warning as in 5a7a367. The necessary condition to initialize 'mode'
> will always be true but cannot be checked by the compiler.
>
> Signed-off-by: David Soria Parra <dsp@php.net>
> ---
>  builtin/checkout.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 84d3eb3..6b8bf31 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -157,7 +157,7 @@ static int checkout_merged(int pos, struct checkout *state)
>  	unsigned char sha1[20];
>  	mmbuffer_t result_buf;
>  	unsigned char threeway[3][20];
> -	unsigned mode;
> +	unsigned mode = mode;
>  
>  	memset(threeway, 0, sizeof(threeway));
>  	while (pos < active_nr) {

```

## Jeff King, 2012-05-08 20:26

Subject: Re: [PATCH] checkout: squelch "'mode' may be used uninitialized in this function" warning
Message-ID: <20120508202649.GA15502@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120508202649.GA15502%40sigill.intra.peff.net
In-Reply-To: <slrnjq4p8c.i00.dsp@experimentalworks.net>

```
On Thu, May 03, 2012 at 10:59:24AM +0000, David Soria Parra wrote:

> Any update on this patch? Is it going to maint?

I doubt it:

> > diff --git a/builtin/checkout.c b/builtin/checkout.c
> > index 84d3eb3..6b8bf31 100644
> > --- a/builtin/checkout.c
> > +++ b/builtin/checkout.c
> > @@ -157,7 +157,7 @@ static int checkout_merged(int pos, struct checkout *state)
> >  	unsigned char sha1[20];
> >  	mmbuffer_t result_buf;
> >  	unsigned char threeway[3][20];
> > -	unsigned mode;
> > +	unsigned mode = mode;

What is this based on? This has been fixed since 335c6e4
(checkout_merged(): squelch false warning from some gcc, 2011-12-15),
which was in v1.7.8.2.

-Peff

```
