Skip to contentSkip to conversation

fw_cfg: print error message when reading splashfile failed

PATCH In review Li Qiang 4 participants 5 messages Oct 24, 2018 – Nov 1, 2018

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 fw_cfg: print error message when reading splashfile failed

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..f4a52d8 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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Li Qiang

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..f4a52d8 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;
     }

Seems to be OK, according to
<https://developer.gnome.org/glib/stable/glib-Error-Reporting.html#glib-Error-Reporting.description>.

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

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..f4a52d8 100644
@@ -68,15 +68,14 @@ static char *read_splashfile(char *filename, gsize *file_sizep,
                               int *file_typep)
  {
      GError *err = NULL;
-    gboolean res;

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

Quoted 10 lines
hw/nvram/fw_cfg.c +2 -3
      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",

Can you use a column like the rest of the codebase?

i.e.: "failed to read splash file '%s': %s"

The maintainer taking this patch can do this minor change, so:

Quoted 5 lines
hw/nvram/fw_cfg.c +1 -0
+                     filename, err->message);
          g_error_free(err);
          return NULL;
      }
#3 lore raw
Quoted 30 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Li Qiang

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..f4a52d8 100644
@@ -68,15 +68,14 @@ static char *read_splashfile(char *filename, gsize *file_sizep,
                               int *file_typep)
  {
      GError *err = NULL;
-    gboolean res;

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

Quoted 10 lines
hw/nvram/fw_cfg.c +2 -2
      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",

Can you use a column like the rest of the codebase?

Quoted 1 line

i.e.: "failed to read splash file '%s': %s"

Yes, please.

Also, my remark on your "[PATCH] vl.c: print error message if loading fw_cfg file failed" applies to this patch as well. Please improve the commit message.

Quoted 8 lines

The maintainer taking this patch can do this minor change, so:

Quoted 5 lines
hw/nvram/fw_cfg.c +1 -0
+                     filename, err->message);
          g_error_free(err);
          return NULL;
      }
author
#4 lore raw

Hello all,

I have sent out another patch.

As the email's subject and commit message changed,
I'm not sure is it suitable to add Philippe and Laszlo's R-b tag.

Thanks,
Li Qiang

Quoted 50 lines · Markus Armbruster <[email protected]> 于2018年10月31日周三 下午11:36写道:
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Li Qiang

Also remove unnecessary 'res' variable.

---
  hw/nvram/fw_cfg.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
Quoted 5 lines

hw/nvram/fw_cfg.c static char *read_splashfile(char *filename, gsize

Quoted 5 lines
hw/nvram/fw_cfg.c +0 -0
index 946f765..f4a52d8 100644
@@ -68,15 +68,14 @@ static char *read_splashfile(char *filename, gsize

*file_sizep,

Quoted 15 lines
Quoted 4 lines
hw/nvram/fw_cfg.c +0 -1
                               int *file_typep)
  {
      GError *err = NULL;
-    gboolean res;

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

Quoted 10 lines
hw/nvram/fw_cfg.c +2 -2
      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",
Quoted 3 lines

Can you use a column like the rest of the codebase?

i.e.: "failed to read splash file '%s': %s"

Yes, please.

Also, my remark on your "[PATCH] vl.c: print error message if loading fw_cfg file failed" applies to this patch as well. Please improve the commit message.

Quoted 8 lines

The maintainer taking this patch can do this minor change, so:

Quoted 5 lines
hw/nvram/fw_cfg.c +1 -0
+                     filename, err->message);
          g_error_free(err);
          return NULL;
      }