Skip to contentSkip to conversation

device_tree.c: redirect load_device_tree err message to stderr

PATCH Superseded john.liuli 3 participants 4 messages Aug 25, 2014 – Aug 26, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

john.liuli

author
#0 lore raw

PATCH 1/1 device_tree.c: redirect load_device_tree err message to stderr

From: Li Liu <[email protected]>

---
 device_tree.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
device_tree.c +4 -4
index ca83504..ccdb039 100644
@@ -79,7 +79,7 @@ void *load_device_tree(const char *filename_path, int *sizep)
     *sizep = 0;
     dt_size = get_image_size(filename_path);
     if (dt_size < 0) {
-        printf("Unable to get size of device tree file '%s'\n",
+        fprintf(stderr, "Unable to get size of device tree file '%s'\n",
             filename_path);
         goto fail;
     }
@@ -92,20 +92,20 @@ void *load_device_tree(const char *filename_path, int *sizep)
 
     dt_file_load_size = load_image(filename_path, fdt);
     if (dt_file_load_size < 0) {
-        printf("Unable to open device tree file '%s'\n",
+        fprintf(stderr, "Unable to open device tree file '%s'\n",
                filename_path);
         goto fail;
     }
 
     ret = fdt_open_into(fdt, fdt, dt_size);
     if (ret) {
-        printf("Unable to copy device tree in memory\n");
+        fprintf(stderr, "Unable to copy device tree in memory\n");
         goto fail;
     }
 
     /* Check sanity of device tree */
     if (fdt_check_header(fdt)) {
-        printf ("Device tree file loaded into memory is invalid: %s\n",
+        fprintf(stderr, "Device tree file loaded into memory is invalid: %s\n",
             filename_path);
         goto fail;
     }
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · john.liuli

From: Li Liu <[email protected]>

---
 device_tree.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
device_tree.c +1 -1
index ca83504..ccdb039 100644
@@ -79,7 +79,7 @@ void *load_device_tree(const char *filename_path, int *sizep)
     *sizep = 0;
     dt_size = get_image_size(filename_path);
     if (dt_size < 0) {
-        printf("Unable to get size of device tree file '%s'\n",
+        fprintf(stderr, "Unable to get size of device tree file '%s'\n",
             filename_path);
         goto fail;
     }

device_tree.c void *load_device_tree(const char *filename_path, int *sizep) · line 96

Quoted 6 lines
device_tree.c +1 -1
@@ -92,20 +92,20 @@ void *load_device_tree(const char *filename_path, int *sizep)
 
     dt_file_load_size = load_image(filename_path, fdt);
     if (dt_file_load_size < 0) {
-        printf("Unable to open device tree file '%s'\n",
+        fprintf(stderr, "Unable to open device tree file '%s'\n",
                filename_path);

Indent this line by one more space to keep continued fn args aligned to the "(". The other two are currently broken wrt to this issue, but you could fix them too.

Otherwise:

I had some code somewhere that coverts this API to use Error **'s but your patch is definitely a step in the right direction, while (and if) that happens. I suggest cc'ing qemu-trivial for a merge.

Regards,
peter

Quoted 22 lines
device_tree.c +2 -3
         goto fail;
     }
 
     ret = fdt_open_into(fdt, fdt, dt_size);
     if (ret) {
-        printf("Unable to copy device tree in memory\n");
+        fprintf(stderr, "Unable to copy device tree in memory\n");
         goto fail;
     }
 
     /* Check sanity of device tree */
     if (fdt_check_header(fdt)) {
-        printf ("Device tree file loaded into memory is invalid: %s\n",
+        fprintf(stderr, "Device tree file loaded into memory is invalid: %s\n",
             filename_path);
         goto fail;
     }
--

1.7.9.5

#2 lore raw
In reply to john.liuli
Quoted 34 lines · john.liuli

From: Li Liu <[email protected]>

---
 device_tree.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
device_tree.c +3 -3
index ca83504..ccdb039 100644
@@ -79,7 +79,7 @@ void *load_device_tree(const char *filename_path, int *sizep)
     *sizep = 0;
     dt_size = get_image_size(filename_path);
     if (dt_size < 0) {
-        printf("Unable to get size of device tree file '%s'\n",
+        fprintf(stderr, "Unable to get size of device tree file '%s'\n",
             filename_path);
         goto fail;
     }
@@ -92,20 +92,20 @@ void *load_device_tree(const char *filename_path, int *sizep)
 
     dt_file_load_size = load_image(filename_path, fdt);
     if (dt_file_load_size < 0) {
-        printf("Unable to open device tree file '%s'\n",
+        fprintf(stderr, "Unable to open device tree file '%s'\n",
                filename_path);
         goto fail;
     }
 
     ret = fdt_open_into(fdt, fdt, dt_size);
     if (ret) {
-        printf("Unable to copy device tree in memory\n");
+        fprintf(stderr, "Unable to copy device tree in memory\n");

device_tree.c void *load_device_tree(const char *filename_path, int *sizep) · line 111

Quoted 10 lines
device_tree.c +1 -1
         goto fail;
     }
 
     /* Check sanity of device tree */
     if (fdt_check_header(fdt)) {
-        printf ("Device tree file loaded into memory is invalid: %s\n",
+        fprintf(stderr, "Device tree file loaded into memory is invalid: %s\n",
             filename_path);
         goto fail;
     }

A welcome improvement. Further improvement would be using error_report().

#3 lore raw

Markus Armbruster <[email protected]> writes:

[...]

Quoted 2 lines

A welcome improvement. Further improvement would be using error_report().

Ah, you did that already in v2. Sorry for the noise!