This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Questionable code in gcov-io.c
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 12 Oct 2016 14:10:01 +0200
- Subject: Questionable code in gcov-io.c
- Authentication-results: sourceware.org; auth=none
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