Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Jeff King
On Fri, Sep 06, 2019 at 01:10:46AM +0200, Stephan Beyer wrote: > I took a quick glance at yours. I also noticed the issue you address in > [PATCH 2/6], but I was unsure if this is the way to go (I'm only > occasionally reading on this list). I would prefer your patch series, > with maybe one excep

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Stephan Beyer
On 9/6/19 12:58 AM, Jeff King wrote: > On Fri, Sep 06, 2019 at 12:53:49AM +0200, Stephan Beyer wrote: > >> On 9/6/19 12:48 AM, Jeff King wrote: >>> On Thu, Sep 05, 2019 at 10:24:59AM +0200, Stephan Beyer wrote: >>> Compiler heuristics for detection of potentially uninitialized variables m

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Jeff King
On Fri, Sep 06, 2019 at 12:53:49AM +0200, Stephan Beyer wrote: > On 9/6/19 12:48 AM, Jeff King wrote: > > On Thu, Sep 05, 2019 at 10:24:59AM +0200, Stephan Beyer wrote: > > > >> Compiler heuristics for detection of potentially uninitialized variables > >> may change between compiler versions and e

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Stephan Beyer
On 9/6/19 12:48 AM, Jeff King wrote: > On Thu, Sep 05, 2019 at 10:24:59AM +0200, Stephan Beyer wrote: > >> Compiler heuristics for detection of potentially uninitialized variables >> may change between compiler versions and enabling link-time optimization >> may find new warnings. Indeed, compilin

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Jeff King
On Thu, Sep 05, 2019 at 10:24:59AM +0200, Stephan Beyer wrote: > Compiler heuristics for detection of potentially uninitialized variables > may change between compiler versions and enabling link-time optimization > may find new warnings. Indeed, compiling with gcc 9.2.1 and enabled > link-time op

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Junio C Hamano
René Scharfe writes: > The loop count is either 1 or argv[1] interpreted as a number, i.e. it could > be very high. Its body consists of an index load and writing a number to a > file, though -- a strlen() call on the name of that file should go unnoticed > amid that activity. (I didn't measure

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread René Scharfe
Am 05.09.19 um 21:25 schrieb Junio C Hamano: > René Scharfe writes: > >> Am 05.09.19 um 19:53 schrieb Jeff King: > int cmd__read_cache(int argc, const char **argv) > { > - int i, cnt = 1, namelen; > + int i, cnt = 1, namelen = 0; >>> >>> I actually saw this one the othe

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Junio C Hamano
René Scharfe writes: > Am 05.09.19 um 19:53 schrieb Jeff King: int cmd__read_cache(int argc, const char **argv) { - int i, cnt = 1, namelen; + int i, cnt = 1, namelen = 0; >> >> I actually saw this one the other day, because it triggered for me when >> compiling wi

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread René Scharfe
Am 05.09.19 um 19:53 schrieb Jeff King: >>> int cmd__read_cache(int argc, const char **argv) >>> { >>> - int i, cnt = 1, namelen; >>> + int i, cnt = 1, namelen = 0; > > I actually saw this one the other day, because it triggered for me when > compiling with SANITIZE=address. AFAICT it's

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Junio C Hamano
Jeff King writes: > I said earlier that I wouldn't mind seeing "namelen = 0" here. But I > think there is a much more direct solution: keeping the assignment and > point of use closer together. That makes it more clear both to the > compiler and to a human when we expect the variable to be valid.

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Jeff King
On Thu, Sep 05, 2019 at 10:56:12AM -0700, Junio C Hamano wrote: > Stephan Beyer writes: > > > diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c > > index 7e79b555de..ef0963e2f4 100644 > > --- a/t/helper/test-read-cache.c > > +++ b/t/helper/test-read-cache.c > > @@ -4,7 +4,7 @@

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Junio C Hamano
Stephan Beyer writes: > diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c > index 7e79b555de..ef0963e2f4 100644 > --- a/t/helper/test-read-cache.c > +++ b/t/helper/test-read-cache.c > @@ -4,7 +4,7 @@ > > int cmd__read_cache(int argc, const char **argv) > { > - int i, cnt

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Jeff King
On Thu, Sep 05, 2019 at 07:08:49PM +0200, René Scharfe wrote: > Anyway, my points are that simply initializing might not always be the > best fix, and that more context would help reviewers of such a patch, > but only if functions are reasonably short and it's not necessary to > follow the rabbit

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread Junio C Hamano
Stephan Beyer writes: > diff --git a/fast-import.c b/fast-import.c > index b44d6a467e..58f73f9105 100644 > --- a/fast-import.c > +++ b/fast-import.c > @@ -903,7 +903,8 @@ static int store_object( > struct object_entry *e; > unsigned char hdr[96]; > struct object_id oid; > -

Re: [PATCH] Fix maybe-uninitialized warnings found by gcc 9 -flto

2019-09-05 Thread René Scharfe
Am 05.09.19 um 10:24 schrieb Stephan Beyer: > Compiler heuristics for detection of potentially uninitialized variables > may change between compiler versions and enabling link-time optimization > may find new warnings. Indeed, compiling with gcc 9.2.1 and enabled > link-time optimization feature r