[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 2/9] hw/{arm,ppc}: Resolve unreachable code
From: |
Bernhard Beschow |
Subject: |
Re: [PATCH v3 2/9] hw/{arm,ppc}: Resolve unreachable code |
Date: |
Mon, 17 Oct 2022 21:48:41 +0000 |
Am 17. Oktober 2022 20:57:06 UTC schrieb "Philippe Mathieu-Daudé"
<philmd@linaro.org>:
>On 16/10/22 14:27, Bernhard Beschow wrote:
>> pflash_cfi01_register() always returns with a non-NULL pointer (otherwise
>> it would crash internally). Therefore, the bodies of the if-statements
>> are unreachable.
>
>This is true, pflash_cfi0X_register() use an hardcoded &error_fatal.
>
>Shouldn't it be better to pass an Error* argument?
You mean that the callers would pass &error_fatal instead, including the ones
in this patch?
>
>From the pflash API perspective I don't see much value in
>returning a PFlashCFI0X type instead of a simple DeviceState
>(but this is another story...).
It comes in handy in the following patches when retrieving the memory region
for memory_region_add_subregion() using pflash_cfi0X_get_memory(). What do you
think about these next patches?
Furthermore, returning PFlashCFI0X can be downcasted which seems safer than
upcasting from DeviceState.
Best regards,
Bernhard
>
>> 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(-)
- [PATCH v3 0/9] ppc/e500: Add support for two types of flash, cleanup, Bernhard Beschow, 2022/10/16
- [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
- [PATCH v3 2/9] hw/{arm,ppc}: Resolve unreachable code, Bernhard Beschow, 2022/10/16
- [PATCH v3 3/9] hw/block/pflash_cfi01: Attach memory region in boards, Bernhard Beschow, 2022/10/16
- [PATCH v3 4/9] hw/block/pflash_cfi02: Attach memory region in boards, Bernhard Beschow, 2022/10/16
- [PATCH v3 5/9] hw/sd/sdhci-internal: Unexport ESDHC defines, Bernhard Beschow, 2022/10/16
- [PATCH v3 6/9] hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*, Bernhard Beschow, 2022/10/16
- [PATCH v3 8/9] hw/sd/sdhci: Implement Freescale eSDHC device model, Bernhard Beschow, 2022/10/16
- [PATCH v3 9/9] hw/ppc/e500: Add Freescale eSDHC to e500plat, Bernhard Beschow, 2022/10/16
- [PATCH v3 7/9] hw/ppc/e500: Implement pflash handling, Bernhard Beschow, 2022/10/16