qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v7] tests/bios-tables-test: check the value returned by fopen()
@ 2014-08-18  7:54 zhanghailiang
  2014-08-18  8:10 ` Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: zhanghailiang @ 2014-08-18  7:54 UTC (permalink / raw)
  To: qemu-devel
  Cc: zhanghailiang, marcel.a, qemu-trivial, Li Liu, mst, luonengjun,
	peter.huangpeng

The function fopen() may fail, so check its return value.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Li Liu <john.liuli@huawei.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/bios-tables-test.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 045eb27..feb3b58 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -790,6 +790,11 @@ int main(int argc, char *argv[])
     const char *arch = qtest_get_arch();
     FILE *f = fopen(disk, "w");
     int ret;
+
+    if (!f) {
+        fprintf(stderr, "Couldn't open \"%s\": %s", disk, strerror(errno));
+        return -1;
+    }
     fwrite(boot_sector, 1, sizeof boot_sector, f);
     fclose(f);
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-08-18 21:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-18  7:54 [Qemu-devel] [PATCH v7] tests/bios-tables-test: check the value returned by fopen() zhanghailiang
2014-08-18  8:10 ` Peter Maydell
2014-08-18  9:13 ` Marcel Apfelbaum
2014-08-18 11:37   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-08-18 12:26     ` Marcel Apfelbaum
2014-08-18 13:51     ` Michael S. Tsirkin
2014-08-18 11:38 ` Michael Tokarev
2014-08-18 13:44   ` Michael S. Tsirkin
2014-08-18 14:24     ` Michael Tokarev
2014-08-18 19:36       ` Michael S. Tsirkin
2014-08-18 21:01         ` Peter Maydell

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 NNTP newsgroup(s).