public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Questionable code in gcov-io.c
@ 2016-10-12 12:10 Marek Polacek
  2016-10-12 12:15 ` Nathan Sidwell
  2016-10-12 12:23 ` Bernd Schmidt
  0 siblings, 2 replies; 13+ messages in thread
From: Marek Polacek @ 2016-10-12 12:10 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek

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, &st) < 0)
 192         {
 193           fclose (gcov_var.file);
 194           gcov_var.file = 0;
 195           return 0;
 196         }
 197       if (st.st_size != 0)
 198         gcov_var.mode = 1;
 199       else
 200         gcov_var.mode = mode * 2 + 1;
 201     }
 202   else
 203     gcov_var.mode = mode * 2 + 1;

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?

This has been introduced in Jakub's r78281.

	Marek

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-10-14 10:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12 12:10 Questionable code in gcov-io.c Marek Polacek
2016-10-12 12:15 ` Nathan Sidwell
2016-10-12 13:43   ` Marek Polacek
2016-10-12 13:45     ` Nathan Sidwell
2016-10-12 14:47     ` Nathan Sidwell
2016-10-12 14:50       ` Marek Polacek
2016-10-12 15:05       ` Andreas Schwab
2016-10-12 15:12         ` Nathan Sidwell
2016-10-12 18:25         ` Nathan Sidwell
2016-10-13 22:10           ` Andrew Pinski
2016-10-14 10:53             ` Nathan Sidwell
2016-10-12 12:23 ` Bernd Schmidt
2016-10-12 12:54   ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).