vl.c: print error message if load fw_cfg file failed
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.
Signed-off-by Li Qiang <[email protected]>
--- vl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
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);return -1 ; } }
Signature · 1 line
2.17.1
Quoted 13 lines · Li Qiang
It makes sense to print the error message while reading file failed.
Signed-off-by Li Qiang <[email protected]>--- vl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)vl.c +0
-0
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);
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 4 lines
vl.c +0
-0return -1 ; } }
Philippe Mathieu-Daudé
Reviewed-byHi Li,
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Li Qiang
It makes sense to print the error message while reading file failed.
Signed-off-by Li Qiang <[email protected]>--- 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@@ -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:
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 5 lines
Quoted 5 lines
vl.c +0
-0return -1 ; } }