Re: Questionable code in gcov-io.c

2016-10-14 Thread Nathan Sidwell
On 10/13/16 18:10, Andrew Pinski wrote: /home/jenkins/workspace/BuildToolchainAARCH64_thunder_elf_upstream/toolchain/scripts/../src/libgcc/libgcov-driver.c:53:0: /home/jenkins/workspace/BuildToolchainAARCH64_thunder_elf_upstream/toolchain/scripts/../src/libgcc/../gcc/gcov-io.c: In function

Re: Questionable code in gcov-io.c

2016-10-13 Thread Andrew Pinski
On Wed, Oct 12, 2016 at 11:24 AM, Nathan Sidwell wrote: > On 10/12/16 11:04, Andreas Schwab wrote: > >> Do we still need to call fstat? I don't think it can ever fail here. > > > Update removing the fstat. Survived a profiled bootstrap, so I'll commit > tomorrow, unless there

Re: Questionable code in gcov-io.c

2016-10-12 Thread Nathan Sidwell
On 10/12/16 11:04, Andreas Schwab wrote: Do we still need to call fstat? I don't think it can ever fail here. Update removing the fstat. Survived a profiled bootstrap, so I'll commit tomorrow, unless there are further comments. Thanks for spotting this! nathan 2016-10-12 Nathan

Re: Questionable code in gcov-io.c

2016-10-12 Thread Nathan Sidwell
On 10/12/16 11:04, Andreas Schwab wrote: Do we still need to call fstat? I don't think it can ever fail here. You appear to be correct. nathan

Re: Questionable code in gcov-io.c

2016-10-12 Thread Marek Polacek
On Wed, Oct 12, 2016 at 10:47:07AM -0400, Nathan Sidwell wrote: > On 10/12/16 09:43, Marek Polacek wrote: > > > > ITYM lines 197 -> 203. I.e. remove the entire if that;s inside the 'mode > > > == > > > 0' branch and make line 203 unconditional. > > > > Yes, sorry for sloppy wording. I'm

Re: Questionable code in gcov-io.c

2016-10-12 Thread Andreas Schwab
On Okt 12 2016, Nathan Sidwell wrote: > @@ -182,9 +176,7 @@ gcov_open (const char *name, int mode) >return 0; > } > > - if (mode > 0) > -gcov_var.mode = 1; > - else if (mode == 0) > + if (mode == 0) > { >struct stat st; > > @@ -194,21 +186,20

Re: Questionable code in gcov-io.c

2016-10-12 Thread Nathan Sidwell
On 10/12/16 09:43, Marek Polacek wrote: ITYM lines 197 -> 203. I.e. remove the entire if that;s inside the 'mode == 0' branch and make line 203 unconditional. Yes, sorry for sloppy wording. I'm testing a patch. Here's the patch I've tested (but not bootstrapped). As the incoming mode is

Re: Questionable code in gcov-io.c

2016-10-12 Thread Nathan Sidwell
On 10/12/16 09:43, Marek Polacek wrote: ITYM lines 197 -> 203. I.e. remove the entire if that;s inside the 'mode == 0' branch and make line 203 unconditional. Yes, sorry for sloppy wording. I'm testing a patch. heh, so am I :) nathan

Re: Questionable code in gcov-io.c

2016-10-12 Thread Marek Polacek
On Wed, Oct 12, 2016 at 08:14:58AM -0400, Nathan Sidwell wrote: > On 10/12/16 08:10, Marek Polacek wrote: > > While implementing a warning I noticed this in gcov-io.c: > > > > 187 else if (mode == 0) > > 188 { > > 189 struct stat st; > > 190 > > 191 if (fstat (fd, ) < 0) >

Re: Questionable code in gcov-io.c

2016-10-12 Thread Jakub Jelinek
On Wed, Oct 12, 2016 at 02:23:36PM +0200, Bernd Schmidt wrote: > >It seems that lines 198 and 200 do the same thing, at line 200 we know that > >mode == 0, so we just assign 1. Should we just remove the condition on line > >197? > > The intention seems to be that a negative gcov_var.mode means

Re: Questionable code in gcov-io.c

2016-10-12 Thread Bernd Schmidt
On 10/12/2016 02:10 PM, Marek Polacek wrote: While implementing a warning I noticed this in gcov-io.c: 187 else if (mode == 0) 188 { 189 struct stat st; 190 191 if (fstat (fd, ) < 0) 192 { 193 fclose (gcov_var.file); 194 gcov_var.file = 0;

Re: Questionable code in gcov-io.c

2016-10-12 Thread Nathan Sidwell
On 10/12/16 08:10, Marek Polacek wrote: While implementing a warning I noticed this in gcov-io.c: 187 else if (mode == 0) 188 { 189 struct stat st; 190 191 if (fstat (fd, ) < 0) 192 { 193 fclose (gcov_var.file); 194 gcov_var.file = 0; 195

Questionable code in gcov-io.c

2016-10-12 Thread Marek Polacek
While implementing a warning I noticed this in gcov-io.c: 187 else if (mode == 0) 188 { 189 struct stat st; 190 191 if (fstat (fd, ) < 0) 192 { 193 fclose (gcov_var.file); 194 gcov_var.file = 0; 195 return 0; 196 } 197