This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: silence warnings in gprof/corefile.c
- From: Ben Elliston <bje at au1 dot ibm dot com>
- To: binutils at sourceware dot org
- Date: Mon, 15 Jan 2007 14:39:40 +1100
- Subject: PATCH: silence warnings in gprof/corefile.c
A patch to fix more warnings triggered by warn_ignored_result.
Okay for mainline?
2007-01-15 Ben Elliston <bje@au.ibm.com>
* corefile.c (read_function_mappings): Check calls to fscanf and
report any errors in parsing the mapping file.
Index: corefile.c
===================================================================
RCS file: /cvs/src/src/gprof/corefile.c,v
retrieving revision 1.24
diff -u -p -r1.24 corefile.c
--- corefile.c 22 Mar 2006 03:51:02 -0000 1.24
+++ corefile.c 15 Jan 2007 03:38:22 -0000
@@ -83,12 +83,24 @@ read_function_mappings (const char *file
/* Just skip messages about files with no symbols. */
if (!strncmp (dummy, "No symbols in ", 14))
{
- fscanf (file, "\n");
+ matches = fscanf (file, "\n");
+ if (matches == EOF)
+ {
+ fprintf (stderr, _("%s: unable to parse mapping file %s.\n"),
+ whoami, filename);
+ done (1);
+ }
continue;
}
/* Don't care what else is on this line at this point. */
- fscanf (file, "%[^\n]\n", dummy);
+ matches = fscanf (file, "%[^\n]\n", dummy);
+ if (!matches)
+ {
+ fprintf (stderr, _("%s: unable to parse mapping file %s.\n"),
+ whoami, filename);
+ done (1);
+ }
count++;
}
@@ -117,7 +129,13 @@ read_function_mappings (const char *file
/* Just skip messages about files with no symbols. */
if (!strncmp (dummy, "No symbols in ", 14))
{
- fscanf (file, "\n");
+ matches = fscanf (file, "\n");
+ if (matches == EOF)
+ {
+ fprintf (stderr, _("%s: unable to parse mapping file %s.\n"),
+ whoami, filename);
+ done (1);
+ }
continue;
}
@@ -126,7 +144,13 @@ read_function_mappings (const char *file
strcpy (symbol_map[count].file_name, dummy);
/* Now we need the function name. */
- fscanf (file, "%[^\n]\n", dummy);
+ matches = fscanf (file, "%[^\n]\n", dummy);
+ if (!matches)
+ {
+ fprintf (stderr, _("%s: unable to parse mapping file %s.\n"),
+ whoami, filename);
+ done (1);
+ }
tmp = strrchr (dummy, ' ') + 1;
symbol_map[count].function_name = xmalloc (strlen (tmp) + 1);
strcpy (symbol_map[count].function_name, tmp);