Skip to contentSkip to conversation

hw/arm/boot: replace fprintf with error_report

PATCH Applied Osama Abdelkader 3 participants 6 messages Aug 23, 2025 – Sep 2, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/boot: replace fprintf with error_report

Replace direct fprintf(stderr, …) with QEMU's error_report() API, which ensures consistent formatting and integrates with QEMU's logging infrastructure.

---
 hw/arm/boot.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
hw/arm/boot.c +11 -11
index d391cd01bb..17c744762f 100644
@@ -531,13 +531,13 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
         char *filename;
         filename = qemu_find_file(QEMU_FILE_TYPE_DTB, binfo->dtb_filename);
         if (!filename) {
-            fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
+            error_report("Couldn't open dtb file %s", binfo->dtb_filename);
             goto fail;
         }
 
         fdt = load_device_tree(filename, &size);
         if (!fdt) {
-            fprintf(stderr, "Couldn't open dtb file %s\n", filename);
+            error_report("Couldn't open dtb file %s", filename);
             g_free(filename);
             goto fail;
         }
@@ -545,7 +545,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
     } else {
         fdt = binfo->get_dtb(binfo, &size);
         if (!fdt) {
-            fprintf(stderr, "Board was unable to create a dtb blob\n");
+            error_report("Board was unable to create a dtb blob");
             goto fail;
         }
     }
@@ -564,7 +564,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
     scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells",
                                    NULL, &error_fatal);
     if (acells == 0 || scells == 0) {
-        fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
+        error_report("dtb file invalid (#address-cells or #size-cells 0)");
         goto fail;
     }
 
@@ -572,8 +572,8 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
         /* This is user error so deserves a friendlier error message
          * than the failure of setprop_sized_cells would provide
          */
-        fprintf(stderr, "qemu: dtb file not compatible with "
-                "RAM size > 4GB\n");
+        error_report("qemu: dtb file not compatible with "
+                "RAM size > 4GB");
         goto fail;
     }
 
@@ -611,7 +611,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
             rc = fdt_add_memory_node(fdt, acells, mem_base,
                                      scells, mem_len, i);
             if (rc < 0) {
-                fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n",
+                error_report("couldn't add /memory@%"PRIx64" node",
                         mem_base);
                 goto fail;
             }
@@ -622,7 +622,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
         rc = fdt_add_memory_node(fdt, acells, binfo->loader_start,
                                  scells, binfo->ram_size, -1);
         if (rc < 0) {
-            fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n",
+            error_report("couldn't add /memory@%"PRIx64" node",
                     binfo->loader_start);
             goto fail;
         }
@@ -637,7 +637,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
         rc = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
                                      ms->kernel_cmdline);
         if (rc < 0) {
-            fprintf(stderr, "couldn't set /chosen/bootargs\n");
+            error_report("couldn't set /chosen/bootargs");
             goto fail;
         }
     }
@@ -646,7 +646,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
         rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,initrd-start",
                                           acells, binfo->initrd_start);
         if (rc < 0) {
-            fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
+            error_report("couldn't set /chosen/linux,initrd-start");
             goto fail;
         }
 
@@ -655,7 +655,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
                                           binfo->initrd_start +
                                           binfo->initrd_size);
         if (rc < 0) {
-            fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
+            error_report("couldn't set /chosen/linux,initrd-end");
             goto fail;
         }
     }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Osama Abdelkader

Replace direct fprintf(stderr, …) with QEMU's error_report() API, which ensures consistent formatting and integrates with QEMU's logging infrastructure.

---
 hw/arm/boot.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Applied to target-arm.next, thanks.

-- PMM

#2 lore raw
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Osama Abdelkader

Replace direct fprintf(stderr, …) with QEMU's error_report() API, which ensures consistent formatting and integrates with QEMU's logging infrastructure.

Quoted 8 lines
Quoted 4 lines
---
 hw/arm/boot.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Applied to target-arm.next, thanks.

I didn't see this had been posted but I did a more extensive clean-up here:

Message-ID: <[email protected]>
Date: Mon, 1 Sep 2025 13:53:00 +0100
Subject: [PATCH 0/4] arm_load_dtb cleanups
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <[email protected]>

Quoted 2 lines

-- PMM

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#3 lore raw
Quoted 21 lines · Alex Bennée
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Osama Abdelkader

Replace direct fprintf(stderr, …) with QEMU's error_report() API, which ensures consistent formatting and integrates with QEMU's logging infrastructure.

Quoted 8 lines
Quoted 4 lines
---
 hw/arm/boot.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Applied to target-arm.next, thanks.

I didn't see this had been posted but I did a more extensive clean-up here:

Quoted 11 lines

Message-ID: <[email protected]>
Date: Mon, 1 Sep 2025 13:53:00 +0100
Subject: [PATCH 0/4] arm_load_dtb cleanups
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <[email protected]>

Quoted 2 lines

-- PMM

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro

sorry Alex, I didn't know that your patch set covers that. I just submitted a simple patch to replace fprintf in raspi4b Would appreciate your review.

Thank you.

Regards,
Osama

#4 lore raw
Quoted 28 lines · Osama Abdelkader
Quoted 27 lines · Alex Bennée
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Osama Abdelkader

Replace direct fprintf(stderr, …) with QEMU's error_report() API, which ensures consistent formatting and integrates with QEMU's logging infrastructure.

Quoted 8 lines
Quoted 4 lines
---
 hw/arm/boot.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Applied to target-arm.next, thanks.

I didn't see this had been posted but I did a more extensive clean-up here:

Message-ID: <[email protected]>
Date: Mon, 1 Sep 2025 13:53:00 +0100
Subject: [PATCH 0/4] arm_load_dtb cleanups
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <[email protected]>

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

-- PMM

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro

sorry Alex, I didn't know that your patch set covers that.

No need to apologise - qemu-devel is a firehose of patches so its inevitable two or more people might touch the same thing at the same time.

Quoted 2 lines

I just submitted a simple patch to replace fprintf in raspi4b Would appreciate your review.

I have left some comments.

Quoted 5 lines

Thank you.

Regards,
Osama

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#5 lore raw
In reply to Alex Bennée
Quoted 19 lines · Alex Bennée
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Osama Abdelkader

Replace direct fprintf(stderr, …) with QEMU's error_report() API, which ensures consistent formatting and integrates with QEMU's logging infrastructure.

Quoted 8 lines
Quoted 4 lines
---
 hw/arm/boot.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Applied to target-arm.next, thanks.

Quoted 7 lines

I didn't see this had been posted but I did a more extensive clean-up here:

Message-ID: <[email protected]>
Date: Mon, 1 Sep 2025 13:53:00 +0100
Subject: [PATCH 0/4] arm_load_dtb cleanups
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <[email protected]>

OK, I'll drop this one and take that series instead: it does look like it does a more comprehensive approach.

-- PMM