gen_init_cpio: fixed fwrite warning
authorMike Frysinger <vapier@gentoo.org>
Wed, 9 Dec 2009 11:55:19 +0000 (06:55 -0500)
committerMichal Marek <mmarek@suse.cz>
Sat, 12 Dec 2009 12:08:17 +0000 (13:08 +0100)
On compilers with security warnings enabled by default, we get:

usr/gen_init_cpio.c: In function ‘cpio_mkfile’:
usr/gen_init_cpio.c:357: warning: ignoring return value of ‘fwrite’,
                                  declared with attribute warn_unused_result

So check the return value and handle errors accordingly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
usr/gen_init_cpio.c

index 83b3dde1a83b74a5f1e75cb2d98a44787e33bca2..b2b3c2d1cf8bd37849d92b9a1d06131f1cf14f96 100644 (file)
@@ -354,7 +354,10 @@ static int cpio_mkfile(const char *name, const char *location,
                push_pad();
 
                if (size) {
-                       fwrite(filebuf, size, 1, stdout);
+                       if (fwrite(filebuf, size, 1, stdout) != 1) {
+                               fprintf(stderr, "writing filebuf failed\n");
+                               goto error;
+                       }
                        offset += size;
                        push_pad();
                }