Skip to contentSkip to conversation

hw: fw_cfg: Improve error message when can't load splash file

PATCH In review Li Qiang 3 participants 4 messages Nov 1, 2018 – Dec 11, 2018

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 hw: fw_cfg: Improve error message when can't load splash file

read_splashfile() reports "failed to read splash file" without further details. Get the details from g_file_get_contents(), and include them in the error message. Also remove unnecessary 'res' variable.

---
 hw/nvram/fw_cfg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/nvram/fw_cfg.c +3 -4
index 946f765..3fcfa35 100644
@@ -68,15 +68,14 @@ static char *read_splashfile(char *filename, gsize *file_sizep,
                              int *file_typep)
 {
     GError *err = NULL;
-    gboolean res;
     gchar *content;
     int file_type;
     unsigned int filehead;
     int bmp_bpp;
 
-    res = g_file_get_contents(filename, &content, file_sizep, &err);
-    if (res == FALSE) {
-        error_report("failed to read splash file '%s'", filename);
+    if (!g_file_get_contents(filename, &content, file_sizep, &err)) {
+        error_report("failed to read splash file '%s': %s",
+                     filename, err->message);
         g_error_free(err);
         return NULL;
     }
Signature · 1 line
1.8.3.1
author
#1 lore raw

Hello Paolo, Philippe

Seems this patch has been lost...

I think Philippe can merge it for 4.0, right?
Also pls notice the following fw_cfg patchset. -->https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg04097.html

Thanks,
Li Qiang

Quoted 38 lines · Li Qiang <[email protected]> 于2018年11月1日周四 下午2:02写道:

read_splashfile() reports "failed to read splash file" without further details. Get the details from g_file_get_contents(), and include them in the error message. Also remove unnecessary 'res' variable.

---
 hw/nvram/fw_cfg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/nvram/fw_cfg.c +3 -4
index 946f765..3fcfa35 100644
@@ -68,15 +68,14 @@ static char *read_splashfile(char *filename, gsize
 *file_sizep,
                              int *file_typep)
 {
     GError *err = NULL;
-    gboolean res;
     gchar *content;
     int file_type;
     unsigned int filehead;
     int bmp_bpp;
 
-    res = g_file_get_contents(filename, &content, file_sizep, &err);
-    if (res == FALSE) {
-        error_report("failed to read splash file '%s'", filename);
+    if (!g_file_get_contents(filename, &content, file_sizep, &err)) {
+        error_report("failed to read splash file '%s': %s",
+                     filename, err->message);
         g_error_free(err);
         return NULL;
     }

--
1.8.3.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Li Qiang
Quoted 23 lines · Li Qiang

read_splashfile() reports "failed to read splash file" without further details. Get the details from g_file_get_contents(), and include them in the error message. Also remove unnecessary 'res' variable.

---
 hw/nvram/fw_cfg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/nvram/fw_cfg.c +0 -1
index 946f765..3fcfa35 100644
@@ -68,15 +68,14 @@ static char *read_splashfile(char *filename, gsize *file_sizep,
                              int *file_typep)
 {
     GError *err = NULL;
-    gboolean res;
     gchar *content;
     int file_type;
     unsigned int filehead;
     int bmp_bpp;

hw/nvram/fw_cfg.c static char *read_splashfile(char *filename, gsize *file_sizep, · line 81

Quoted 10 lines
hw/nvram/fw_cfg.c +3 -3
 
-    res = g_file_get_contents(filename, &content, file_sizep, &err);
-    if (res == FALSE) {
-        error_report("failed to read splash file '%s'", filename);
+    if (!g_file_get_contents(filename, &content, file_sizep, &err)) {
+        error_report("failed to read splash file '%s': %s",
+                     filename, err->message);
         g_error_free(err);
         return NULL;
     }

Philippe, I assume you'll take this.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Li Qiang
Quoted 24 lines · Li Qiang

read_splashfile() reports "failed to read splash file" without further details. Get the details from g_file_get_contents(), and include them in the error message. Also remove unnecessary 'res' variable.

---
 hw/nvram/fw_cfg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/nvram/fw_cfg.c +0 -1
index 946f765..3fcfa35 100644
@@ -68,15 +68,14 @@ static char *read_splashfile(char *filename, gsize *file_sizep,
                              int *file_typep)
 {
     GError *err = NULL;
-    gboolean res;
     gchar *content;
     int file_type;
     unsigned int filehead;
     int bmp_bpp;

hw/nvram/fw_cfg.c static char *read_splashfile(char *filename, gsize *file_sizep, · line 81

Quoted 10 lines
hw/nvram/fw_cfg.c +3 -3
 
-    res = g_file_get_contents(filename, &content, file_sizep, &err);
-    if (res == FALSE) {
-        error_report("failed to read splash file '%s'", filename);
+    if (!g_file_get_contents(filename, &content, file_sizep, &err)) {
+        error_report("failed to read splash file '%s': %s",
+                     filename, err->message);
         g_error_free(err);
         return NULL;
     }

and queued, thanks!

Phil.