From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25351 invoked by alias); 23 Jul 2003 21:38:13 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25342 invoked by uid 48); 23 Jul 2003 21:38:12 -0000 Date: Wed, 23 Jul 2003 21:38:00 -0000 From: "laurent dot deniel at free dot fr" To: gcc-bugs@gcc.gnu.org Message-ID: <20030723213810.11651.laurent.deniel@free.fr> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug other/11651] New: gcov aborts if empty .da files (patch attached) X-Bugzilla-Reason: CC X-SW-Source: 2003-07/txt/msg02776.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11651 Summary: gcov aborts if empty .da files (patch attached) Product: gcc Version: 3.2.3 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: other AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: laurent dot deniel at free dot fr CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: any-any-any GCC host triplet: any-any-any GCC target triplet: any-any-any Sometimes it is required to create empty .da files with appropriate rights to be able to run the instrumented executable with different users. But then, if some source files have not been executed, some .da files remain empty making gcov aborts. The simple fix below simply does the same thing with empty .da file as if the file was not present. --- gcov.c.ori 2003-07-23 22:17:41.000000000 +0200 +++ gcov.c 2003-07-23 22:25:50.000000000 +0200 @@ -471,6 +471,18 @@ fnotice (stderr, "Could not open data file %s.\n", da_file_name); fnotice (stderr, "Assuming that all execution counts are zero.\n"); } + + /* Check for empty .da file. Just assume that all execution counts are + zero in this case. */ + /* Set the EOF condition if at the end of file. */ + ungetc (getc (da_file), da_file); + if (feof (da_file)) + { + fnotice (stderr, "data file %s is empty.\n", da_file_name); + fnotice (stderr, "Assuming that all execution counts are zero.\n"); + fclose(da_file); + da_file = NULL; + } bbg_file = fopen (bbg_file_name, "rb"); if (bbg_file == NULL)