putw is supposed to return 0 (not the value written) on success
authorRich Felker <dalias@aerifal.cx>
Wed, 4 Jul 2012 16:21:22 +0000 (12:21 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 4 Jul 2012 16:21:22 +0000 (12:21 -0400)
this is not a standard but it's the traditional behavior and it's more
useful because the caller can reliably detect errors.

src/stdio/putw.c

index a6d2429..0ff9d7f 100644 (file)
@@ -3,5 +3,5 @@
 
 int putw(int x, FILE *f)
 {
-       return fwrite(&x, sizeof x, 1, f) ? x : EOF;
+       return (int)fwrite(&x, sizeof x, 1, f)-1;
 }