tools/makedep.c: check return values of "fgets","ftruncate" to prevent gcc warning messages with -Werror
titon barua
titanix88 at gmail.com
Sat Jan 3 17:53:27 CST 2009
---
tools/makedep.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c
index 2571359..2e33c6e 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -196,7 +196,8 @@ static char *get_line( FILE *file )
while (p == buffer + size - 1 && p[-1] != '\n')
{
buffer = xrealloc( buffer, size * 2 );
- fgets( buffer + size - 1, size + 1, file );
+ /* in case of a read error, NULL is returned */
+ if (!fgets( buffer + size - 1, size + 1, file )) return NULL;
p = buffer + strlen(buffer);
size *= 2;
}
@@ -208,7 +209,7 @@ static char *get_line( FILE *file )
{
*(--p) = 0;
/* line ends in backslash, read continuation line */
- fgets( p, size - (p - buffer), file );
+ if (!fgets( p, size - (p - buffer), file )) return NULL;
input_line++;
continue;
}
@@ -880,7 +881,12 @@ static void output_dependencies(void)
while ((buffer = get_line( file )))
{
if (strncmp( buffer, Separator, strlen(Separator) )) continue;
- ftruncate( fileno(file), ftell(file) );
+ /* report error in case of failure to truncate*/
+ if (ftruncate( fileno(file), ftell(file) ) == -1)
+ {
+ perror( OutputFileName );
+ exit(1);
+ }
fseek( file, 0L, SEEK_END );
break;
}
--
1.5.6.3
More information about the wine-patches
mailing list