hw/ppc: Replace fprintf(stderr, "*\n" with error_report()

Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.

find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +
find ./* -type f -exec sed -i \
    'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
    {} +

Some lines were then manually tweaked to pass checkpatch and some curly
braces were added to match QEMU style.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-ppc@nongnu.org

Conversions that aren't followed by exit() dropped, because they might
be inappropriate.

Also trim trailing punctuation from error messages.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-10-armbru@redhat.com>
This commit is contained in:
Alistair Francis 2018-02-03 09:43:10 +01:00 committed by Markus Armbruster
parent 0151abe4f5
commit 6f76b817b5
7 changed files with 28 additions and 31 deletions

View File

@ -811,8 +811,8 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
cs = CPU(cpu); cs = CPU(cpu);
if (env->mmu_model != POWERPC_MMU_BOOKE206) { if (env->mmu_model != POWERPC_MMU_BOOKE206) {
fprintf(stderr, "MMU model %i not supported by this machine.\n", error_report("MMU model %i not supported by this machine",
env->mmu_model); env->mmu_model);
exit(1); exit(1);
} }
@ -959,8 +959,8 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
cur_base, cur_base,
ram_size - cur_base); ram_size - cur_base);
if (kernel_size < 0) { if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", error_report("could not load kernel '%s'",
machine->kernel_filename); machine->kernel_filename);
exit(1); exit(1);
} }
@ -974,8 +974,8 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
ram_size - initrd_base); ram_size - initrd_base);
if (initrd_size < 0) { if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", error_report("could not load initial ram disk '%s'",
machine->initrd_filename); machine->initrd_filename);
exit(1); exit(1);
} }
@ -1016,7 +1016,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
kernel_size = load_uimage(filename, &bios_entry, &loadaddr, NULL, kernel_size = load_uimage(filename, &bios_entry, &loadaddr, NULL,
NULL, NULL); NULL, NULL);
if (kernel_size < 0) { if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load firmware '%s'\n", filename); error_report("could not load firmware '%s'", filename);
exit(1); exit(1);
} }
} }
@ -1029,7 +1029,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
initrd_base, initrd_size, initrd_base, initrd_size,
kernel_base, kernel_size); kernel_base, kernel_size);
if (dt_size < 0) { if (dt_size < 0) {
fprintf(stderr, "couldn't load device tree\n"); error_report("couldn't load device tree");
exit(1); exit(1);
} }
assert(dt_size < DTB_MAX_SIZE); assert(dt_size < DTB_MAX_SIZE);

View File

@ -270,7 +270,7 @@ static void ppc_core99_init(MachineState *machine)
} }
} }
if (ppc_boot_device == '\0') { if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n"); error_report("No valid boot device for Mac99 machine");
exit(1); exit(1);
} }
} }

View File

@ -218,7 +218,7 @@ static void ppc_heathrow_init(MachineState *machine)
#endif #endif
} }
if (ppc_boot_device == '\0') { if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for G3 Beige machine\n"); error_report("No valid boot device for G3 Beige machine");
exit(1); exit(1);
} }
} }

View File

@ -331,8 +331,7 @@ static void ref405ep_init(MachineState *machine)
kernel_size = load_image_targphys(kernel_filename, kernel_base, kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base); ram_size - kernel_base);
if (kernel_size < 0) { if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", error_report("could not load kernel '%s'", kernel_filename);
kernel_filename);
exit(1); exit(1);
} }
printf("Load kernel size %ld at " TARGET_FMT_lx, printf("Load kernel size %ld at " TARGET_FMT_lx,
@ -343,8 +342,8 @@ static void ref405ep_init(MachineState *machine)
initrd_size = load_image_targphys(initrd_filename, initrd_base, initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base); ram_size - initrd_base);
if (initrd_size < 0) { if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", error_report("could not load initial ram disk '%s'",
initrd_filename); initrd_filename);
exit(1); exit(1);
} }
} else { } else {
@ -621,8 +620,7 @@ static void taihu_405ep_init(MachineState *machine)
kernel_size = load_image_targphys(kernel_filename, kernel_base, kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base); ram_size - kernel_base);
if (kernel_size < 0) { if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", error_report("could not load kernel '%s'", kernel_filename);
kernel_filename);
exit(1); exit(1);
} }
/* load initrd */ /* load initrd */
@ -631,9 +629,8 @@ static void taihu_405ep_init(MachineState *machine)
initrd_size = load_image_targphys(initrd_filename, initrd_base, initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base); ram_size - initrd_base);
if (initrd_size < 0) { if (initrd_size < 0) {
fprintf(stderr, error_report("could not load initial ram disk '%s'",
"qemu: could not load initial ram disk '%s'\n", initrd_filename);
initrd_filename);
exit(1); exit(1);
} }
} else { } else {

View File

@ -12,6 +12,7 @@
*/ */
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "net/net.h" #include "net/net.h"
@ -188,8 +189,8 @@ static void bamboo_init(MachineState *machine)
env = &cpu->env; env = &cpu->env;
if (env->mmu_model != POWERPC_MMU_BOOKE) { if (env->mmu_model != POWERPC_MMU_BOOKE) {
fprintf(stderr, "MMU model %i not supported by this machine.\n", error_report("MMU model %i not supported by this machine",
env->mmu_model); env->mmu_model);
exit(1); exit(1);
} }
@ -229,7 +230,7 @@ static void bamboo_init(MachineState *machine)
NULL); NULL);
pcibus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); pcibus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (!pcibus) { if (!pcibus) {
fprintf(stderr, "couldn't create PCI controller!\n"); error_report("couldn't create PCI controller");
exit(1); exit(1);
} }
@ -270,8 +271,7 @@ static void bamboo_init(MachineState *machine)
} }
/* XXX try again as binary */ /* XXX try again as binary */
if (success < 0) { if (success < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n", error_report("could not load kernel '%s'", kernel_filename);
kernel_filename);
exit(1); exit(1);
} }
} }
@ -282,8 +282,8 @@ static void bamboo_init(MachineState *machine)
ram_size - RAMDISK_ADDR); ram_size - RAMDISK_ADDR);
if (initrd_size < 0) { if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load ram disk '%s' at %x\n", error_report("could not load ram disk '%s' at %x",
initrd_filename, RAMDISK_ADDR); initrd_filename, RAMDISK_ADDR);
exit(1); exit(1);
} }
} }
@ -292,7 +292,7 @@ static void bamboo_init(MachineState *machine)
if (kernel_filename) { if (kernel_filename) {
if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR, if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR,
initrd_size, kernel_cmdline) < 0) { initrd_size, kernel_cmdline) < 0) {
fprintf(stderr, "couldn't load device tree\n"); error_report("couldn't load device tree");
exit(1); exit(1);
} }
} }

View File

@ -574,7 +574,7 @@ static void ppc_prep_init(MachineState *machine)
} }
} }
if (ppc_boot_device == '\0') { if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for Mac99 machine\n"); error_report("No valid boot device for Mac99 machine");
exit(1); exit(1);
} }
} }
@ -595,7 +595,7 @@ static void ppc_prep_init(MachineState *machine)
qdev_init_nofail(dev); qdev_init_nofail(dev);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (pci_bus == NULL) { if (pci_bus == NULL) {
fprintf(stderr, "Couldn't create PCI host controller.\n"); error_report("Couldn't create PCI host controller");
exit(1); exit(1);
} }
sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0); sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0);

View File

@ -223,8 +223,8 @@ static void virtex_init(MachineState *machine)
env = &cpu->env; env = &cpu->env;
if (env->mmu_model != POWERPC_MMU_BOOKE) { if (env->mmu_model != POWERPC_MMU_BOOKE) {
fprintf(stderr, "MMU model %i not supported by this machine.\n", error_report("MMU model %i not supported by this machine",
env->mmu_model); env->mmu_model);
exit(1); exit(1);
} }