qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 08/10] qtest: check the value returned by fop


From: zhanghailiang
Subject: Re: [Qemu-devel] [PATCH v3 08/10] qtest: check the value returned by fopen()
Date: Thu, 7 Aug 2014 19:33:29 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

On 2014/8/7 19:14, Gonglei (Arei) wrote:
Subject: [Qemu-devel] [PATCH v3 08/10] qtest: check the value returned by
fopen()

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

Signed-off-by: zhanghailiang<address@hidden>
Signed-off-by: Li Liu<address@hidden>
---
  qtest.c                  | 5 +++++
  tests/bios-tables-test.c | 2 ++
  2 files changed, 7 insertions(+)

diff --git a/qtest.c b/qtest.c
index 04a6dc1..ae9b636 100644
--- a/qtest.c
+++ b/qtest.c
@@ -536,6 +536,11 @@ void qtest_init(const char *qtest_chrdev, const char
*qtest_log, Error **errp)
      if (qtest_log) {
          if (strcmp(qtest_log, "none") != 0) {
              qtest_log_fp = fopen(qtest_log, "w+");
+            if (qtest_log_fp == NULL) {
+                error_setg(errp, "Failed to open log file for qtest: \"%s\"",
+                           qtest_log);
+                return;
+            }

Actually I don't think this check is necessary, because the qtest_log_fp will 
be checked
where it is used.


Hmm, you are right! I will remove the changes!

Thanks,
zhanghailiang

          }
      } else {
          qtest_log_fp = stderr;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 045eb27..6a357c0 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -790,6 +790,8 @@ int main(int argc, char *argv[])
      const char *arch = qtest_get_arch();
      FILE *f = fopen(disk, "w");
      int ret;
+
+    g_assert(f != NULL);
      fwrite(boot_sector, 1, sizeof boot_sector, f);
      fclose(f);

--
1.7.12.4







reply via email to

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