Hello!

My system warns during compilation of libiberty test-expandargv.c test:

gcc -DHAVE_CONFIG_H -g -O2 -I..
-I../../../gcc-svn/trunk/libiberty/testsuite/../../include
-DHAVE_CONFIG_H -I.. -o test-expandargv \
        ../../../gcc-svn/trunk/libiberty/testsuite/test-expandargv.c 
../libiberty.a
../../../gcc-svn/trunk/libiberty/testsuite/test-expandargv.c: In
function ‘writeout_test’:
../../../gcc-svn/trunk/libiberty/testsuite/test-expandargv.c:211:
warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_result

Attached patch fixes this warning.

2011-08-05  Uros Bizjak  <ubiz...@gmail.com>

        * testsuite/test-expandargv.c (writeout_test): Check result of fwrite.

Tested on alphaev68-pc-linux-gnu and x86_64-pc-linux-gnu.

OK for mainline SVN and 4.6?

Uros.
Index: testsuite/test-expandargv.c
===================================================================
--- testsuite/test-expandargv.c (revision 177430)
+++ testsuite/test-expandargv.c (working copy)
@@ -189,7 +189,7 @@ writeout_test (int test, const char * test_data)
 {
   char filename[256];
   FILE *fd;
-  size_t len;
+  size_t len, sys_fwrite;
   char * parse;
 
   /* Unique filename per test */
@@ -208,7 +208,10 @@ writeout_test (int test, const char * test_data)
   /* Run all possible replaces */
   run_replaces (parse);
 
-  fwrite (parse, len, sizeof (char), fd);
+  sys_fwrite = fwrite (parse, sizeof (char), len, fd);
+  if (sys_fwrite != len)
+    fatal_error (__LINE__, "Failed to write to test file.", errno);
+
   free (parse);
   fclose (fd);
 }

Reply via email to