* [PATCH, libiberty]: Check result of fwrite in test-expandargv.c
@ 2011-08-05 22:10 Uros Bizjak
2011-08-06 18:20 ` Uros Bizjak
0 siblings, 1 reply; 2+ messages in thread
From: Uros Bizjak @ 2011-08-05 22:10 UTC (permalink / raw)
To: gcc-patches; +Cc: DJ Delorie
[-- Attachment #1: Type: text/plain, Size: 811 bytes --]
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 <ubizjak@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.
[-- Attachment #2: l.diff.txt --]
[-- Type: text/plain, Size: 767 bytes --]
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);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, libiberty]: Check result of fwrite in test-expandargv.c
2011-08-05 22:10 [PATCH, libiberty]: Check result of fwrite in test-expandargv.c Uros Bizjak
@ 2011-08-06 18:20 ` Uros Bizjak
0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2011-08-06 18:20 UTC (permalink / raw)
To: gcc-patches; +Cc: DJ Delorie
On Fri, Aug 5, 2011 at 11:51 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> 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 <ubizjak@gmail.com>
>
> * testsuite/test-expandargv.c (writeout_test): Check result of fwrite.
>
> Tested on alphaev68-pc-linux-gnu and x86_64-pc-linux-gnu.
I have committed this patch as obvious. Please also note, that size
and nitems arguments to fwrite were reversed.
Uros.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-06 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-05 22:10 [PATCH, libiberty]: Check result of fwrite in test-expandargv.c Uros Bizjak
2011-08-06 18:20 ` Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).