gcov: Fix first time gcov info dump
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Mon, 2 May 2022 06:44:16 +0000 (08:44 +0200)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Mon, 2 May 2022 08:50:48 +0000 (10:50 +0200)
This patch fixes an issue introduced by commit
ef9a53feae5701953da9161afef2aea0329ec8b2:

gcc --coverage main.c && ./a.out
libgcov profiling error:a-main.gcda:Error writing

gcc/ChangeLog:

* gcov-io.cc (gcov_rewrite):  Clear the file error status.

gcc/gcov-io.cc

index fdf745e..62032cc 100644 (file)
@@ -79,11 +79,14 @@ gcov_is_error (void)
 }
 
 #if IN_LIBGCOV
-/* Move to beginning of file and initialize for writing.  */
+/* Move to beginning of file, initialize for writing, and clear file error
+   status.  */
+
 GCOV_LINKAGE inline void
 gcov_rewrite (void)
 {
   gcov_var.mode = -1; 
+  gcov_var.error = GCOV_FILE_NO_ERROR;
   fseek (gcov_var.file, 0L, SEEK_SET);
 }
 #endif