Re: [Qemu-devel] [PATCH QEMU v1 4/4] multiboot: fprintf(stderr...) -> error_report()
+-- On Thu, 21 Dec 2017, Jack Schwartz wrote --+ | Change all fprintf(stderr...) calls in hw/i386/multiboot.c to call | error_report() instead, including the mb_debug macro. Remove the "\n" | from strings passed to all modified calls, since error_report() appends | one. | | Signed-off-by: Jack Schwartz| Reviewed-by: Daniel Kiper | --- | hw/i386/multiboot.c | 55 - | 1 file changed, 29 insertions(+), 26 deletions(-) | | diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c | index 818728b..d9a0a95 100644 | --- a/hw/i386/multiboot.c | +++ b/hw/i386/multiboot.c | @@ -31,12 +31,13 @@ | #include "hw/loader.h" | #include "elf.h" | #include "sysemu/sysemu.h" | +#include "qemu/error-report.h" | | /* Show multiboot debug output */ | //#define DEBUG_MULTIBOOT | | #ifdef DEBUG_MULTIBOOT | -#define mb_debug(a...) fprintf(stderr, ## a) | +#define mb_debug(a...) error_report(a) | #else | #define mb_debug(a...) | #endif | @@ -137,7 +138,7 @@ static void mb_add_mod(MultibootState *s, | stl_p(p + MB_MOD_END, end); | stl_p(p + MB_MOD_CMDLINE, cmdline_phys); | | -mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n", | +mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx, | s->mb_mods_count, start, end); | | s->mb_mods_count++; | @@ -179,12 +180,12 @@ int load_multiboot(FWCfgState *fw_cfg, | if (!is_multiboot) | return 0; /* no multiboot */ | | -mb_debug("qemu: I believe we found a multiboot image!\n"); | +mb_debug("qemu: I believe we found a multiboot image!"); | memset(bootinfo, 0, sizeof(bootinfo)); | memset(, 0, sizeof(mbs)); | | if (flags & 0x0004) { /* MULTIBOOT_HEADER_HAS_VBE */ | -fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n"); | +error_report("qemu: multiboot knows VBE. we don't."); | } | if (!(flags & 0x0001)) { /* MULTIBOOT_HEADER_HAS_ADDR */ | uint64_t elf_entry; | @@ -193,7 +194,7 @@ int load_multiboot(FWCfgState *fw_cfg, | fclose(f); | | if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) { | -fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n"); | +error_report("Cannot load x86-64 image, give a 32bit one."); | exit(1); | } | | @@ -201,7 +202,7 @@ int load_multiboot(FWCfgState *fw_cfg, | _low, _high, 0, I386_ELF_MACHINE, | 0, 0); | if (kernel_size < 0) { | -fprintf(stderr, "Error while loading elf kernel\n"); | +error_report("Error while loading elf kernel"); | exit(1); | } | mh_load_addr = elf_low; | @@ -210,12 +211,13 @@ int load_multiboot(FWCfgState *fw_cfg, | | mbs.mb_buf = g_malloc(mb_kernel_size); | if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) { | -fprintf(stderr, "Error while fetching elf kernel from rom\n"); | +error_report("Error while fetching elf kernel from rom"); | exit(1); | } | | -mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n", | - mb_kernel_size, (size_t)mh_entry_addr); | +mb_debug("qemu: loading multiboot-elf kernel " | + "(%#x bytes) with entry %#zx", | + mb_kernel_size, (size_t)mh_entry_addr); | } else { | /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ | uint32_t mh_header_addr = ldl_p(header+i+12); | @@ -224,7 +226,7 @@ int load_multiboot(FWCfgState *fw_cfg, | | mh_load_addr = ldl_p(header+i+16); | if (mh_header_addr < mh_load_addr) { | -fprintf(stderr, "invalid load_addr address\n"); | +error_report("invalid load_addr address"); | exit(1); | } | | @@ -234,20 +236,20 @@ int load_multiboot(FWCfgState *fw_cfg, | | if (mh_load_end_addr) { | if (mh_load_end_addr < mh_load_addr) { | -fprintf(stderr, "invalid load_end_addr address\n"); | +error_report("invalid load_end_addr address"); | exit(1); | } | mb_load_size = mh_load_end_addr - mh_load_addr; | } else { | if (kernel_file_size < mb_kernel_text_offset) { | -fprintf(stderr, "invalid kernel_file_size\n"); | +error_report("invalid kernel_file_size"); | exit(1); | } | mb_load_size = kernel_file_size - mb_kernel_text_offset; | } | if (mh_bss_end_addr) { | if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { | -fprintf(stderr, "invalid bss_end_addr address\n"); | +error_report("invalid bss_end_addr address"); |
[Qemu-devel] [PATCH QEMU v1 4/4] multiboot: fprintf(stderr...) -> error_report()
Change all fprintf(stderr...) calls in hw/i386/multiboot.c to call error_report() instead, including the mb_debug macro. Remove the "\n" from strings passed to all modified calls, since error_report() appends one. Signed-off-by: Jack SchwartzReviewed-by: Daniel Kiper --- hw/i386/multiboot.c | 55 - 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 818728b..d9a0a95 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -31,12 +31,13 @@ #include "hw/loader.h" #include "elf.h" #include "sysemu/sysemu.h" +#include "qemu/error-report.h" /* Show multiboot debug output */ //#define DEBUG_MULTIBOOT #ifdef DEBUG_MULTIBOOT -#define mb_debug(a...) fprintf(stderr, ## a) +#define mb_debug(a...) error_report(a) #else #define mb_debug(a...) #endif @@ -137,7 +138,7 @@ static void mb_add_mod(MultibootState *s, stl_p(p + MB_MOD_END, end); stl_p(p + MB_MOD_CMDLINE, cmdline_phys); -mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n", +mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx, s->mb_mods_count, start, end); s->mb_mods_count++; @@ -179,12 +180,12 @@ int load_multiboot(FWCfgState *fw_cfg, if (!is_multiboot) return 0; /* no multiboot */ -mb_debug("qemu: I believe we found a multiboot image!\n"); +mb_debug("qemu: I believe we found a multiboot image!"); memset(bootinfo, 0, sizeof(bootinfo)); memset(, 0, sizeof(mbs)); if (flags & 0x0004) { /* MULTIBOOT_HEADER_HAS_VBE */ -fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n"); +error_report("qemu: multiboot knows VBE. we don't."); } if (!(flags & 0x0001)) { /* MULTIBOOT_HEADER_HAS_ADDR */ uint64_t elf_entry; @@ -193,7 +194,7 @@ int load_multiboot(FWCfgState *fw_cfg, fclose(f); if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) { -fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n"); +error_report("Cannot load x86-64 image, give a 32bit one."); exit(1); } @@ -201,7 +202,7 @@ int load_multiboot(FWCfgState *fw_cfg, _low, _high, 0, I386_ELF_MACHINE, 0, 0); if (kernel_size < 0) { -fprintf(stderr, "Error while loading elf kernel\n"); +error_report("Error while loading elf kernel"); exit(1); } mh_load_addr = elf_low; @@ -210,12 +211,13 @@ int load_multiboot(FWCfgState *fw_cfg, mbs.mb_buf = g_malloc(mb_kernel_size); if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) { -fprintf(stderr, "Error while fetching elf kernel from rom\n"); +error_report("Error while fetching elf kernel from rom"); exit(1); } -mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n", - mb_kernel_size, (size_t)mh_entry_addr); +mb_debug("qemu: loading multiboot-elf kernel " + "(%#x bytes) with entry %#zx", + mb_kernel_size, (size_t)mh_entry_addr); } else { /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ uint32_t mh_header_addr = ldl_p(header+i+12); @@ -224,7 +226,7 @@ int load_multiboot(FWCfgState *fw_cfg, mh_load_addr = ldl_p(header+i+16); if (mh_header_addr < mh_load_addr) { -fprintf(stderr, "invalid load_addr address\n"); +error_report("invalid load_addr address"); exit(1); } @@ -234,20 +236,20 @@ int load_multiboot(FWCfgState *fw_cfg, if (mh_load_end_addr) { if (mh_load_end_addr < mh_load_addr) { -fprintf(stderr, "invalid load_end_addr address\n"); +error_report("invalid load_end_addr address"); exit(1); } mb_load_size = mh_load_end_addr - mh_load_addr; } else { if (kernel_file_size < mb_kernel_text_offset) { -fprintf(stderr, "invalid kernel_file_size\n"); +error_report("invalid kernel_file_size"); exit(1); } mb_load_size = kernel_file_size - mb_kernel_text_offset; } if (mh_bss_end_addr) { if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { -fprintf(stderr, "invalid bss_end_addr address\n"); +error_report("invalid bss_end_addr address"); exit(1); } mb_kernel_size = mh_bss_end_addr - mh_load_addr; @@ -255,17 +257,17 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size = mb_load_size; } -mb_debug("multiboot: header_addr = %#x\n", mh_header_addr); -