qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] tests: Fix bios-tables-test -Werror compilation err


From: Maciej W. Rozycki
Subject: [Qemu-devel] [PATCH] tests: Fix bios-tables-test -Werror compilation error
Date: Tue, 2 Dec 2014 16:27:20 +0000
User-agent: Alpine 1.10 (DEB 962 2008-03-14)

Fix:

.../tests/bios-tables-test.c: In function 'main':
.../tests/bios-tables-test.c:796:11: error: ignoring return value of 'fwrite', 
declared with attribute warn_unused_result [-Werror=unused-result]
cc1: all warnings being treated as errors
make: *** [tests/bios-tables-test.o] Error 1

happening when building QEMU with the `--enable-werror' configuration 
option present.  Report any failure from `fwrite'.

Signed-off-by: Maciej W. Rozycki <address@hidden>
---
qemu-test-bios-tables-fwrite.diff
Index: qemu-git-trunk/tests/bios-tables-test.c
===================================================================
--- qemu-git-trunk.orig/tests/bios-tables-test.c        2014-11-21 
11:56:04.000000000 +0000
+++ qemu-git-trunk/tests/bios-tables-test.c     2014-12-02 15:52:27.868971680 
+0000
@@ -787,14 +787,21 @@ int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
     FILE *f = fopen(disk, "w");
+    size_t s;
+    int err;
     int ret;
 
     if (!f) {
         fprintf(stderr, "Couldn't open \"%s\": %s", disk, strerror(errno));
         return 1;
     }
-    fwrite(boot_sector, 1, sizeof boot_sector, f);
+    s = fwrite(boot_sector, 1, sizeof boot_sector, f);
+    err = errno;
     fclose(f);
+    if (s != sizeof boot_sector) {
+        fprintf(stderr, "Couldn't write \"%s\": %s", disk, strerror(err));
+        return 1;
+    }
 
     g_test_init(&argc, &argv, NULL);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]