hw/arm: 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 where then manually tweaked to pass checkpatch.

The 'qemu: ' prefix was manually removed from the hw/arm/boot.c file.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-arm@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: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-3-armbru@redhat.com>
This commit is contained in:
Alistair Francis 2018-02-03 09:43:03 +01:00 committed by Markus Armbruster
parent 470bcabd8f
commit c0dbca36dc
11 changed files with 38 additions and 33 deletions

View file

@ -278,7 +278,7 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size)
#endif
if (!kernel_filename && !qtest_enabled()) {
fprintf(stderr, "Guest image must be specified (using -kernel)\n");
error_report("Guest image must be specified (using -kernel)");
exit(1);
}

View file

@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include <libfdt.h>
#include "hw/hw.h"
@ -690,7 +691,7 @@ static void load_image_to_fw_cfg(FWCfgState *fw_cfg, uint16_t size_key,
gsize length;
if (!g_file_get_contents(image_name, &contents, &length, NULL)) {
fprintf(stderr, "failed to load \"%s\"\n", image_name);
error_report("failed to load \"%s\"", image_name);
exit(1);
}
size = length;
@ -956,8 +957,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
is_linux = 1;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
info->kernel_filename);
error_report("could not load kernel '%s'", info->kernel_filename);
exit(1);
}
info->entry = entry;
@ -976,8 +976,8 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
info->initrd_start);
}
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initrd '%s'\n",
info->initrd_filename);
error_report("could not load initrd '%s'",
info->initrd_filename);
exit(1);
}
} else {
@ -1021,9 +1021,9 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
} else {
fixupcontext[FIXUP_ARGPTR] = info->loader_start + KERNEL_ARGS_ADDR;
if (info->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
" Linux kernel using ATAGS (try passing a device tree"
" using -dtb)\n");
error_report("RAM size must be less than 4GB to boot"
" Linux kernel using ATAGS (try passing a device tree"
" using -dtb)");
exit(1);
}
}

View file

@ -35,6 +35,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
#include "net/net.h"
@ -62,8 +63,8 @@ static void connex_init(MachineState *machine)
dinfo = drive_get(IF_PFLASH, 0, 0);
if (!dinfo && !qtest_enabled()) {
fprintf(stderr, "A flash image must be given with the "
"'pflash' parameter\n");
error_report("A flash image must be given with the "
"'pflash' parameter");
exit(1);
}
@ -76,7 +77,7 @@ static void connex_init(MachineState *machine)
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
sector_len, connex_rom / sector_len,
2, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
error_report("Error registering flash memory");
exit(1);
}
@ -99,8 +100,8 @@ static void verdex_init(MachineState *machine)
dinfo = drive_get(IF_PFLASH, 0, 0);
if (!dinfo && !qtest_enabled()) {
fprintf(stderr, "A flash image must be given with the "
"'pflash' parameter\n");
error_report("A flash image must be given with the "
"'pflash' parameter");
exit(1);
}
@ -113,7 +114,7 @@ static void verdex_init(MachineState *machine)
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
sector_len, verdex_rom / sector_len,
2, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
error_report("Error registering flash memory");
exit(1);
}

View file

@ -12,6 +12,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
@ -143,8 +144,8 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
if (qtest_enabled()) {
break;
}
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
error_report("Two flash images must be given with the "
"'pflash' parameter");
exit(1);
}
@ -154,7 +155,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
blk_by_legacy_dinfo(dinfo),
sector_len, MAINSTONE_FLASH / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
error_report("Error registering flash memory");
exit(1);
}
}

View file

@ -1627,7 +1627,7 @@ static void musicpal_init(MachineState *machine)
flash_size = blk_getlength(blk);
if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
flash_size != 32*1024*1024) {
fprintf(stderr, "Invalid flash image size\n");
error_report("Invalid flash image size");
exit(1);
}

View file

@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@ -2313,7 +2314,7 @@ void omap_uwire_attach(struct omap_uwire_s *s,
uWireSlave *slave, int chipselect)
{
if (chipselect < 0 || chipselect > 3) {
fprintf(stderr, "%s: Bad chipselect %i\n", __func__, chipselect);
error_report("%s: Bad chipselect %i", __func__, chipselect);
exit(-1);
}
@ -3987,7 +3988,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
dinfo = drive_get(IF_SD, 0, 0);
if (!dinfo) {
fprintf(stderr, "qemu: missing SecureDigital device\n");
error_report("missing SecureDigital device");
exit(1);
}
s->mmc = omap_mmc_init(0xfffb7800, system_memory,

View file

@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@ -2486,7 +2487,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
dinfo = drive_get(IF_SD, 0, 0);
if (!dinfo) {
fprintf(stderr, "qemu: missing SecureDigital device\n");
error_report("missing SecureDigital device");
exit(1);
}
s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9),

View file

@ -194,7 +194,7 @@ static void sx1_init(MachineState *machine, const int version)
}
if (!machine->kernel_filename && !fl_idx && !qtest_enabled()) {
fprintf(stderr, "Kernel or Flash image must be specified\n");
error_report("Kernel or Flash image must be specified");
exit(1);
}

View file

@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@ -2062,7 +2063,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
s = g_new0(PXA2xxState, 1);
if (strncmp(cpu_type, "pxa27", 5)) {
fprintf(stderr, "Machine requires a PXA27x processor.\n");
error_report("Machine requires a PXA27x processor");
exit(1);
}
@ -2095,7 +2096,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
dinfo = drive_get(IF_SD, 0, 0);
if (!dinfo) {
fprintf(stderr, "qemu: missing SecureDigital device\n");
error_report("missing SecureDigital device");
exit(1);
}
s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
@ -2220,7 +2221,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
dinfo = drive_get(IF_SD, 0, 0);
if (!dinfo) {
fprintf(stderr, "qemu: missing SecureDigital device\n");
error_report("missing SecureDigital device");
exit(1);
}
s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,

View file

@ -266,7 +266,7 @@ static void a9_daughterboard_init(const VexpressMachineState *vms,
if (ram_size > 0x40000000) {
/* 1GB is the maximum the address space permits */
fprintf(stderr, "vexpress-a9: cannot model more than 1GB RAM\n");
error_report("vexpress-a9: cannot model more than 1GB RAM");
exit(1);
}
@ -355,7 +355,7 @@ static void a15_daughterboard_init(const VexpressMachineState *vms,
*/
uint64_t rsz = ram_size;
if (rsz > (30ULL * 1024 * 1024 * 1024)) {
fprintf(stderr, "vexpress-a15: cannot model more than 30GB RAM\n");
error_report("vexpress-a15: cannot model more than 30GB RAM");
exit(1);
}
}
@ -640,7 +640,7 @@ static void vexpress_common_init(MachineState *machine)
pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0",
dinfo);
if (!pflash0) {
fprintf(stderr, "vexpress: error registering flash 0.\n");
error_report("vexpress: error registering flash 0");
exit(1);
}
@ -655,7 +655,7 @@ static void vexpress_common_init(MachineState *machine)
dinfo = drive_get_next(IF_PFLASH);
if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1",
dinfo)) {
fprintf(stderr, "vexpress: error registering flash 1.\n");
error_report("vexpress: error registering flash 1");
exit(1);
}

View file

@ -320,8 +320,8 @@ static void z2_init(MachineState *machine)
#endif
dinfo = drive_get(IF_PFLASH, 0, 0);
if (!dinfo && !qtest_enabled()) {
fprintf(stderr, "Flash image must be given with the "
"'pflash' parameter\n");
error_report("Flash image must be given with the "
"'pflash' parameter");
exit(1);
}
@ -330,7 +330,7 @@ static void z2_init(MachineState *machine)
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
sector_len, Z2_FLASH_SIZE / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
error_report("Error registering flash memory");
exit(1);
}