From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-arm@nongnu.org, "Alistair Francis" <alistair@alistair23.me>,
"Jan Kiszka" <jan.kiszka@web.de>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Kevin Wolf" <kwolf@redhat.com>,
qemu-block@nongnu.org, "Bin Meng" <bin.meng@windriver.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
qemu-ppc@nongnu.org, "BALATON Zoltan" <balaton@eik.bme.hu>,
"Yoshinori Sato" <ysato@users.sourceforge.jp>,
"Antony Pavlov" <antonynpavlov@gmail.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Bernhard Beschow" <shentey@gmail.com>
Subject: [PATCH v3 2/9] hw/{arm,ppc}: Resolve unreachable code
Date: Sun, 16 Oct 2022 14:27:30 +0200 [thread overview]
Message-ID: <20221016122737.93755-3-shentey@gmail.com> (raw)
In-Reply-To: <20221016122737.93755-1-shentey@gmail.com>
pflash_cfi01_register() always returns with a non-NULL pointer (otherwise
it would crash internally). Therefore, the bodies of the if-statements
are unreachable.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/arm/gumstix.c | 18 ++++++------------
hw/arm/mainstone.c | 13 +++++--------
hw/arm/omap_sx1.c | 22 ++++++++--------------
hw/arm/versatilepb.c | 6 ++----
hw/arm/z2.c | 9 +++------
hw/ppc/sam460ex.c | 12 ++++--------
6 files changed, 28 insertions(+), 52 deletions(-)
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 3a4bc332c4..1296628ed9 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -65,12 +65,9 @@ static void connex_init(MachineState *machine)
exit(1);
}
- if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- sector_len, 2, 0, 0, 0, 0, 0)) {
- error_report("Error registering flash memory");
- exit(1);
- }
+ pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+ sector_len, 2, 0, 0, 0, 0, 0);
/* Interrupt line of NIC is connected to GPIO line 36 */
smc91c111_init(&nd_table[0], 0x04000300,
@@ -95,12 +92,9 @@ static void verdex_init(MachineState *machine)
exit(1);
}
- if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- sector_len, 2, 0, 0, 0, 0, 0)) {
- error_report("Error registering flash memory");
- exit(1);
- }
+ pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+ sector_len, 2, 0, 0, 0, 0, 0);
/* Interrupt line of NIC is connected to GPIO line 99 */
smc91c111_init(&nd_table[0], 0x04000300,
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index 8454b65458..40f708f2d3 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -130,14 +130,11 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
/* There are two 32MiB flash devices on the board */
for (i = 0; i < 2; i ++) {
dinfo = drive_get(IF_PFLASH, 0, i);
- if (!pflash_cfi01_register(mainstone_flash_base[i],
- i ? "mainstone.flash1" : "mainstone.flash0",
- MAINSTONE_FLASH,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- sector_len, 4, 0, 0, 0, 0, 0)) {
- error_report("Error registering flash memory");
- exit(1);
- }
+ pflash_cfi01_register(mainstone_flash_base[i],
+ i ? "mainstone.flash1" : "mainstone.flash0",
+ MAINSTONE_FLASH,
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+ sector_len, 4, 0, 0, 0, 0, 0);
}
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index 57829b3744..820652265b 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -153,13 +153,10 @@ static void sx1_init(MachineState *machine, const int version)
fl_idx = 0;
if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
- if (!pflash_cfi01_register(OMAP_CS0_BASE,
- "omap_sx1.flash0-1", flash_size,
- blk_by_legacy_dinfo(dinfo),
- sector_size, 4, 0, 0, 0, 0, 0)) {
- fprintf(stderr, "qemu: Error registering flash memory %d.\n",
- fl_idx);
- }
+ pflash_cfi01_register(OMAP_CS0_BASE,
+ "omap_sx1.flash0-1", flash_size,
+ blk_by_legacy_dinfo(dinfo),
+ sector_size, 4, 0, 0, 0, 0, 0);
fl_idx++;
}
@@ -175,13 +172,10 @@ static void sx1_init(MachineState *machine, const int version)
memory_region_add_subregion(address_space,
OMAP_CS1_BASE + flash1_size, &cs[1]);
- if (!pflash_cfi01_register(OMAP_CS1_BASE,
- "omap_sx1.flash1-1", flash1_size,
- blk_by_legacy_dinfo(dinfo),
- sector_size, 4, 0, 0, 0, 0, 0)) {
- fprintf(stderr, "qemu: Error registering flash memory %d.\n",
- fl_idx);
- }
+ pflash_cfi01_register(OMAP_CS1_BASE,
+ "omap_sx1.flash1-1", flash1_size,
+ blk_by_legacy_dinfo(dinfo),
+ sector_size, 4, 0, 0, 0, 0, 0);
fl_idx++;
} else {
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index ecc1f6cf74..43172d72ea 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -385,13 +385,11 @@ static void versatile_init(MachineState *machine, int board_id)
/* 0x34000000 NOR Flash */
dinfo = drive_get(IF_PFLASH, 0, 0);
- if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
+ pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
VERSATILE_FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
VERSATILE_FLASH_SECT_SIZE,
- 4, 0x0089, 0x0018, 0x0000, 0x0, 0)) {
- fprintf(stderr, "qemu: Error registering flash memory.\n");
- }
+ 4, 0x0089, 0x0018, 0x0000, 0x0, 0);
versatile_binfo.ram_size = machine->ram_size;
versatile_binfo.board_id = board_id;
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 9c1e876207..082ccc557e 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -311,12 +311,9 @@ static void z2_init(MachineState *machine)
mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, machine->cpu_type);
dinfo = drive_get(IF_PFLASH, 0, 0);
- if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- sector_len, 4, 0, 0, 0, 0, 0)) {
- error_report("Error registering flash memory");
- exit(1);
- }
+ pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+ sector_len, 4, 0, 0, 0, 0, 0);
/* setup keypad */
pxa27x_register_keypad(mpu->kp, map, 0x100);
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 850bb3b817..8089dd015b 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -111,14 +111,10 @@ static int sam460ex_load_uboot(void)
DriveInfo *dinfo;
dinfo = drive_get(IF_PFLASH, 0, 0);
- if (!pflash_cfi01_register(FLASH_BASE | ((hwaddr)FLASH_BASE_H << 32),
- "sam460ex.flash", FLASH_SIZE,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1)) {
- error_report("Error registering flash memory");
- /* XXX: return an error instead? */
- exit(1);
- }
+ pflash_cfi01_register(FLASH_BASE | ((hwaddr)FLASH_BASE_H << 32),
+ "sam460ex.flash", FLASH_SIZE,
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+ 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1);
if (!dinfo) {
/*error_report("No flash image given with the 'pflash' parameter,"
--
2.38.0
next prev parent reply other threads:[~2022-10-16 12:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-16 12:27 [PATCH v3 0/9] ppc/e500: Add support for two types of flash, cleanup Bernhard Beschow
2022-10-16 12:27 ` [PATCH v3 1/9] hw/block/pflash_cfi0{1, 2}: Error out if device length isn't a power of two Bernhard Beschow
2022-10-16 12:27 ` Bernhard Beschow [this message]
2022-10-17 20:57 ` [PATCH v3 2/9] hw/{arm,ppc}: Resolve unreachable code Philippe Mathieu-Daudé
2022-10-17 21:48 ` Bernhard Beschow
2022-10-18 9:25 ` Peter Maydell
2022-10-16 12:27 ` [PATCH v3 3/9] hw/block/pflash_cfi01: Attach memory region in boards Bernhard Beschow
2022-10-16 12:27 ` [PATCH v3 4/9] hw/block/pflash_cfi02: " Bernhard Beschow
2022-10-16 12:27 ` [PATCH v3 5/9] hw/sd/sdhci-internal: Unexport ESDHC defines Bernhard Beschow
2022-10-16 12:27 ` [PATCH v3 6/9] hw/sd/sdhci: Rename ESDHC_* defines to USDHC_* Bernhard Beschow
2022-10-16 12:27 ` [PATCH v3 7/9] hw/ppc/e500: Implement pflash handling Bernhard Beschow
2022-10-16 14:15 ` BALATON Zoltan
2022-10-18 7:45 ` Bernhard Beschow
2022-10-18 7:48 ` Bin Meng
2022-10-18 11:13 ` BALATON Zoltan
2022-10-18 9:28 ` Peter Maydell
2022-10-16 12:27 ` [PATCH v3 8/9] hw/sd/sdhci: Implement Freescale eSDHC device model Bernhard Beschow
2022-10-16 12:27 ` [PATCH v3 9/9] hw/ppc/e500: Add Freescale eSDHC to e500plat Bernhard Beschow
2022-10-16 12:41 ` [PATCH v3 0/9] ppc/e500: Add support for two types of flash, cleanup Bernhard Beschow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221016122737.93755-3-shentey@gmail.com \
--to=shentey@gmail.com \
--cc=alistair@alistair23.me \
--cc=antonynpavlov@gmail.com \
--cc=aurelien@aurel32.net \
--cc=balaton@eik.bme.hu \
--cc=bin.meng@windriver.com \
--cc=edgar.iglesias@gmail.com \
--cc=f4bug@amsat.org \
--cc=hreitz@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kwolf@redhat.com \
--cc=magnus.damm@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=ysato@users.sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).