Skip to contentSkip to conversation

vl.c: print error message if load fw_cfg file failed

PATCH In review Li Qiang 2 participants 3 messages Oct 7, 2018 – Oct 8, 2018

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 vl.c: print error message if load fw_cfg file failed

It makes sense to print the error message while reading file failed.

---
 vl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
vl.c +3 -2
index cc55fe04a2..3db410e771 100644
@@ -2207,8 +2207,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
         size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
         buf = g_memdup(str, size);
     } else {
-        if (!g_file_get_contents(file, &buf, &size, NULL)) {
-            error_report("can't load %s", file);
+        GError *error = NULL;
+        if (!g_file_get_contents(file, &buf, &size, &error)) {
+            error_report("can't load %s, %s", file, error->message);
             return -1;
         }
     }
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Li Qiang

It makes sense to print the error message while reading file failed.

---
 vl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
vl.c +0 -0
index cc55fe04a2..3db410e771 100644

vl.c static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) · line 2212

Quoted 8 lines
vl.c +3 -2
@@ -2207,8 +2207,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
         size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
         buf = g_memdup(str, size);
     } else {
-        if (!g_file_get_contents(file, &buf, &size, NULL)) {
-            error_report("can't load %s", file);
+        GError *error = NULL;
+        if (!g_file_get_contents(file, &buf, &size, &error)) {
+            error_report("can't load %s, %s", file, error->message);
Quoted 4 lines
vl.c +0 -0
             return -1;
         }
     }
#2 lore raw

Hi Li,

Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Li Qiang

It makes sense to print the error message while reading file failed.

---
 vl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 13 lines

vl.c static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) · line 2212

Quoted 13 lines
vl.c +3 -2
index cc55fe04a2..3db410e771 100644
@@ -2207,8 +2207,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
         size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
         buf = g_memdup(str, size);
     } else {
-        if (!g_file_get_contents(file, &buf, &size, NULL)) {
-            error_report("can't load %s", file);
+        GError *error = NULL;
+        if (!g_file_get_contents(file, &buf, &size, &error)) {
+            error_report("can't load %s, %s", file, error->message);

You forgot:

                    g_error_free(error);

With the free:

Quoted 5 lines
Quoted 5 lines
vl.c +0 -0
             return -1;
         }
     }