All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH-for-5.1 v3 00/23] various: Fix error-propagation with Coccinelle scripts (part 2)
@ 2020-04-12 22:41 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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/qemu-devel@nongnu.org/msg691636.html
[2] https://www.mail-archive.com/qemu-devel@nongnu.org/msg692155.html
Based-on: <20200412223619.11284-1-f4bug@amsat.org>

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

-- 
2.21.1



^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 00/23] various: Fix error-propagation with Coccinelle scripts (part 2)
@ 2020-04-12 22:41 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, Philippe Mathieu-Daudé

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/qemu-devel@nongnu.org/msg691636.html
[2] https://www.mail-archive.com/qemu-devel@nongnu.org/msg692155.html
Based-on: <20200412223619.11284-1-f4bug@amsat.org>

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

-- 
2.21.1



^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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 <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 .../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

diff --git a/scripts/coccinelle/use-error_propagate-in-realize.cocci b/scripts/coccinelle/use-error_propagate-in-realize.cocci
new file mode 100644
index 0000000000..7b59277a50
--- /dev/null
+++ b/scripts/coccinelle/use-error_propagate-in-realize.cocci
@@ -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/qemu-devel@nongnu.org/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;
++   }
+    ...+>
+}
diff --git a/MAINTAINERS b/MAINTAINERS
index 6203543ec0..54e05ecbdf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <alex.bennee@linaro.org>
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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 <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 .../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

diff --git a/scripts/coccinelle/use-error_propagate-in-realize.cocci b/scripts/coccinelle/use-error_propagate-in-realize.cocci
new file mode 100644
index 0000000000..7b59277a50
--- /dev/null
+++ b/scripts/coccinelle/use-error_propagate-in-realize.cocci
@@ -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/qemu-devel@nongnu.org/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;
++   }
+    ...+>
+}
diff --git a/MAINTAINERS b/MAINTAINERS
index 6203543ec0..54e05ecbdf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <alex.bennee@linaro.org>
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 02/23] hw/arm/fsl-imx: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/fsl-imx25.c |  6 +++++-
 hw/arm/fsl-imx6.c  | 18 +++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 6f1a82ce3d..3d87fe867e 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -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),
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 6bf8aa0404..b3cef5bb57 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -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]);
     }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 02/23] hw/arm/fsl-imx: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/fsl-imx25.c |  6 +++++-
 hw/arm/fsl-imx6.c  | 18 +++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 6f1a82ce3d..3d87fe867e 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -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),
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 6bf8aa0404..b3cef5bb57 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -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]);
     }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 03/23] hw/arm/stm32f*05_soc: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/stm32f205_soc.c | 6 +++++-
 hw/arm/stm32f405_soc.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 76b0b0e9be..b1be4fde40 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -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);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index 4f10ce6176..2b8a84a695 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 03/23] hw/arm/stm32f*05_soc: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, Philippe Mathieu-Daudé,
	Alistair Francis

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/stm32f205_soc.c | 6 +++++-
 hw/arm/stm32f405_soc.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 76b0b0e9be..b1be4fde40 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -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);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index 4f10ce6176..2b8a84a695 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 04/23] hw/arm/aspeed: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/aspeed_ast2600.c | 36 ++++++++++++++++++++++++++++++------
 hw/arm/aspeed_soc.c     | 12 ++++++++++--
 2 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index 64512f95c9..504f540369 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -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) {
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 4ee991ec16..1762c7aebd 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 04/23] hw/arm/aspeed: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/aspeed_ast2600.c | 36 ++++++++++++++++++++++++++++++------
 hw/arm/aspeed_soc.c     | 12 ++++++++++--
 2 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index 64512f95c9..504f540369 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -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) {
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 4ee991ec16..1762c7aebd 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 05/23] hw/arm/allwinner-a10: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/allwinner-a10.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index f41395734a..db70aa2b88 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -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));
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 05/23] hw/arm/allwinner-a10: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/allwinner-a10.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index f41395734a..db70aa2b88 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -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));
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 06/23] hw/arm/msf2-soc: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/msf2-soc.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index e448b0ab74..7619e71cfa 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 06/23] hw/arm/msf2-soc: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/msf2-soc.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index e448b0ab74..7619e71cfa 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 07/23] hw/riscv/sifive: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/riscv/sifive_e.c |  6 +++++-
 hw/riscv/sifive_u.c | 24 ++++++++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index 0be8b52147..6d4e141ff7 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -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,
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index e13ab34de4..b07526aba1 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 07/23] hw/riscv/sifive: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/riscv/sifive_e.c |  6 +++++-
 hw/riscv/sifive_u.c | 24 ++++++++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index 0be8b52147..6d4e141ff7 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -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,
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index e13ab34de4..b07526aba1 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 08/23] hw/arm/armv7m: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/armv7m.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 7531b97ccd..249a7605f6 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 08/23] hw/arm/armv7m: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/armv7m.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 7531b97ccd..249a7605f6 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 09/23] hw/intc/arm_gicv3_its_kvm: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/intc/arm_gicv3_its_kvm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
index ad0ebabc87..3d2c4e22f5 100644
--- a/hw/intc/arm_gicv3_its_kvm.c
+++ b/hw/intc/arm_gicv3_its_kvm.c
@@ -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,
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 09/23] hw/intc/arm_gicv3_its_kvm: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/intc/arm_gicv3_its_kvm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
index ad0ebabc87..3d2c4e22f5 100644
--- a/hw/intc/arm_gicv3_its_kvm.c
+++ b/hw/intc/arm_gicv3_its_kvm.c
@@ -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,
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 10/23] hw/microblaze/xlnx-zynqmp-pmu: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/microblaze/xlnx-zynqmp-pmu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
index 2aa602cf85..4ecbea7fdc 100644
--- a/hw/microblaze/xlnx-zynqmp-pmu.c
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 10/23] hw/microblaze/xlnx-zynqmp-pmu: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/microblaze/xlnx-zynqmp-pmu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
index 2aa602cf85..4ecbea7fdc 100644
--- a/hw/microblaze/xlnx-zynqmp-pmu.c
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -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



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 11/23] hw/pci-host/pnv_phb3: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/pci-host/pnv_phb3.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index 57d717ed23..a9029f5a02 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 11/23] hw/pci-host/pnv_phb3: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/pci-host/pnv_phb3.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index 57d717ed23..a9029f5a02 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 12/23] hw/block/onenand: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/block/onenand.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index 898ac563a3..1f68dba28b 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 12/23] hw/block/onenand: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/block/onenand.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index 898ac563a3..1f68dba28b 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 13/23] scripts/coccinelle: Add script to catch missing error_propagate() calls
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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.

Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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

diff --git a/scripts/coccinelle/add-missing-error_propagate.cocci b/scripts/coccinelle/add-missing-error_propagate.cocci
new file mode 100644
index 0000000000..4b82e40418
--- /dev/null
+++ b/scripts/coccinelle/add-missing-error_propagate.cocci
@@ -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/qemu-devel@nongnu.org/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);
+    ...>
+}
diff --git a/MAINTAINERS b/MAINTAINERS
index 54e05ecbdf..f996e72780 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 13/23] scripts/coccinelle: Add script to catch missing error_propagate() calls
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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.

Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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

diff --git a/scripts/coccinelle/add-missing-error_propagate.cocci b/scripts/coccinelle/add-missing-error_propagate.cocci
new file mode 100644
index 0000000000..4b82e40418
--- /dev/null
+++ b/scripts/coccinelle/add-missing-error_propagate.cocci
@@ -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/qemu-devel@nongnu.org/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);
+    ...>
+}
diff --git a/MAINTAINERS b/MAINTAINERS
index 54e05ecbdf..f996e72780 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 14/23] hw/arm/bcm2835_peripherals: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/bcm2835_peripherals.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index edcaa4916d..a111e91069 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -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) {
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 14/23] hw/arm/bcm2835_peripherals: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/bcm2835_peripherals.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index edcaa4916d..a111e91069 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -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) {
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 15/23] hw/arm/fsl-imx: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/fsl-imx25.c | 8 ++++++++
 hw/arm/fsl-imx6.c  | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 3d87fe867e..69d8645dcd 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -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);
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index b3cef5bb57..c254294a70 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 15/23] hw/arm/fsl-imx: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/fsl-imx25.c | 8 ++++++++
 hw/arm/fsl-imx6.c  | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index 3d87fe867e..69d8645dcd 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -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);
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index b3cef5bb57..c254294a70 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 16/23] hw/arm/stm32fx05_soc: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/stm32f205_soc.c | 4 ++++
 hw/arm/stm32f405_soc.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index b1be4fde40..fba18bc204 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -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);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index 2b8a84a695..6db77d296b 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 16/23] hw/arm/stm32fx05_soc: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, Philippe Mathieu-Daudé,
	Alistair Francis

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/stm32f205_soc.c | 4 ++++
 hw/arm/stm32f405_soc.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index b1be4fde40..fba18bc204 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -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);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index 2b8a84a695..6db77d296b 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 17/23] hw/dma/xilinx_axidma: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Then review showed this file has a 'xilinx_axidma_realize_fail'
label that calls error_propagate().  Updated the patch to use
the label.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v2: New cocci patch generated both transformations
    (Peter noticed v1 only catched one)
---
 hw/dma/xilinx_axidma.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index 018f36991b..2d36346319 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -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;
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 17/23] hw/dma/xilinx_axidma: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, Philippe Mathieu-Daudé,
	Alistair Francis

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

Then review showed this file has a 'xilinx_axidma_realize_fail'
label that calls error_propagate().  Updated the patch to use
the label.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v2: New cocci patch generated both transformations
    (Peter noticed v1 only catched one)
---
 hw/dma/xilinx_axidma.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index 018f36991b..2d36346319 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -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;
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 18/23] hw/i386/x86: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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 hw

inserted 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.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/i386/x86.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index b82770024c..ec807ce94f 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -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);
 }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 18/23] hw/i386/x86: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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 hw

inserted 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.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/i386/x86.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index b82770024c..ec807ce94f 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -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);
 }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 19/23] hw/mips/cps: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Unfortunately the cocci script doesn't properly patch trailing
error_propagate() block and emitted duplicate if() block statements.
These 3 blocks were manually removed.

Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/mips/cps.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/hw/mips/cps.c b/hw/mips/cps.c
index 92b9b1a5f6..18943b64e0 100644
--- a/hw/mips/cps.c
+++ b/hw/mips/cps.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 19/23] hw/mips/cps: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Unfortunately the cocci script doesn't properly patch trailing
error_propagate() block and emitted duplicate if() block statements.
These 3 blocks were manually removed.

Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/mips/cps.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/hw/mips/cps.c b/hw/mips/cps.c
index 92b9b1a5f6..18943b64e0 100644
--- a/hw/mips/cps.c
+++ b/hw/mips/cps.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 20/23] hw/misc/macio/macio: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/misc/macio/macio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 79222192e8..fffb64a7d5 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -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),
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 20/23] hw/misc/macio/macio: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/misc/macio/macio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 79222192e8..fffb64a7d5 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -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),
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 21/23] hw/net/xilinx_axienet: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Then review showed this file has a 'xilinx_enet_realize_fail'
label that calls error_propagate(). Updated the patch to use
the label.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v2: New cocci patch generated both transformations
    (Peter noticed v1 only catched one)
---
 hw/net/xilinx_axienet.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 704788811a..db2c675b16 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -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;
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 21/23] hw/net/xilinx_axienet: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, Philippe Mathieu-Daudé,
	Alistair Francis

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

Then review showed this file has a 'xilinx_enet_realize_fail'
label that calls error_propagate(). Updated the patch to use
the label.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v2: New cocci patch generated both transformations
    (Peter noticed v1 only catched one)
---
 hw/net/xilinx_axienet.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 704788811a..db2c675b16 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -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;
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 22/23] hw/riscv/sifive_u: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/riscv/sifive_u.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index b07526aba1..b6c27bc970 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -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++) {
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 22/23] hw/riscv/sifive_u: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, Philippe Mathieu-Daudé,
	Alistair Francis

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/riscv/sifive_u.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index b07526aba1..b6c27bc970 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -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++) {
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 23/23] hw/sd/milkymist-memcard: Add missing error-propagation code
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Philippe Mathieu-Daudé,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle, qemu-ppc,
	Paolo Bonzini, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sd/milkymist-memcard.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
index 926e1af475..87294c1b71 100644
--- a/hw/sd/milkymist-memcard.c
+++ b/hw/sd/milkymist-memcard.c
@@ -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));
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH-for-5.1 v3 23/23] hw/sd/milkymist-memcard: Add missing error-propagation code
@ 2020-04-12 22:41   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 64+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 22:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Richard Henderson, Michael S. Tsirkin, qemu-ppc,
	Beniamino Galvani, David Gibson, Aleksandar Rikalo,
	Andrew Jeffery, Alistair Francis, Eduardo Habkost,
	Andrew Baumann, Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater, 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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sd/milkymist-memcard.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
index 926e1af475..87294c1b71 100644
--- a/hw/sd/milkymist-memcard.c
+++ b/hw/sd/milkymist-memcard.c
@@ -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));
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 00/23] various: Fix error-propagation with Coccinelle scripts (part 2)
  2020-04-12 22:41 ` Philippe Mathieu-Daudé
@ 2020-04-13  1:30   ` no-reply
  -1 siblings, 0 replies; 64+ messages in thread
From: no-reply @ 2020-04-13  1:30 UTC (permalink / raw)
  To: f4bug
  Cc: peter.maydell, sagark, mst, jasowang, mark.cave-ayland,
	qemu-devel, Alistair.Francis, edgar.iglesias, mreitz, qemu-block,
	armbru, aleksandar.qemu.devel, joel, qemu-ppc, aleksandar.rikalo,
	rth, philmd, ehabkost, jcd, alistair, b.galvani, qemu-arm, clg,
	david, kwolf, qemu-riscv, andrew, kbastian, f4bug,
	Andrew.Baumann, sundeep.lkml, michael, palmer, pbonzini,
	aurelien

Patchew URL: https://patchew.org/QEMU/20200412224144.12205-1-f4bug@amsat.org/



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/20200412224144.12205-1-f4bug@amsat.org/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 00/23] various: Fix error-propagation with Coccinelle scripts (part 2)
@ 2020-04-13  1:30   ` no-reply
  0 siblings, 0 replies; 64+ messages in thread
From: no-reply @ 2020-04-13  1:30 UTC (permalink / raw)
  To: f4bug
  Cc: qemu-devel, peter.maydell, sagark, mst, jasowang,
	mark.cave-ayland, Alistair.Francis, edgar.iglesias, sundeep.lkml,
	qemu-block, armbru, aleksandar.qemu.devel, mreitz, joel, palmer,
	aleksandar.rikalo, david, philmd, ehabkost, alistair, b.galvani,
	qemu-arm, clg, rth, kwolf, qemu-riscv, andrew, kbastian, f4bug,
	Andrew.Baumann, jcd, michael, qemu-ppc, pbonzini, aurelien

Patchew URL: https://patchew.org/QEMU/20200412224144.12205-1-f4bug@amsat.org/



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/20200412224144.12205-1-f4bug@amsat.org/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 06/23] hw/arm/msf2-soc: Add missing error-propagation code
  2020-04-12 22:41   ` Philippe Mathieu-Daudé
@ 2020-04-13 15:57     ` Alistair Francis
  -1 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 15:57 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, qemu-devel@nongnu.org Developers,
	Alistair Francis, Edgar E. Iglesias, Max Reitz, Qemu-block,
	Markus Armbruster, Aleksandar Markovic, Joel Stanley,
	open list:New World, Aleksandar Rikalo, Richard Henderson,
	Philippe Mathieu-Daudé,
	Eduardo Habkost, Jean-Christophe Dubois, Alistair Francis,
	Beniamino Galvani, qemu-arm, Cédric Le Goater, David Gibson,
	Kevin Wolf, open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Subbaraya Sundeep, Michael Walle, Palmer Dabbelt,
	Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 3:53 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/arm/msf2-soc.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> index e448b0ab74..7619e71cfa 100644
> --- a/hw/arm/msf2-soc.c
> +++ b/hw/arm/msf2-soc.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 06/23] hw/arm/msf2-soc: Add missing error-propagation code
@ 2020-04-13 15:57     ` Alistair Francis
  0 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 15:57 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel@nongnu.org Developers, Peter Maydell,
	Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, Qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf,
	open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle,
	open list:New World, Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 3:53 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/arm/msf2-soc.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> index e448b0ab74..7619e71cfa 100644
> --- a/hw/arm/msf2-soc.c
> +++ b/hw/arm/msf2-soc.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 08/23] hw/arm/armv7m: Add missing error-propagation code
  2020-04-12 22:41   ` Philippe Mathieu-Daudé
@ 2020-04-13 22:10     ` Alistair Francis
  -1 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 22:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, qemu-devel@nongnu.org Developers,
	Alistair Francis, Edgar E. Iglesias, Max Reitz, Qemu-block,
	Markus Armbruster, Aleksandar Markovic, Joel Stanley,
	open list:New World, Aleksandar Rikalo, Richard Henderson,
	Philippe Mathieu-Daudé,
	Eduardo Habkost, Jean-Christophe Dubois, Alistair Francis,
	Beniamino Galvani, qemu-arm, Cédric Le Goater, David Gibson,
	Kevin Wolf, open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Subbaraya Sundeep, Michael Walle, Palmer Dabbelt,
	Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 3:54 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/arm/armv7m.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
> index 7531b97ccd..249a7605f6 100644
> --- a/hw/arm/armv7m.c
> +++ b/hw/arm/armv7m.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 08/23] hw/arm/armv7m: Add missing error-propagation code
@ 2020-04-13 22:10     ` Alistair Francis
  0 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 22:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel@nongnu.org Developers, Peter Maydell,
	Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, Qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf,
	open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle,
	open list:New World, Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 3:54 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/arm/armv7m.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
> index 7531b97ccd..249a7605f6 100644
> --- a/hw/arm/armv7m.c
> +++ b/hw/arm/armv7m.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 07/23] hw/riscv/sifive: Add missing error-propagation code
  2020-04-12 22:41   ` Philippe Mathieu-Daudé
@ 2020-04-13 22:12     ` Alistair Francis
  -1 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 22:12 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, qemu-devel@nongnu.org Developers,
	Alistair Francis, Edgar E. Iglesias, Max Reitz, Qemu-block,
	Markus Armbruster, Aleksandar Markovic, Joel Stanley,
	open list:New World, Aleksandar Rikalo, Richard Henderson,
	Philippe Mathieu-Daudé,
	Eduardo Habkost, Jean-Christophe Dubois, Alistair Francis,
	Beniamino Galvani, qemu-arm, Cédric Le Goater, David Gibson,
	Kevin Wolf, open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Subbaraya Sundeep, Michael Walle, Palmer Dabbelt,
	Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 4:00 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/riscv/sifive_e.c |  6 +++++-
>  hw/riscv/sifive_u.c | 24 ++++++++++++++++++++----
>  2 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
> index 0be8b52147..6d4e141ff7 100644
> --- a/hw/riscv/sifive_e.c
> +++ b/hw/riscv/sifive_e.c
> @@ -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,
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index e13ab34de4..b07526aba1 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 07/23] hw/riscv/sifive: Add missing error-propagation code
@ 2020-04-13 22:12     ` Alistair Francis
  0 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 22:12 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel@nongnu.org Developers, Peter Maydell,
	Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, Qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf,
	open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle,
	open list:New World, Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 4:00 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/riscv/sifive_e.c |  6 +++++-
>  hw/riscv/sifive_u.c | 24 ++++++++++++++++++++----
>  2 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
> index 0be8b52147..6d4e141ff7 100644
> --- a/hw/riscv/sifive_e.c
> +++ b/hw/riscv/sifive_e.c
> @@ -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,
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index e13ab34de4..b07526aba1 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 10/23] hw/microblaze/xlnx-zynqmp-pmu: Add missing error-propagation code
  2020-04-12 22:41   ` Philippe Mathieu-Daudé
@ 2020-04-13 22:13     ` Alistair Francis
  -1 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 22:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, qemu-devel@nongnu.org Developers,
	Alistair Francis, Edgar E. Iglesias, Max Reitz, Qemu-block,
	Markus Armbruster, Aleksandar Markovic, Joel Stanley,
	open list:New World, Aleksandar Rikalo, Richard Henderson,
	Philippe Mathieu-Daudé,
	Eduardo Habkost, Jean-Christophe Dubois, Alistair Francis,
	Beniamino Galvani, qemu-arm, Cédric Le Goater, David Gibson,
	Kevin Wolf, open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Subbaraya Sundeep, Michael Walle, Palmer Dabbelt,
	Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 3:58 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/microblaze/xlnx-zynqmp-pmu.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
> index 2aa602cf85..4ecbea7fdc 100644
> --- a/hw/microblaze/xlnx-zynqmp-pmu.c
> +++ b/hw/microblaze/xlnx-zynqmp-pmu.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 10/23] hw/microblaze/xlnx-zynqmp-pmu: Add missing error-propagation code
@ 2020-04-13 22:13     ` Alistair Francis
  0 siblings, 0 replies; 64+ messages in thread
From: Alistair Francis @ 2020-04-13 22:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel@nongnu.org Developers, Peter Maydell,
	Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, Alistair Francis, Edgar E. Iglesias,
	Subbaraya Sundeep, Qemu-block, Markus Armbruster,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf,
	open list:RISC-V, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Jean-Christophe Dubois, Michael Walle,
	open list:New World, Paolo Bonzini, Aurelien Jarno

On Sun, Apr 12, 2020 at 3:58 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/microblaze/xlnx-zynqmp-pmu.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
> index 2aa602cf85..4ecbea7fdc 100644
> --- a/hw/microblaze/xlnx-zynqmp-pmu.c
> +++ b/hw/microblaze/xlnx-zynqmp-pmu.c
> @@ -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
>
>


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 11/23] hw/pci-host/pnv_phb3: Add missing error-propagation code
  2020-04-12 22:41   ` Philippe Mathieu-Daudé
@ 2020-04-14  2:12     ` David Gibson
  -1 siblings, 0 replies; 64+ messages in thread
From: David Gibson @ 2020-04-14  2:12 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, qemu-devel, Alistair Francis,
	Edgar E. Iglesias, Subbaraya Sundeep, qemu-block,
	Markus Armbruster, Aleksandar Markovic, Max Reitz, Joel Stanley,
	Palmer Dabbelt, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Andrew Baumann,
	Jean-Christophe Dubois, Michael Walle, qemu-ppc, Paolo Bonzini,
	Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 2892 bytes --]

On Mon, Apr 13, 2020 at 12:41:32AM +0200, Philippe Mathieu-Daudé wrote:
> 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
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/pci-host/pnv_phb3.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
> index 57d717ed23..a9029f5a02 100644
> --- a/hw/pci-host/pnv_phb3.c
> +++ b/hw/pci-host/pnv_phb3.c
> @@ -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);

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 11/23] hw/pci-host/pnv_phb3: Add missing error-propagation code
@ 2020-04-14  2:12     ` David Gibson
  0 siblings, 0 replies; 64+ messages in thread
From: David Gibson @ 2020-04-14  2:12 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, qemu-block, Richard Henderson, Michael S. Tsirkin,
	qemu-ppc, Beniamino Galvani, Aleksandar Rikalo, Andrew Jeffery,
	Alistair Francis, Eduardo Habkost, Andrew Baumann,
	Philippe Mathieu-Daudé,
	Palmer Dabbelt, Bastian Koppelmann, Edgar E. Iglesias,
	qemu-riscv, Sagar Karandikar, Alistair Francis, Jason Wang,
	Aleksandar Markovic, Peter Maydell, Paolo Bonzini, Kevin Wolf,
	Aurelien Jarno, Mark Cave-Ayland, qemu-arm, Michael Walle,
	Joel Stanley, Jean-Christophe Dubois, Subbaraya Sundeep,
	Markus Armbruster, Max Reitz, Marcel Apfelbaum,
	Cédric Le Goater

[-- Attachment #1: Type: text/plain, Size: 2892 bytes --]

On Mon, Apr 13, 2020 at 12:41:32AM +0200, Philippe Mathieu-Daudé wrote:
> 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
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/pci-host/pnv_phb3.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
> index 57d717ed23..a9029f5a02 100644
> --- a/hw/pci-host/pnv_phb3.c
> +++ b/hw/pci-host/pnv_phb3.c
> @@ -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);

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
  2020-04-12 22:41   ` Philippe Mathieu-Daudé
@ 2020-04-14 12:40     ` Markus Armbruster
  -1 siblings, 0 replies; 64+ messages in thread
From: Markus Armbruster @ 2020-04-14 12:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, qemu-devel, Alistair Francis,
	Edgar E. Iglesias, Max Reitz, qemu-block, Aleksandar Markovic,
	Joel Stanley, qemu-ppc, Aleksandar Rikalo, Richard Henderson,
	Philippe Mathieu-Daudé,
	Eduardo Habkost, Jean-Christophe Dubois, Alistair Francis,
	Beniamino Galvani, qemu-arm, Cédric Le Goater, David Gibson,
	Kevin Wolf, qemu-riscv, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Subbaraya Sundeep, Michael Walle, Palmer Dabbelt,
	Paolo Bonzini, Aurelien Jarno

Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> 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 <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  .../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
>
> diff --git a/scripts/coccinelle/use-error_propagate-in-realize.cocci b/scripts/coccinelle/use-error_propagate-in-realize.cocci
> new file mode 100644
> index 0000000000..7b59277a50
> --- /dev/null
> +++ b/scripts/coccinelle/use-error_propagate-in-realize.cocci
> @@ -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/qemu-devel@nongnu.org/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;

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.

> ++   }
> +    ...+>
> +}
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6203543ec0..54e05ecbdf 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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 <alex.bennee@linaro.org>



^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
@ 2020-04-14 12:40     ` Markus Armbruster
  0 siblings, 0 replies; 64+ messages in thread
From: Markus Armbruster @ 2020-04-14 12:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Peter Maydell, Sagar Karandikar, Michael S. Tsirkin,
	Jason Wang, Mark Cave-Ayland, Alistair Francis,
	Edgar E. Iglesias, Subbaraya Sundeep, qemu-block,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Andrew Baumann,
	Jean-Christophe Dubois, Michael Walle, qemu-ppc, Paolo Bonzini,
	Aurelien Jarno

Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> 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 <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  .../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
>
> diff --git a/scripts/coccinelle/use-error_propagate-in-realize.cocci b/scripts/coccinelle/use-error_propagate-in-realize.cocci
> new file mode 100644
> index 0000000000..7b59277a50
> --- /dev/null
> +++ b/scripts/coccinelle/use-error_propagate-in-realize.cocci
> @@ -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/qemu-devel@nongnu.org/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;

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.

> ++   }
> +    ...+>
> +}
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6203543ec0..54e05ecbdf 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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 <alex.bennee@linaro.org>



^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
  2020-04-14 12:40     ` Markus Armbruster
@ 2020-04-14 13:24       ` Markus Armbruster
  -1 siblings, 0 replies; 64+ messages in thread
From: Markus Armbruster @ 2020-04-14 13:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Sagar Karandikar, Michael S. Tsirkin, Jason Wang,
	Mark Cave-Ayland, qemu-devel, Alistair Francis,
	Edgar E. Iglesias, Max Reitz, qemu-block, Aleksandar Markovic,
	Joel Stanley, qemu-ppc, Aleksandar Rikalo, Richard Henderson,
	Philippe Mathieu-Daudé,
	Eduardo Habkost, Jean-Christophe Dubois, Alistair Francis,
	Beniamino Galvani, qemu-arm, Cédric Le Goater, David Gibson,
	Kevin Wolf, qemu-riscv, Andrew Jeffery, Bastian Koppelmann,
	Andrew Baumann, Subbaraya Sundeep, Michael Walle, Palmer Dabbelt,
	Paolo Bonzini, Aurelien Jarno

Markus Armbruster <armbru@redhat.com> writes:

> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
>
>> 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 <peter.maydell@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  .../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
>>
>> diff --git a/scripts/coccinelle/use-error_propagate-in-realize.cocci b/scripts/coccinelle/use-error_propagate-in-realize.cocci
>> new file mode 100644
>> index 0000000000..7b59277a50
>> --- /dev/null
>> +++ b/scripts/coccinelle/use-error_propagate-in-realize.cocci
>> @@ -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/qemu-devel@nongnu.org/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;
>
> 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().

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.

>
> 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().

> 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.



^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize()
@ 2020-04-14 13:24       ` Markus Armbruster
  0 siblings, 0 replies; 64+ messages in thread
From: Markus Armbruster @ 2020-04-14 13:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Peter Maydell, Sagar Karandikar, Michael S. Tsirkin,
	Jason Wang, Mark Cave-Ayland, Alistair Francis,
	Edgar E. Iglesias, Subbaraya Sundeep, qemu-block,
	Aleksandar Markovic, Max Reitz, Joel Stanley, Palmer Dabbelt,
	Aleksandar Rikalo, David Gibson, Philippe Mathieu-Daudé,
	Eduardo Habkost, Alistair Francis, Beniamino Galvani, qemu-arm,
	Cédric Le Goater, Richard Henderson, Kevin Wolf, qemu-riscv,
	Andrew Jeffery, Bastian Koppelmann, Andrew Baumann,
	Jean-Christophe Dubois, Michael Walle, qemu-ppc, Paolo Bonzini,
	Aurelien Jarno

Markus Armbruster <armbru@redhat.com> writes:

> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
>
>> 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 <peter.maydell@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  .../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
>>
>> diff --git a/scripts/coccinelle/use-error_propagate-in-realize.cocci b/scripts/coccinelle/use-error_propagate-in-realize.cocci
>> new file mode 100644
>> index 0000000000..7b59277a50
>> --- /dev/null
>> +++ b/scripts/coccinelle/use-error_propagate-in-realize.cocci
>> @@ -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/qemu-devel@nongnu.org/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;
>
> 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().

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.

>
> 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().

> 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.



^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2020-04-14 13:25 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 22:41 [PATCH-for-5.1 v3 00/23] various: Fix error-propagation with Coccinelle scripts (part 2) Philippe Mathieu-Daudé
2020-04-12 22:41 ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 01/23] scripts/coccinelle: Catch missing error_propagate() calls in realize() Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-14 12:40   ` Markus Armbruster
2020-04-14 12:40     ` Markus Armbruster
2020-04-14 13:24     ` Markus Armbruster
2020-04-14 13:24       ` Markus Armbruster
2020-04-12 22:41 ` [PATCH-for-5.1 v3 02/23] hw/arm/fsl-imx: Add missing error-propagation code Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 03/23] hw/arm/stm32f*05_soc: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 04/23] hw/arm/aspeed: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 05/23] hw/arm/allwinner-a10: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 06/23] hw/arm/msf2-soc: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-13 15:57   ` Alistair Francis
2020-04-13 15:57     ` Alistair Francis
2020-04-12 22:41 ` [PATCH-for-5.1 v3 07/23] hw/riscv/sifive: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-13 22:12   ` Alistair Francis
2020-04-13 22:12     ` Alistair Francis
2020-04-12 22:41 ` [PATCH-for-5.1 v3 08/23] hw/arm/armv7m: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-13 22:10   ` Alistair Francis
2020-04-13 22:10     ` Alistair Francis
2020-04-12 22:41 ` [PATCH-for-5.1 v3 09/23] hw/intc/arm_gicv3_its_kvm: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 10/23] hw/microblaze/xlnx-zynqmp-pmu: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-13 22:13   ` Alistair Francis
2020-04-13 22:13     ` Alistair Francis
2020-04-12 22:41 ` [PATCH-for-5.1 v3 11/23] hw/pci-host/pnv_phb3: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-14  2:12   ` David Gibson
2020-04-14  2:12     ` David Gibson
2020-04-12 22:41 ` [PATCH-for-5.1 v3 12/23] hw/block/onenand: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 13/23] scripts/coccinelle: Add script to catch missing error_propagate() calls Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 14/23] hw/arm/bcm2835_peripherals: Add missing error-propagation code Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 15/23] hw/arm/fsl-imx: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 16/23] hw/arm/stm32fx05_soc: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 17/23] hw/dma/xilinx_axidma: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 18/23] hw/i386/x86: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 19/23] hw/mips/cps: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 20/23] hw/misc/macio/macio: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 21/23] hw/net/xilinx_axienet: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 22/23] hw/riscv/sifive_u: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-12 22:41 ` [PATCH-for-5.1 v3 23/23] hw/sd/milkymist-memcard: " Philippe Mathieu-Daudé
2020-04-12 22:41   ` Philippe Mathieu-Daudé
2020-04-13  1:30 ` [PATCH-for-5.1 v3 00/23] various: Fix error-propagation with Coccinelle scripts (part 2) no-reply
2020-04-13  1:30   ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.