various: Fix error-propagation with Coccinelle scripts (part 2)
Subsystems (10)
v3 cover various: Fix error-propagation with Coccinelle scripts (part 2)
This series is inspired of Peter Maydell fix [1]:
"hw/arm/xlnx-zynqmp.c: fix some error-handling code", but grew after v1 [2] review :/
Markus: I added the cocci patches to your Error section, I hope that's fine :)
Part 2: Add missing error_propagate() calls in DeviceClass::realize().
Regards,
Phil.
[1] https://www.mail-archive.com/[email protected]/msg691636.html
[2] https://www.mail-archive.com/[email protected]/msg692155.html
Based-on: <[email protected]>
Philippe Mathieu-Daudé (23):
scripts/coccinelle: Catch missing error_propagate() calls in realize() hw/arm/fsl-imx: Add missing error-propagation code hw/arm/stm32f*05_soc: Add missing error-propagation code hw/arm/aspeed: Add missing error-propagation code hw/arm/allwinner-a10: Add missing error-propagation code hw/arm/msf2-soc: Add missing error-propagation code hw/riscv/sifive: Add missing error-propagation code hw/arm/armv7m: Add missing error-propagation code hw/intc/arm_gicv3_its_kvm: Add missing error-propagation code hw/microblaze/xlnx-zynqmp-pmu: Add missing error-propagation code hw/pci-host/pnv_phb3: Add missing error-propagation code hw/block/onenand: Add missing error-propagation code scripts/coccinelle: Add script to catch missing error_propagate()
calls
hw/arm/bcm2835_peripherals: Add missing error-propagation code hw/arm/fsl-imx: Add missing error-propagation code hw/arm/stm32fx05_soc: Add missing error-propagation code hw/dma/xilinx_axidma: Add missing error-propagation code hw/i386/x86: Add missing error-propagation code hw/mips/cps: Add missing error-propagation code hw/misc/macio/macio: Add missing error-propagation code hw/net/xilinx_axienet: Add missing error-propagation code hw/riscv/sifive_u: Add missing error-propagation code hw/sd/milkymist-memcard: Add missing error-propagation code
.../add-missing-error_propagate.cocci | 30 +++++++++++ .../use-error_propagate-in-realize.cocci | 54 +++++++++++++++++++ hw/arm/allwinner-a10.c | 18 +++++-- hw/arm/armv7m.c | 12 ++++- hw/arm/aspeed_ast2600.c | 36 ++++++++++--- hw/arm/aspeed_soc.c | 12 ++++- hw/arm/bcm2835_peripherals.c | 8 +++ hw/arm/fsl-imx25.c | 14 ++++- hw/arm/fsl-imx6.c | 26 +++++++-- hw/arm/msf2-soc.c | 24 +++++++-- hw/arm/stm32f205_soc.c | 10 +++- hw/arm/stm32f405_soc.c | 10 +++- hw/block/onenand.c | 6 ++- hw/dma/xilinx_axidma.c | 6 +++ hw/i386/x86.c | 4 ++ hw/intc/arm_gicv3_its_kvm.c | 6 ++- hw/microblaze/xlnx-zynqmp-pmu.c | 6 ++- hw/mips/cps.c | 48 +++++++++++++++++ hw/misc/macio/macio.c | 4 ++ hw/net/xilinx_axienet.c | 6 +++ hw/pci-host/pnv_phb3.c | 24 +++++++-- hw/riscv/sifive_e.c | 6 ++- hw/riscv/sifive_u.c | 32 +++++++++-- hw/sd/milkymist-memcard.c | 4 ++ MAINTAINERS | 2 + 25 files changed, 373 insertions(+), 35 deletions(-) create mode 100644 scripts/coccinelle/add-missing-error_propagate.cocci create mode 100644 scripts/coccinelle/use-error_propagate-in-realize.cocci
Signature · 1 line
2.21.1
PATCH v3 1/23 scripts/coccinelle: Catch missing error_propagate() calls in realize()
In some DeviceClass::realize() while we can propagate errors to the caller, we forgot to do so. Add a Coccinelle patch to automatically add the missing code.
--- .../use-error_propagate-in-realize.cocci | 54 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 55 insertions(+) create mode 100644 scripts/coccinelle/use-error_propagate-in-realize.cocci
scripts/coccinelle/use-error_propagate-in-realize.cocci new file +54 -0
@@ -0,0 +1,54 @@ +// Add missing error-propagation code in DeviceClass::realize() +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h --include-headers \ +// --sp-file scripts/coccinelle/use-error_abort-in-instance_init.cocci \ +// --keep-comments --timeout 60 --in-place +// +// Inspired by https://www.mail-archive.com/[email protected]/msg691638.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_realize @ +identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +} + + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp; +symbol error_abort, error_fatal; +@@ +void realizefn(..., Error **errp) +{ + ... + Error *err = NULL; + <+... + func_with_errp(..., +- \(&error_abort\|&error_fatal\)); ++ &err); ++ if (err) { ++ error_propagate(errp, err); ++ return; ++ } + ...+> +}
MAINTAINERS +1 -0
@@ -2060,6 +2060,7 @@ F: scripts/coccinelle/error_propagate_null.cocci F: scripts/coccinelle/remove_local_err.cocci F: scripts/coccinelle/simplify-init-realize-error_propagate.cocci F: scripts/coccinelle/use-error_fatal.cocci +F: scripts/coccinelle/use-error_propagate-in-realize.cocci GDB stub M: Alex Bennée <[email protected]>
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
Quoted 59 lines · Philippe Mathieu-Daudé
In some
DeviceClass::realize()while we can propagate errors to the caller, we forgot to do so. Add a Coccinelle patch to automatically add the missing code.Inspired-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- .../use-error_propagate-in-realize.cocci | 54 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 55 insertions(+) create mode 100644 scripts/coccinelle/use-error_propagate-in-realize.cocciscripts/coccinelle/use-error_propagate-in-realize.cocci new file +41
-0@@ -0,0 +1,54 @@ +// Add missing error-propagation code in DeviceClass::realize() +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h --include-headers \ +// --sp-file scripts/coccinelle/use-error_abort-in-instance_init.cocci \ +// --keep-comments --timeout 60 --in-place +// +// Inspired by https://www.mail-archive.com/[email protected]/msg691638.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_realize @ +identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +} + + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp; +symbol error_abort, error_fatal; +@@ +void realizefn(..., Error **errp)
scripts/coccinelle/use-error_propagate-in-realize.cocci line 51
Quoted 10 lines
scripts/coccinelle/use-error_propagate-in-realize.cocci new file +10
-0+{ + ... + Error *err = NULL; + <+... + func_with_errp(..., +- \(&error_abort\|&error_fatal\)); ++ &err); ++ if (err) { ++ error_propagate(errp, err); ++ return;
Issues:
0. The script patches only realize() methods of DeviceClass, not of subclasses, and no helpers.
Example of a subclass method: see my review of "[PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation".
Example of a helper method: pnv_chip_core_realize().
1. When the function can't actually fail, the script adds dead error handling.
2. When the function can fail, it may well add incomplete error
handling: it can't add the code needed to revert what has been done so far.
Example: ivshmem_common_realize() has:
error_setg(&s->migration_blocker,
"Migration is disabled when using feature 'peer mode' in device 'ivshmem'");
migrate_add_blocker(s->migration_blocker, &err);
if (err) {
error_propagate(errp, err);
error_free(s->migration_blocker);
return;
} If the error handling was missing, the script would fail to add the error_free().
Even imperfect scripts can lead us to code in need of improvement. But you should explain the script's limitations, both in the script and the commit message.
Quoted 15 lines
scripts/coccinelle/use-error_propagate-in-realize.cocci new file +3
-0++ } + ...+> +}MAINTAINERS +1
-0@@ -2060,6 +2060,7 @@ F: scripts/coccinelle/error_propagate_null.cocci F: scripts/coccinelle/remove_local_err.cocci F: scripts/coccinelle/simplify-init-realize-error_propagate.cocci F: scripts/coccinelle/use-error_fatal.cocci +F: scripts/coccinelle/use-error_propagate-in-realize.cocci GDB stub M: Alex Bennée <[email protected]>
Re: [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
Quoted 74 lines · Markus Armbruster
Quoted 59 lines · Philippe Mathieu-Daudé
In some
DeviceClass::realize()while we can propagate errors to the caller, we forgot to do so. Add a Coccinelle patch to automatically add the missing code.Inspired-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- .../use-error_propagate-in-realize.cocci | 54 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 55 insertions(+) create mode 100644 scripts/coccinelle/use-error_propagate-in-realize.cocciscripts/coccinelle/use-error_propagate-in-realize.cocci new file +41
-0@@ -0,0 +1,54 @@ +// Add missing error-propagation code in DeviceClass::realize() +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h --include-headers \ +// --sp-file scripts/coccinelle/use-error_abort-in-instance_init.cocci \ +// --keep-comments --timeout 60 --in-place +// +// Inspired by https://www.mail-archive.com/[email protected]/msg691638.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_realize @ +identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +} + + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp; +symbol error_abort, error_fatal; +@@ +void realizefn(..., Error **errp)scripts/coccinelle/use-error_propagate-in-realize.cocci line 51
Quoted 10 lines
scripts/coccinelle/use-error_propagate-in-realize.cocci new file +10
-0+{ + ... + Error *err = NULL; + <+... + func_with_errp(..., +- \(&error_abort\|&error_fatal\)); ++ &err); ++ if (err) { ++ error_propagate(errp, err); ++ return;Issues:
Quoted 8 lines
0. The script patches only
realize()methods of DeviceClass, not of subclasses, and no helpers.Example of a subclass method: see my review of "[PATCH-for-5.1 v3 02/24]
scripts/coccinelle: Script to simplify DeviceClass error propagation".Example of a helper method:
pnv_chip_core_realize().
One more:
* The script doesn't patch calls that pass NULL for errp. The ones that can't fail should pass &error_abort instad. The ones that can fail commonly need to error_propagate(). There may be exceptions, though.
Quoted 3 lines
1. When the function can't actually fail, the script adds dead error handling.
&error_abort is not wrong in such cases.
&error_fatal is always wrong in realize().
Quoted 21 lines
2. When the function can fail, it may well add incomplete error
handling: it can't add the code needed to revert what has been done so far.Example: ivshmem_common_realize() has: error_setg(&s->migration_blocker, "Migration is disabled when using feature 'peer mode' in device 'ivshmem'"); migrate_add_blocker(s->migration_blocker, &err); if (err) { error_propagate(errp, err); error_free(s->migration_blocker); return; } If the error handling was missing, the script would fail to add the error_free().Even imperfect scripts can lead us to code in need of improvement. But you should explain the script's limitations, both in the script and the commit message.
PATCH v3 2/23 hw/arm/fsl-imx: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/fsl-imx25.c | 6 +++++- hw/arm/fsl-imx6.c | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-)
hw/arm/fsl-imx25.c +5 -1
@@ -295,7 +295,11 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) };object_property_set_bool (OBJECT (&s->usb[i]), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->usb[i]),0 , usb_table[i].addr); sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, qdev_get_gpio_in(DEVICE(&s->avic),
hw/arm/fsl-imx6.c +15 -3
@@ -359,7 +359,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)/* USB */ for (i =0 ; i <FSL_IMX6_NUM_USB_PHYS ; i++) {object_property_set_bool (OBJECT (&s->usbphy[i]), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->usbphy[i]),0 ,FSL_IMX6_USBPHY1_ADDR + i *0x1000 ); }
@@ -372,7 +376,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) };object_property_set_bool (OBJECT (&s->usb[i]), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->usb[i]),0 ,FSL_IMX6_USBOH3_USB_ADDR + i *0x200 ); sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0,
@@ -430,7 +438,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) };object_property_set_bool (OBJECT (&s->wdt[i]), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[i]),0 , FSL_IMX6_WDOGn_ADDR[i]); }
Signature · 1 line
2.21.1
PATCH v3 3/23 hw/arm/stm32f*05_soc: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/stm32f205_soc.c | 6 +++++- hw/arm/stm32f405_soc.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
hw/arm/stm32f205_soc.c +5 -1
@@ -106,7 +106,11 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)qdev_prop_set_string (armv7m,"cpu-type" , s->cpu_type);qdev_prop_set_bit (armv7m,"enable-bitband" , true);object_property_set_link (OBJECT (&s->armv7m),OBJECT (get_system_memory ()), -"memory" , &error_abort); +"memory" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->armv7m), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
hw/arm/stm32f405_soc.c +5 -1
@@ -121,7 +121,11 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)qdev_prop_set_string (armv7m,"cpu-type" , s->cpu_type);qdev_prop_set_bit (armv7m,"enable-bitband" , true);object_property_set_link (OBJECT (&s->armv7m),OBJECT (system_memory), -"memory" , &error_abort); +"memory" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->armv7m), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
Signature · 1 line
2.21.1
PATCH v3 4/23 hw/arm/aspeed: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/aspeed_ast2600.c | 36 ++++++++++++++++++++++++++++++------ hw/arm/aspeed_soc.c | 12 ++++++++++-- 2 files changed, 40 insertions(+), 8 deletions(-)
hw/arm/aspeed_ast2600.c +30 -6
@@ -277,7 +277,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)if (s->num_cpus >1 ) {object_property_set_int (OBJECT (&s->cpu[i]),ASPEED_A7MPCORE_ADDR , -"reset-cbar" , &error_abort); +"reset-cbar" , &err); +if (err) { +error_propagate (errp, err); +return ; + } }/* * TODO: the secondary CPUs are started and a boot helper
@@ -293,10 +297,18 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* A7MPCORE */ object_property_set_int (OBJECT (&s->a7mpcore), s->num_cpus,"num-cpu" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->a7mpcore), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->a7mpcore),0 ,ASPEED_A7MPCORE_ADDR );for (i =0 ; i < s->num_cpus; i++) {
@@ -343,7 +355,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* Timer */ object_property_set_link (OBJECT (&s->timerctrl), -OBJECT (&s->scu),"scu" , &error_abort); +OBJECT (&s->scu),"scu" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->timerctrl), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -459,7 +475,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (&s->wdt[i]);object_property_set_link (OBJECT (&s->wdt[i]), -OBJECT (&s->scu),"scu" , &error_abort); +OBJECT (&s->scu),"scu" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->wdt[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -490,7 +510,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) aspeed_soc_get_irq(s, ASPEED_ETH1 + i));object_property_set_link (OBJECT (&s->mii[i]),OBJECT (&s->ftgmac100[i]), -"nic" , &error_abort); +"nic" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->mii[i]), true,"realized" , &err);if (err) {
hw/arm/aspeed_soc.c +10 -2
@@ -301,7 +301,11 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)/* Timer */ object_property_set_link (OBJECT (&s->timerctrl), -OBJECT (&s->scu),"scu" , &error_abort); +OBJECT (&s->scu),"scu" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->timerctrl), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -398,7 +402,11 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (&s->wdt[i]);object_property_set_link (OBJECT (&s->wdt[i]), -OBJECT (&s->scu),"scu" , &error_abort); +OBJECT (&s->scu),"scu" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->wdt[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
Signature · 1 line
2.21.1
PATCH v3 5/23 hw/arm/allwinner-a10: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/allwinner-a10.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
hw/arm/allwinner-a10.c +15 -3
@@ -158,14 +158,22 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)for (i =0 ; i <AW_A10_NUM_USB ; i++) {object_property_set_bool (OBJECT (&s->ehci[i]), true,"realized" , - &error_fatal); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ehci[i]),0 ,AW_A10_EHCI_BASE + i *0x8000 );sysbus_connect_irq (SYS_BUS_DEVICE (&s->ehci[i]),0 ,qdev_get_gpio_in (dev,39 + i));object_property_set_bool (OBJECT (&s->ohci[i]), true,"realized" , - &error_fatal); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ohci[i]),0 ,AW_A10_OHCI_BASE + i *0x8000 ); sysbus_connect_irq(SYS_BUS_DEVICE(&s->ohci[i]), 0,
@@ -178,7 +186,11 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->mmc0),0 ,AW_A10_MMC0_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->mmc0),0 ,qdev_get_gpio_in (dev,32 ));object_property_add_alias (OBJECT (s),"sd-bus" ,OBJECT (&s->mmc0), -"sd-bus" , &error_abort); +"sd-bus" , &err); +if (err) { +error_propagate (errp, err); +return ; + }/* RTC */ qdev_init_nofail (DEVICE (&s->rtc));
Signature · 1 line
2.21.1
PATCH v3 6/23 hw/arm/msf2-soc: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/msf2-soc.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
hw/arm/msf2-soc.c +20 -4
@@ -93,7 +93,11 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)MemoryRegion *system_memory =get_system_memory ();memory_region_init_rom (&s->nvm,OBJECT (dev_soc),"MSF2.eNVM" , s->envm_size, - &error_fatal); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* * On power-on, the eNVM region 0x60000000 is automatically * remapped to the Cortex-M3 processor executable region
@@ -107,7 +111,11 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)memory_region_add_subregion (system_memory,0 , &s->nvm_alias);memory_region_init_ram (&s->sram,NULL ,"MSF2.eSRAM" , s->esram_size, - &error_fatal); + &err); +if (err) { +error_propagate (errp, err); +return ; + }memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); armv7m =DEVICE (&s->armv7m);
@@ -115,7 +123,11 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)qdev_prop_set_string (armv7m,"cpu-type" , s->cpu_type);qdev_prop_set_bit (armv7m,"enable-bitband" , true);object_property_set_link (OBJECT (&s->armv7m),OBJECT (get_system_memory ()), -"memory" , &error_abort); +"memory" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->armv7m), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
@@ -184,8 +196,12 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) bus_name =g_strdup_printf ("spi%d" , i);object_property_add_alias (OBJECT (s), bus_name,OBJECT (&s->spi[i]),"spi" , - &error_abort); + &err);g_free (bus_name); +if (err) { +error_propagate (errp, err); +return ; + } }/* Below devices are not modelled yet. */
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 06/23] hw/arm/msf2-soc: Add missing error-propagation code
Quoted 9 lines · Philippe Mathieu-Daudé
Patch created mechanically by running:
$ spatch \ --macro-file scripts/cocci-macro-file.h --include-headers \ --sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \ --keep-comments --smpl-spacing --in-place --dir hwSigned-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 65 lines
--- hw/arm/msf2-soc.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)hw/arm/msf2-soc.c +20
-5@@ -93,7 +93,11 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)MemoryRegion *system_memory =get_system_memory ();memory_region_init_rom (&s->nvm,OBJECT (dev_soc),"MSF2.eNVM" , s->envm_size, - &error_fatal); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* * On power-on, the eNVM region 0x60000000 is automatically * remapped to the Cortex-M3 processor executable region @@ -107,7 +111,11 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)memory_region_add_subregion (system_memory,0 , &s->nvm_alias);memory_region_init_ram (&s->sram,NULL ,"MSF2.eSRAM" , s->esram_size, - &error_fatal); + &err); +if (err) { +error_propagate (errp, err); +return ; + }memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); armv7m =DEVICE (&s->armv7m);@@ -115,7 +123,11 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)qdev_prop_set_string (armv7m,"cpu-type" , s->cpu_type);qdev_prop_set_bit (armv7m,"enable-bitband" , true);object_property_set_link (OBJECT (&s->armv7m),OBJECT (get_system_memory ()), -"memory" , &error_abort); +"memory" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->armv7m), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);@@ -184,8 +196,12 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) bus_name =g_strdup_printf ("spi%d" , i);object_property_add_alias (OBJECT (s), bus_name,OBJECT (&s->spi[i]),"spi" , - &error_abort); + &err);g_free (bus_name); +if (err) { +error_propagate (errp, err); +return ; + } }/* Below devices are not modelled yet. */ --2.21.1
PATCH v3 7/23 hw/riscv/sifive: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/riscv/sifive_e.c | 6 +++++- hw/riscv/sifive_u.c | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-)
hw/riscv/sifive_e.c +5 -1
@@ -156,7 +156,11 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)MemoryRegion *sys_mem =get_system_memory ();object_property_set_bool (OBJECT (&s->cpus), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* MMIO */ s->plic = sifive_plic_create(memmap[SIFIVE_E_PLIC].base,
hw/riscv/sifive_u.c +20 -4
@@ -508,9 +508,17 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)NICInfo *nd = &nd_table[0 ];object_property_set_bool (OBJECT (&s->e_cpus), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->u_cpus), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* * The cluster must be realized after the RISC-V hart array container, * as the container's CPU object is only created on realize, and the
@@ -518,9 +526,17 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)* cluster is realized. */ object_property_set_bool (OBJECT (&s->e_cluster), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->u_cluster), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* create PLIC hart topology configuration string */ plic_hart_config_len = (strlen(SIFIVE_U_PLIC_HART_CONFIG) + 1) *
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 07/23] hw/riscv/sifive: Add missing error-propagation code
Quoted 9 lines · Philippe Mathieu-Daudé
Patch created mechanically by running:
$ spatch \ --macro-file scripts/cocci-macro-file.h --include-headers \ --sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \ --keep-comments --smpl-spacing --in-place --dir hwSigned-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 70 lines
--- hw/riscv/sifive_e.c | 6 +++++- hw/riscv/sifive_u.c | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-)hw/riscv/sifive_e.c +5
-1@@ -156,7 +156,11 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)MemoryRegion *sys_mem =get_system_memory ();object_property_set_bool (OBJECT (&s->cpus), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* MMIO */ s->plic = sifive_plic_create(memmap[SIFIVE_E_PLIC].base,hw/riscv/sifive_u.c +20
-5@@ -508,9 +508,17 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)NICInfo *nd = &nd_table[0 ];object_property_set_bool (OBJECT (&s->e_cpus), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->u_cpus), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* * The cluster must be realized after the RISC-V hart array container, * as the container's CPU object is only created on realize, and the @@ -518,9 +526,17 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)* cluster is realized. */ object_property_set_bool (OBJECT (&s->e_cluster), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->u_cluster), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }/* create PLIC hart topology configuration string */ plic_hart_config_len = (strlen(SIFIVE_U_PLIC_HART_CONFIG) + 1) * --2.21.1
PATCH v3 8/23 hw/arm/armv7m: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/armv7m.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
hw/arm/armv7m.c +10 -2
@@ -168,7 +168,11 @@ static void armv7m_realize(DeviceState *dev, Error **errp) }object_property_set_link (OBJECT (s->cpu),OBJECT (&s->container),"memory" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }if (object_property_find (OBJECT (s->cpu),"idau" ,NULL )) {object_property_set_link (OBJECT (s->cpu), s->idau,"idau" , &err);if (err !=NULL ) {
@@ -256,7 +260,11 @@ static void armv7m_realize(DeviceState *dev, Error **errp)return ; }object_property_set_link (obj,OBJECT (s->board_memory), -"source-memory" , &error_abort); +"source-memory" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (obj, true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 08/23] hw/arm/armv7m: Add missing error-propagation code
Quoted 9 lines · Philippe Mathieu-Daudé
Patch created mechanically by running:
$ spatch \ --macro-file scripts/cocci-macro-file.h --include-headers \ --sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \ --keep-comments --smpl-spacing --in-place --dir hwSigned-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 38 lines
--- hw/arm/armv7m.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)hw/arm/armv7m.c +10
-3@@ -168,7 +168,11 @@ static void armv7m_realize(DeviceState *dev, Error **errp) }object_property_set_link (OBJECT (s->cpu),OBJECT (&s->container),"memory" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }if (object_property_find (OBJECT (s->cpu),"idau" ,NULL )) {object_property_set_link (OBJECT (s->cpu), s->idau,"idau" , &err);if (err !=NULL ) {@@ -256,7 +260,11 @@ static void armv7m_realize(DeviceState *dev, Error **errp)return ; }object_property_set_link (obj,OBJECT (s->board_memory), -"source-memory" , &error_abort); +"source-memory" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (obj, true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err); --2.21.1
PATCH v3 9/23 hw/intc/arm_gicv3_its_kvm: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/intc/arm_gicv3_its_kvm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/intc/arm_gicv3_its_kvm.c +5 -1
@@ -101,7 +101,11 @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp)/* explicit init of the ITS */ kvm_device_access (s->dev_fd,KVM_DEV_ARM_VGIC_GRP_CTRL , -KVM_DEV_ARM_VGIC_CTRL_INIT ,NULL , true, &error_abort); +KVM_DEV_ARM_VGIC_CTRL_INIT ,NULL , true, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }/* register the base address */ kvm_arm_register_device(&s->iomem_its_cntrl, -1, KVM_DEV_ARM_VGIC_GRP_ADDR,
Signature · 1 line
2.21.1
PATCH v3 10/23 hw/microblaze/xlnx-zynqmp-pmu: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/microblaze/xlnx-zynqmp-pmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/microblaze/xlnx-zynqmp-pmu.c +5 -1
@@ -123,7 +123,11 @@ static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp)/* Connect the IPI device */ for (int i =0 ; i <XLNX_ZYNQMP_PMU_NUM_IPIS ; i++) {object_property_set_bool (OBJECT (&s->ipi[i]), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ipi[i]),0 , ipi_addr[i]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->ipi[i]),0 ,qdev_get_gpio_in (DEVICE (&s->intc), ipi_irq[i]));
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 10/23] hw/microblaze/xlnx-zynqmp-pmu: Add missing error-propagation code
Quoted 9 lines · Philippe Mathieu-Daudé
Patch created mechanically by running:
$ spatch \ --macro-file scripts/cocci-macro-file.h --include-headers \ --sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \ --keep-comments --smpl-spacing --in-place --dir hwSigned-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 25 lines
--- hw/microblaze/xlnx-zynqmp-pmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/microblaze/xlnx-zynqmp-pmu.c +5
-2@@ -123,7 +123,11 @@ static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp)/* Connect the IPI device */ for (int i =0 ; i <XLNX_ZYNQMP_PMU_NUM_IPIS ; i++) {object_property_set_bool (OBJECT (&s->ipi[i]), true,"realized" , - &error_abort); + &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ipi[i]),0 , ipi_addr[i]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->ipi[i]),0 ,qdev_get_gpio_in (DEVICE (&s->intc), ipi_irq[i])); --2.21.1
PATCH v3 11/23 hw/pci-host/pnv_phb3: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/pci-host/pnv_phb3.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
hw/pci-host/pnv_phb3.c +20 -4
@@ -1008,7 +1008,11 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* LSI sources */ object_property_set_link (OBJECT (&phb->lsis),OBJECT (pnv),"xics" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_bool (OBJECT (&phb->lsis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
@@ -1023,9 +1027,17 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* MSI sources */ object_property_set_link (OBJECT (&phb->msis),OBJECT (phb),"phb" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_link (OBJECT (&phb->msis),OBJECT (pnv),"xics" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_bool (OBJECT (&phb->msis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
@@ -1034,7 +1046,11 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* Power Bus Common Queue */ object_property_set_link (OBJECT (&phb->pbcq),OBJECT (phb),"phb" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_bool (OBJECT (&phb->pbcq), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 11/23] hw/pci-host/pnv_phb3: Add missing error-propagation code
Quoted 8 lines · Philippe Mathieu-Daudé
Patch created mechanically by running:
$ spatch \ --macro-file scripts/cocci-macro-file.h --include-headers \ --sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \ --keep-comments --smpl-spacing --in-place --dir hwSigned-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 54 lines
--- hw/pci-host/pnv_phb3.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)hw/pci-host/pnv_phb3.c +20
-4@@ -1008,7 +1008,11 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* LSI sources */ object_property_set_link (OBJECT (&phb->lsis),OBJECT (pnv),"xics" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_bool (OBJECT (&phb->lsis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);@@ -1023,9 +1027,17 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* MSI sources */ object_property_set_link (OBJECT (&phb->msis),OBJECT (phb),"phb" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_link (OBJECT (&phb->msis),OBJECT (pnv),"xics" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_bool (OBJECT (&phb->msis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);@@ -1034,7 +1046,11 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* Power Bus Common Queue */ object_property_set_link (OBJECT (&phb->pbcq),OBJECT (phb),"phb" , - &error_abort); + &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }object_property_set_bool (OBJECT (&phb->pbcq), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v3 12/23 hw/block/onenand: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/use-error_propagate-in-realize.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/block/onenand.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/block/onenand.c +5 -1
@@ -810,7 +810,11 @@ static void onenand_realize(DeviceState *dev, Error **errp) s->otp =memset (g_malloc ((64 +2 ) <<PAGE_SHIFT ),0xff , (64 +2 ) <<PAGE_SHIFT );memory_region_init_ram_nomigrate (&s->ram,OBJECT (s),"onenand.ram" , -0xc000 << s->shift, &error_fatal); +0xc000 << s->shift, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }vmstate_register_ram_global (&s->ram); ram =memory_region_get_ram_ptr (&s->ram); s->boot[0 ] = ram + (0x0000 << s->shift);
Signature · 1 line
2.21.1
PATCH v3 13/23 scripts/coccinelle: Add script to catch missing error_propagate() calls
In reply to Philippe Mathieu-DaudéIn some places in we put an error into a local Error*, but forget to check for failure and pass it back to the caller. Add a Coccinelle patch to catch and automatically add the missing code.
---
v3: Fixed typo 'provides', let prototype return 'void' (eblake)
--- .../add-missing-error_propagate.cocci | 30 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 31 insertions(+) create mode 100644 scripts/coccinelle/add-missing-error_propagate.cocci
scripts/coccinelle/add-missing-error_propagate.cocci new file +30 -0
@@ -0,0 +1,30 @@ +// Add missing error-propagation code where caller provides a Error* argument +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h --include-headers \ +// --sp-file scripts/coccinelle/add-missing-error_propagate.cocci \ +// --keep-comments --in-place +// +// Inspired by https://www.mail-archive.com/[email protected]/msg691638.html + + +@ add_missing_error_propagate @ +typedef Error; +Error *local_err; +identifier func, errp, errfunc1, errfunc2; +@@ +void func(..., Error **errp) +{ + <... + errfunc1(..., &local_err); ++ if (local_err) { ++ error_propagate(errp, local_err); ++ return; ++ } + ... when != local_err + errfunc2(..., &local_err); + ...> +}
MAINTAINERS +1 -0
@@ -2054,6 +2054,7 @@ F: include/qemu/error-report.h F: qapi/error.json F: util/error.c F: util/qemu-error.c +F: scripts/coccinelle/add-missing-error_propagate.cocci F: scripts/coccinelle/err-bad-newline.cocci F: scripts/coccinelle/error-use-after-free.cocci F: scripts/coccinelle/error_propagate_null.cocci
Signature · 1 line
2.21.1
PATCH v3 14/23 hw/arm/bcm2835_peripherals: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/bcm2835_peripherals.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/arm/bcm2835_peripherals.c +8 -0
@@ -289,8 +289,16 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)* SD3.0_Host_AHB_eMMC4.4_Usersguide_ver5.9_jan11_10.pdf */ object_property_set_uint (OBJECT (&s->sdhci),3 ,"sd-spec-version" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_uint (OBJECT (&s->sdhci),BCM2835_SDHC_CAPAREG ,"capareg" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->sdhci), true,"pending-insert-quirk" , &err);if (err) {
Signature · 1 line
2.21.1
PATCH v3 15/23 hw/arm/fsl-imx: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/fsl-imx25.c | 8 ++++++++ hw/arm/fsl-imx6.c | 8 ++++++++ 2 files changed, 16 insertions(+)
hw/arm/fsl-imx25.c +8 -0
@@ -271,8 +271,16 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)object_property_set_uint (OBJECT (&s->esdhc[i]),2 ,"sd-spec-version" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_uint (OBJECT (&s->esdhc[i]),IMX25_ESDHC_CAPABILITIES ,"capareg" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->esdhc[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/arm/fsl-imx6.c +8 -0
@@ -343,8 +343,16 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)/* UHS-I SDIO3.0 SDR104 1.8V ADMA */ object_property_set_uint (OBJECT (&s->esdhc[i]),3 ,"sd-spec-version" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_uint (OBJECT (&s->esdhc[i]),IMX6_ESDHC_CAPABILITIES ,"capareg" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->esdhc[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
Signature · 1 line
2.21.1
PATCH v3 16/23 hw/arm/stm32fx05_soc: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --in-place --dir hw--- hw/arm/stm32f205_soc.c | 4 ++++ hw/arm/stm32f405_soc.c | 4 ++++ 2 files changed, 8 insertions(+)
hw/arm/stm32f205_soc.c +4 -0
@@ -159,6 +159,10 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)/* ADC 1 to 3 */ object_property_set_int (OBJECT (s->adc_irqs),STM_NUM_ADCS ,"num-lines" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (s->adc_irqs), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
hw/arm/stm32f405_soc.c +4 -0
@@ -181,6 +181,10 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) }object_property_set_int (OBJECT (&s->adc_irqs),STM_NUM_ADCS ,"num-lines" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->adc_irqs), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
Signature · 1 line
2.21.1
PATCH v3 17/23 hw/dma/xilinx_axidma: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --dir hwThen review showed this file has a 'xilinx_axidma_realize_fail' label that calls error_propagate(). Updated the patch to use the label.
---
v2: New cocci patch generated both transformations
(Peter noticed v1 only catched one)
--- hw/dma/xilinx_axidma.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/dma/xilinx_axidma.c +6 -0
@@ -531,6 +531,9 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp) object_property_allow_set_link,OBJ_PROP_LINK_STRONG , &local_err); +if (local_err) { + goto xilinx_axidma_realize_fail; + } object_property_add_link(OBJECT(cs), "dma", TYPE_XILINX_AXI_DMA, (Object **)&cs->dma, object_property_allow_set_link,
@@ -540,6 +543,9 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp) goto xilinx_axidma_realize_fail; }object_property_set_link (OBJECT (ds),OBJECT (s),"dma" , &local_err); +if (local_err) { + goto xilinx_axidma_realize_fail; + }object_property_set_link (OBJECT (cs),OBJECT (s),"dma" , &local_err);if (local_err) { goto xilinx_axidma_realize_fail;
Signature · 1 line
2.21.1
PATCH v3 18/23 hw/i386/x86: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéRunning the coccinelle script:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --dir hwinserted a block after object_property_set_uint("apic-id") which calls error_propagate() and return.
Thanksfully code review noticed returning here would skip the 'object_unref(cpu)' call.
Manually fix the error propagation code by adding a label to the existing call.
--- hw/i386/x86.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/x86.c +4 -0
@@ -124,8 +124,12 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp) cpu =object_new (MACHINE (x86ms)->cpu_type);object_property_set_uint (cpu, apic_id,"apic-id" , &local_err); +if (local_err) { + goto out; + }object_property_set_bool (cpu, true,"realized" , &local_err); +out:object_unref (cpu);error_propagate (errp, local_err); }
Signature · 1 line
2.21.1
PATCH v3 19/23 hw/mips/cps: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --in-place --dir hwUnfortunately the cocci script doesn't properly patch trailing error_propagate() block and emitted duplicate if() block statements. These 3 blocks were manually removed.
--- hw/mips/cps.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
hw/mips/cps.c +48 -0
@@ -102,9 +102,21 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)sysbus_init_child_obj (OBJECT (dev),"itu" , &s->itu,sizeof (s->itu),TYPE_MIPS_ITU );object_property_set_int (OBJECT (&s->itu),16 ,"num-fifo" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_int (OBJECT (&s->itu),16 ,"num-semaphores" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->itu), saar_present,"saar-present" , &err); +if (err) { +error_propagate (errp, err); +return ; + }if (saar_present) { s->itu.saar = &env->CP0_SAAR; }
@@ -122,7 +134,15 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)sysbus_init_child_obj (OBJECT (dev),"cpc" , &s->cpc,sizeof (s->cpc),TYPE_MIPS_CPC );object_property_set_int (OBJECT (&s->cpc), s->num_vp,"num-vp" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_int (OBJECT (&s->cpc),1 ,"vp-start-running" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->cpc), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
@@ -136,7 +156,15 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)sysbus_init_child_obj (OBJECT (dev),"gic" , &s->gic,sizeof (s->gic),TYPE_MIPS_GIC );object_property_set_int (OBJECT (&s->gic), s->num_vp,"num-vp" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_int (OBJECT (&s->gic),128 ,"num-irq" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->gic), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
@@ -152,10 +180,30 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)sysbus_init_child_obj (OBJECT (dev),"gcr" , &s->gcr,sizeof (s->gcr),TYPE_MIPS_GCR );object_property_set_int (OBJECT (&s->gcr), s->num_vp,"num-vp" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_int (OBJECT (&s->gcr),0x800 ,"gcr-rev" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_int (OBJECT (&s->gcr), gcr_base,"gcr-base" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_link (OBJECT (&s->gcr),OBJECT (&s->gic.mr),"gic" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_link (OBJECT (&s->gcr),OBJECT (&s->cpc.mr),"cpc" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->gcr), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
Signature · 1 line
2.21.1
PATCH v3 20/23 hw/misc/macio/macio: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --dir hw--- hw/misc/macio/macio.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/misc/macio/macio.c +4 -0
@@ -348,6 +348,10 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)memory_region_add_subregion (&s->bar,0x50 ,sysbus_mmio_get_region (sysbus_dev,0 ));object_property_set_bool (OBJECT (&ns->gpio), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + }/* PMU */ object_initialize_child(OBJECT(s), "pmu", &s->pmu, sizeof(s->pmu),
Signature · 1 line
2.21.1
PATCH v3 21/23 hw/net/xilinx_axienet: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --dir hwThen review showed this file has a 'xilinx_enet_realize_fail' label that calls error_propagate(). Updated the patch to use the label.
---
v2: New cocci patch generated both transformations
(Peter noticed v1 only catched one)
--- hw/net/xilinx_axienet.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/net/xilinx_axienet.c +6 -0
@@ -958,6 +958,9 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp) object_property_allow_set_link,OBJ_PROP_LINK_STRONG , &local_err); +if (local_err) { + goto xilinx_enet_realize_fail; + } object_property_add_link(OBJECT(cs), "enet", "xlnx.axi-ethernet", (Object **) &cs->enet, object_property_allow_set_link,
@@ -967,6 +970,9 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp) goto xilinx_enet_realize_fail; }object_property_set_link (OBJECT (ds),OBJECT (s),"enet" , &local_err); +if (local_err) { + goto xilinx_enet_realize_fail; + }object_property_set_link (OBJECT (cs),OBJECT (s),"enet" , &local_err);if (local_err) { goto xilinx_enet_realize_fail;
Signature · 1 line
2.21.1
PATCH v3 22/23 hw/riscv/sifive_u: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --dir hw--- hw/riscv/sifive_u.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/riscv/sifive_u.c +8 -0
@@ -574,9 +574,17 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);object_property_set_bool (OBJECT (&s->prci), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->prci),0 , memmap[SIFIVE_U_PRCI ].base);object_property_set_bool (OBJECT (&s->otp), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_mmio_map (SYS_BUS_DEVICE (&s->otp),0 , memmap[SIFIVE_U_OTP ].base);for (i =0 ; i <SIFIVE_U_PLIC_NUM_SOURCES ; i++) {
Signature · 1 line
2.21.1
PATCH v3 23/23 hw/sd/milkymist-memcard: Add missing error-propagation code
In reply to Philippe Mathieu-DaudéPatch created mechanically by running:
$ spatch \
--macro-file scripts/cocci-macro-file.h --include-headers \
--sp-file scripts/coccinelle/add-missing-error_propagate.cocci \
--keep-comments --smpl-spacing --dir hw--- hw/sd/milkymist-memcard.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/sd/milkymist-memcard.c +4 -0
@@ -280,6 +280,10 @@ static void milkymist_memcard_realize(DeviceState *dev, Error **errp) blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ; carddev =qdev_create (BUS (&s->sdbus),TYPE_SD_CARD );qdev_prop_set_drive (carddev,"drive" , blk, &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (carddev), true,"realized" , &err);if (err) {error_setg (errp,"failed to init SD card: %s" ,error_get_pretty (err));
Signature · 1 line
2.21.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
RAMBlock "sram A" already registered, abort!
Broken pipe/tmp/qemu-test/src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)
ERROR - too few tests run (expected 6, got 5)
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 154
TEST iotest-qcow2: 156
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=bbbb9d29b4e4477f9a3e0dfbe1bf69db', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-744vr6w6/src/docker-src.2020-04-12-21.16.30.9289:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=bbbb9d29b4e4477f9a3e0dfbe1bf69db
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-744vr6w6/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 13m33.194s
user 0m9.060s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]