Re: [PATCH 2/2] read-cache: fix an -Wmaybe-uninitialized warning

2018-03-21 Thread Jeff King
On Tue, Mar 20, 2018 at 10:52:16PM +, Ramsay Jones wrote: > > Maybe too clever, but I think you could just do: > > > > unsigned int saved_namelen = 0; > > ... > > saved_namelen = ce_namelen(ce); > > ... > > if (saved_namelen) > > ce->ce_namelen = saved_namelen; > >

Re: [PATCH 2/2] read-cache: fix an -Wmaybe-uninitialized warning

2018-03-20 Thread Ramsay Jones
On 20/03/18 04:36, Jeff King wrote: > On Mon, Mar 19, 2018 at 05:56:11PM +, Ramsay Jones wrote: > [snip] >> diff --git a/read-cache.c b/read-cache.c >> index 2eb81a66b..49607ddcd 100644 >> --- a/read-cache.c >> +++ b/read-cache.c >> @@ -2104,13 +2104,15 @@ static int

Re: [PATCH 2/2] read-cache: fix an -Wmaybe-uninitialized warning

2018-03-19 Thread Jeff King
On Mon, Mar 19, 2018 at 05:56:11PM +, Ramsay Jones wrote: > For the purposes of this discussion, the ce_write_entry() function has > three code blocks of interest, that look like so: > > /* block #1 */ > if (ce->ce_flags & CE_STRIP_NAME) { > saved_namelen =

[PATCH 2/2] read-cache: fix an -Wmaybe-uninitialized warning

2018-03-19 Thread Ramsay Jones
The function ce_write_entry() uses a 'self-initialised' variable construct, for the symbol 'saved_namelen', to suppress a gcc '-Wmaybe-uninitialized' warning, given that the warning is a false positive. For the purposes of this discussion, the ce_write_entry() function has three code blocks of