Skip to contentSkip to conversation

error: auto propagated local_err

RFC Superseded Vladimir Sementsov-Ogievskiy 2 participants 27 messages Sep 23, 2019 – Sep 24, 2019

Subsystems (15)

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v2 cover error: auto propagated local_err

Hi all!

Here is a proposal of auto propagation for local_err, to not call error_propagate on every exit point, when we deal with local_err.

It also fixes two issues:
1. Fix issue with error_fatal & error_append_hint: user can't see these hints, because exit() happens in error_setg earlier than hint is appended. [Reported by Greg Kurz]

2. Fix issue with error_abort & error_propagate: when we wrap error_abort by local_err+error_propagate, resulting coredump will refer to error_propagate and not to the place where error happened. (the macro itself don't fix the issue, but it allows to [3.] drop all local_err+error_propagate pattern, which will definitely fix the issue) [Reported by Kevin Wolf]

It's still an RFC, due to the following reasons:

1. I'm new to coccinella, so I failed to do the following pattern:

<...
- goto out;
+ return;
...>
- out:
- error_propagate(errp, local_err)

So, here is compilation fix 08.. Who can help with it? If nobody, 08 is to be merged to 07 by hand.

2. Question about using new macro in empty stub functions - see 09

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

4. Also, checkpatch has some complains about 07 patch:
- using tabs.. (hmm exactly stubs functions..)
- empty ifs
Again, I don't see any ways to fix it other that by hand and merge to 07..

==================

Also, if we decide, that this all is too huge, here is plan B:

1. apply 01
2. fix only functions that don't use local_err and use error_append_hint, by just invocation of new macro at function start - it will substitute Greg's series with no pain.
3[optional]. Do full update for some subsystems, for example, only for block* and nbd*

Vladimir Sementsov-Ogievskiy (9):
error: auto propagated local_err
qapi/error: add (Error **errp) cleaning APIs
errp: rename errp to errp_in where it is IN-argument hw/core/loader-fit: fix freeing errp in fit_load_fdt net/net: fix local variable shadowing in net_client_init
scripts: add coccinelle script to use auto propagated errp Use auto-propagated errp
fix-compilation: empty goto
fix-compilation: includes

 include/hw/pci-host/spapr.h                   |   2 +
 include/monitor/hmp.h                         |   2 +-
 include/qapi/error.h                          |  61 ++++-
 target/ppc/kvm_ppc.h                          |   3 +
 target/s390x/cpu_models.h                     |   3 +
 ui/vnc.h                                      |   2 +-
 audio/audio.c                                 |  12 +-
 authz/pamacct.c                               |   1 +
 backends/cryptodev-vhost-user.c               |   9 +-
 backends/cryptodev.c                          |  24 +-
 backends/hostmem-file.c                       |  19 +-
 backends/hostmem-memfd.c                      |  17 +-
 backends/hostmem.c                            |  38 ++-
 backends/rng.c                                |   6 +-
 block.c                                       | 208 +++++++----------
 block/blkdebug.c                              |  33 +--
 block/blklogwrites.c                          |  21 +-
 block/blkreplay.c                             |   6 +-
 block/blkverify.c                             |  16 +-
 block/block-backend.c                         |  17 +-
 block/commit.c                                |   6 +-
 block/crypto.c                                |  12 +-
 block/curl.c                                  |   6 +-
 block/file-posix.c                            |  71 +++---
 block/file-win32.c                            |  27 +--
 block/gluster.c                               |  64 +++--
 block/io.c                                    |  11 +-
 block/iscsi.c                                 |  33 +--
 block/mirror.c                                |  17 +-
 block/nbd.c                                   |  44 ++--
 block/nfs.c                                   |   6 +-
 block/nvme.c                                  |  17 +-
 block/parallels.c                             |  28 +--
 block/qapi.c                                  |  23 +-
 block/qcow.c                                  |  15 +-
 block/qcow2-bitmap.c                          |   6 +-
 block/qcow2.c                                 |  90 +++----
 block/qed.c                                   |  16 +-
 block/quorum.c                                |  22 +-
 block/raw-format.c                            |   6 +-
 block/rbd.c                                   |  25 +-
 block/replication.c                           |  36 ++-
 block/sheepdog.c                              |  66 +++---
 block/snapshot.c                              |  14 +-
 block/ssh.c                                   |  11 +-
 block/throttle-groups.c                       |  22 +-
 block/throttle.c                              |   6 +-
 block/vdi.c                                   |  12 +-
 block/vhdx.c                                  |  20 +-
 block/vmdk.c                                  |  36 +--
 block/vpc.c                                   |  25 +-
 block/vvfat.c                                 |  11 +-
 block/vxhs.c                                  |  22 +-
 blockdev.c                                    | 220 +++++++-----------
 blockjob.c                                    |   7 +-
 bootdevice.c                                  |  29 +--
 chardev/char-socket.c                         |   6 +-
 chardev/char.c                                |  18 +-
 crypto/block-luks.c                           |  31 +--
 crypto/secret.c                               |  16 +-
 crypto/tlssession.c                           |   6 +-
 dump/dump.c                                   | 142 +++++------
 dump/win_dump.c                               |  27 +--
 exec.c                                        |  12 +-
 hw/9pfs/9p-local.c                            |   7 +-
 hw/acpi/core.c                                |  17 +-
 hw/acpi/ich9.c                                |  27 +--
 hw/acpi/memory_hotplug.c                      |   6 +-
 hw/arm/allwinner-a10.c                        |  26 +--
 hw/arm/armv7m.c                               |  51 ++--
 hw/arm/bcm2835_peripherals.c                  |  84 +++----
 hw/arm/bcm2836.c                              |  40 ++--
 hw/arm/digic.c                                |  21 +-
 hw/arm/fsl-imx25.c                            |  61 ++---
 hw/arm/fsl-imx31.c                            |  56 ++---
 hw/arm/fsl-imx6.c                             |  80 +++----
 hw/arm/integratorcp.c                         |   6 +-
 hw/arm/msf2-soc.c                             |  21 +-
 hw/arm/nrf51_soc.c                            |  46 ++--
 hw/arm/smmu-common.c                          |   6 +-
 hw/arm/smmuv3.c                               |   6 +-
 hw/arm/stm32f205_soc.c                        |  38 ++-
 hw/arm/tosa.c                                 |   1 +
 hw/arm/xlnx-versal-virt.c                     |   6 +-
 hw/arm/xlnx-zynqmp.c                          |  84 +++----
 hw/audio/intel-hda.c                          |  12 +-
 hw/block/dataplane/xen-block.c                |  16 +-
 hw/block/fdc.c                                |  17 +-
 hw/block/onenand.c                            |   6 +-
 hw/block/pflash_cfi01.c                       |   6 +-
 hw/block/pflash_cfi02.c                       |   6 +-
 hw/block/vhost-user-blk.c                     |   5 +-
 hw/block/virtio-blk.c                         |   6 +-
 hw/block/xen-block.c                          | 114 ++++-----
 hw/char/debugcon.c                            |   6 +-
 hw/char/serial-pci-multi.c                    |   6 +-
 hw/char/serial-pci.c                          |   6 +-
 hw/char/virtio-serial-bus.c                   |   6 +-
 hw/core/bus.c                                 |  14 +-
 hw/core/loader-fit.c                          |   2 +-
 hw/core/machine.c                             |  18 +-
 hw/core/numa.c                                |  48 ++--
 hw/core/qdev-properties-system.c              |  24 +-
 hw/core/qdev-properties.c                     |  78 +++----
 hw/core/qdev.c                                |  36 ++-
 hw/core/sysbus.c                              |   1 +
 hw/cpu/a15mpcore.c                            |   6 +-
 hw/cpu/a9mpcore.c                             |  26 +--
 hw/cpu/arm11mpcore.c                          |  21 +-
 hw/cpu/core.c                                 |  12 +-
 hw/cpu/realview_mpcore.c                      |  11 +-
 hw/display/bcm2835_fb.c                       |   5 +-
 hw/display/qxl.c                              |   6 +-
 hw/display/virtio-gpu-base.c                  |   6 +-
 hw/display/virtio-gpu-pci.c                   |   6 +-
 hw/display/virtio-vga.c                       |   6 +-
 hw/dma/bcm2835_dma.c                          |   5 +-
 hw/dma/xilinx_axidma.c                        |  21 +-
 hw/gpio/aspeed_gpio.c                         |   6 +-
 hw/gpio/bcm2835_gpio.c                        |   9 +-
 hw/i386/kvm/apic.c                            |   2 +
 hw/i386/pc.c                                  | 109 ++++-----
 hw/ide/qdev.c                                 |  15 +-
 hw/input/virtio-input.c                       |  12 +-
 hw/intc/apic_common.c                         |   6 +-
 hw/intc/arm_gic.c                             |   6 +-
 hw/intc/arm_gic_kvm.c                         |  11 +-
 hw/intc/arm_gicv3.c                           |  11 +-
 hw/intc/arm_gicv3_its_kvm.c                   |   6 +-
 hw/intc/arm_gicv3_kvm.c                       |  16 +-
 hw/intc/armv7m_nvic.c                         |  11 +-
 hw/intc/nios2_iic.c                           |   5 +-
 hw/intc/pnv_xive.c                            |  14 +-
 hw/intc/realview_gic.c                        |   6 +-
 hw/intc/s390_flic_kvm.c                       |  10 +-
 hw/intc/spapr_xive.c                          |  11 +-
 hw/intc/spapr_xive_kvm.c                      |  49 ++--
 hw/intc/xics.c                                |  31 +--
 hw/intc/xics_kvm.c                            |  28 +--
 hw/intc/xics_pnv.c                            |   6 +-
 hw/intc/xive.c                                |  23 +-
 hw/ipack/ipack.c                              |   4 +-
 hw/isa/pc87312.c                              |   6 +-
 hw/mem/memory-device.c                        |  19 +-
 hw/mem/nvdimm.c                               |  23 +-
 hw/mem/pc-dimm.c                              |  21 +-
 hw/microblaze/xlnx-zynqmp-pmu.c               |  11 +-
 hw/mips/cps.c                                 |  45 ++--
 hw/misc/arm11scu.c                            |   2 +
 hw/misc/bcm2835_mbox.c                        |   5 +-
 hw/misc/bcm2835_property.c                    |   9 +-
 hw/misc/ivshmem.c                             |  33 +--
 hw/misc/macio/macio.c                         |  65 ++----
 hw/misc/mps2-scc.c                            |   2 +
 hw/misc/tmp105.c                              |   6 +-
 hw/misc/tmp421.c                              |   6 +-
 hw/net/dp8393x.c                              |   6 +-
 hw/net/eepro100.c                             |   6 +-
 hw/net/ne2000-isa.c                           |  16 +-
 hw/net/xilinx_axienet.c                       |  21 +-
 hw/nvram/fw_cfg.c                             |  12 +-
 hw/nvram/nrf51_nvm.c                          |   6 +-
 hw/pci-bridge/dec.c                           |   2 +
 hw/pci-bridge/gen_pcie_root_port.c            |   6 +-
 hw/pci-bridge/pci_bridge_dev.c                |  12 +-
 hw/pci-bridge/pci_expander_bridge.c           |   6 +-
 hw/pci-bridge/pcie_pci_bridge.c               |   7 +-
 hw/pci-host/piix.c                            |   6 +-
 hw/pci/pci.c                                  |  17 +-
 hw/pci/pcie.c                                 |   6 +-
 hw/pci/shpc.c                                 |  12 +-
 hw/ppc/e500.c                                 |   6 +-
 hw/ppc/pnv.c                                  |  92 +++-----
 hw/ppc/pnv_core.c                             |  21 +-
 hw/ppc/pnv_lpc.c                              |  22 +-
 hw/ppc/pnv_occ.c                              |   4 +-
 hw/ppc/pnv_psi.c                              |  21 +-
 hw/ppc/spapr.c                                | 124 ++++------
 hw/ppc/spapr_caps.c                           |  50 ++--
 hw/ppc/spapr_cpu_core.c                       |  33 ++-
 hw/ppc/spapr_drc.c                            |  44 ++--
 hw/ppc/spapr_irq.c                            |  95 +++-----
 hw/ppc/spapr_pci.c                            |  88 +++----
 hw/ppc/spapr_vio.c                            |  11 +-
 hw/riscv/riscv_hart.c                         |   7 +-
 hw/riscv/sifive_e.c                           |   6 +-
 hw/riscv/sifive_u.c                           |  10 +-
 hw/s390x/3270-ccw.c                           |  12 +-
 hw/s390x/css-bridge.c                         |   6 +-
 hw/s390x/css.c                                |   6 +-
 hw/s390x/ipl.c                                |  23 +-
 hw/s390x/s390-ccw.c                           |  17 +-
 hw/s390x/s390-pci-bus.c                       |  34 ++-
 hw/s390x/s390-skeys.c                         |   6 +-
 hw/s390x/s390-virtio-ccw.c                    |  10 +-
 hw/s390x/sclp.c                               |  14 +-
 hw/s390x/tod-kvm.c                            |  13 +-
 hw/s390x/virtio-ccw-crypto.c                  |   6 +-
 hw/s390x/virtio-ccw-rng.c                     |   6 +-
 hw/s390x/virtio-ccw.c                         |  12 +-
 hw/scsi/esp-pci.c                             |   6 +-
 hw/scsi/megasas.c                             |  10 +-
 hw/scsi/mptsas.c                              |  12 +-
 hw/scsi/scsi-bus.c                            |  22 +-
 hw/scsi/scsi-disk.c                           |   6 +-
 hw/scsi/vhost-scsi.c                          |  11 +-
 hw/scsi/vhost-user-scsi.c                     |   6 +-
 hw/scsi/virtio-scsi.c                         |   6 +-
 hw/sd/milkymist-memcard.c                     |  10 +-
 hw/sd/sdhci-pci.c                             |   6 +-
 hw/sd/sdhci.c                                 |  20 +-
 hw/sd/ssi-sd.c                                |  13 +-
 hw/smbios/smbios.c                            |  41 ++--
 hw/sparc/sun4m.c                              |  18 +-
 hw/sparc64/sun4u.c                            |   6 +-
 hw/timer/aspeed_timer.c                       |   6 +-
 hw/tpm/tpm_util.c                             |   6 +-
 hw/usb/bus.c                                  |  33 +--
 hw/usb/dev-serial.c                           |   6 +-
 hw/usb/dev-smartcard-reader.c                 |  12 +-
 hw/usb/dev-storage.c                          |  16 +-
 hw/usb/hcd-ohci-pci.c                         |   6 +-
 hw/usb/hcd-ohci.c                             |  12 +-
 hw/usb/hcd-uhci.c                             |   6 +-
 hw/usb/hcd-xhci.c                             |  12 +-
 hw/vfio/ap.c                                  |   9 +-
 hw/vfio/ccw.c                                 |  23 +-
 hw/vfio/pci-quirks.c                          |   6 +-
 hw/vfio/pci.c                                 |  36 ++-
 hw/virtio/virtio-balloon.c                    |  33 ++-
 hw/virtio/virtio-bus.c                        |  16 +-
 hw/virtio/virtio-rng-pci.c                    |   6 +-
 hw/virtio/virtio-rng.c                        |   6 +-
 hw/virtio/virtio.c                            |  17 +-
 hw/watchdog/wdt_aspeed.c                      |   4 +-
 hw/xen/xen-backend.c                          |   6 +-
 hw/xen/xen-bus.c                              |  85 +++----
 hw/xen/xen-host-pci-device.c                  |  26 +--
 hw/xen/xen_pt.c                               |  24 +-
 hw/xen/xen_pt_config_init.c                   |  19 +-
 io/dns-resolver.c                             |   6 +-
 io/net-listener.c                             |   6 +-
 iothread.c                                    |  25 +-
 job.c                                         |   6 +-
 memory.c                                      |  54 ++---
 memory_mapping.c                              |   6 +-
 migration/colo.c                              |  33 +--
 migration/migration.c                         |  35 ++-
 migration/ram.c                               |  12 +-
 migration/rdma.c                              |  11 +-
 migration/socket.c                            |  16 +-
 monitor/hmp-cmds.c                            |   8 +-
 monitor/misc.c                                |   8 +-
 monitor/qmp-cmds.c                            |   6 +-
 net/can/can_host.c                            |   6 +-
 net/dump.c                                    |  14 +-
 net/filter-buffer.c                           |  14 +-
 net/filter.c                                  |   6 +-
 net/net.c                                     |  44 ++--
 net/netmap.c                                  |   6 +-
 net/slirp.c                                   |   6 +-
 net/tap-bsd.c                                 |   1 +
 net/tap-solaris.c                             |   1 +
 net/tap-stub.c                                |   1 +
 net/tap.c                                     |  44 ++--
 qapi/opts-visitor.c                           |   1 +
 qapi/qapi-dealloc-visitor.c                   |   8 +
 qapi/qapi-visit-core.c                        |  53 ++---
 qapi/qmp-dispatch.c                           |   6 +-
 qapi/string-input-visitor.c                   |   6 +-
 qdev-monitor.c                                |  37 ++-
 qga/commands-posix.c                          | 197 ++++++----------
 qga/commands-win32.c                          | 127 ++++------
 qom/object.c                                  | 187 ++++++---------
 qom/object_interfaces.c                       |  26 +--
 qom/qom-qobject.c                             |   6 +-
 replication.c                                 |  24 +-
 scsi/pr-manager-helper.c                      |   6 +-
 stubs/xen-hvm.c                               |   3 +
 target/alpha/cpu.c                            |   6 +-
 target/arm/cpu.c                              |   6 +-
 target/arm/cpu64.c                            |  10 +-
 target/cris/cpu.c                             |   6 +-
 target/hppa/cpu.c                             |   6 +-
 target/i386/cpu.c                             | 107 ++++-----
 target/lm32/cpu.c                             |   6 +-
 target/m68k/cpu.c                             |   6 +-
 target/microblaze/cpu.c                       |   6 +-
 target/mips/cpu.c                             |   6 +-
 target/moxie/cpu.c                            |   6 +-
 target/nios2/cpu.c                            |   6 +-
 target/openrisc/cpu.c                         |   6 +-
 target/ppc/compat.c                           |  18 +-
 target/ppc/kvm.c                              |   6 +-
 target/ppc/translate_init.inc.c               |  23 +-
 target/riscv/cpu.c                            |   6 +-
 target/s390x/cpu.c                            |  25 +-
 target/s390x/kvm-stub.c                       |   1 +
 target/sh4/cpu.c                              |   6 +-
 target/sparc/cpu.c                            |  12 +-
 target/tilegx/cpu.c                           |   6 +-
 target/tricore/cpu.c                          |   6 +-
 target/unicore32/cpu.c                        |   6 +-
 target/xtensa/cpu.c                           |   6 +-
 tests/test-image-locking.c                    |   6 +-
 tests/test-qmp-cmds.c                         |   7 +
 tpm.c                                         |   6 +-
 trace/qmp.c                                   |  12 +-
 ui/input-barrier.c                            |   6 +-
 ui/input.c                                    |  12 +-
 ui/vnc.c                                      |  27 +--
 util/error.c                                  |   8 +-
 util/main-loop.c                              |   4 +-
 util/oslib-posix.c                            |   5 +-
 util/qemu-config.c                            |  27 +--
 util/qemu-option.c                            |  50 ++--
 util/qemu-sockets.c                           |  25 +-
 vl.c                                          |  13 +-
 scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++
 319 files changed, 2729 insertions(+), 4245 deletions(-)
 create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
Signature · 1 line
2.21.0
#1 lore raw

RFC v2 1/9 error: auto propagated local_err

Here is introduced ERRP_FUNCTION_BEGIN macro, to be used at start of any function with errp parameter.

It has three goals:

1. Fix issue with error_fatal & error_append_hint: user can't see these hints, because exit() happens in error_setg earlier than hint is appended. [Reported by Greg Kurz]

2. Fix issue with error_abort & error_propagate: when we wrap error_abort by local_err+error_propagate, resulting coredump will refer to error_propagate and not to the place where error happened. (the macro itself don't fix the issue, but it allows to [3.] drop all local_err+error_propagate pattern, which will definitely fix the issue) [Reported by Kevin Wolf]

3. Drop local_err+error_propagate pattern, which is used to workaround void functions with errp parameter, when caller wants to know resulting status. (Note: actually these functions should be merely updated to return int error code).

---
 include/qapi/error.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
include/qapi/error.h +37 -0
index 3f95141a01..f6f4fa0fac 100644
@@ -322,6 +322,43 @@ void error_set_internal(Error **errp,
                         ErrorClass err_class, const char *fmt, ...)
     GCC_FMT_ATTR(6, 7);
 
+typedef struct ErrorPropagator {
+    Error *local_err;
+    Error **errp;
+} ErrorPropagator;
+
+static inline void error_propagator_cleanup(ErrorPropagator *prop)
+{
+    error_propagate(prop->errp, prop->local_err);
+}
+
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(ErrorPropagator, error_propagator_cleanup);
+
+/*
+ * ERRP_FUNCTION_BEGIN
+ *
+ * This macro MUST be the first line of EACH function with Error **errp
+ * parameter.
+ *
+ * If errp is NULL or points to error_fatal, it is rewritten to point to
+ * local Error object, which will be automatically propagated to original
+ * errp on function exit (see error_propagator_cleanup).
+ *
+ * After invocation of this macro it is always safe to dereference errp
+ * (as it's not NULL anymore) and to append hint (by error_append_hint)
+ * (as, if it was error_fatal, we swapped it by local_error to be
+ * propagated on cleanup).
+ *
+ * Note: we don't wrap error_abort case, as we want resulting coredump
+ * to point to the place where the error happened, not to error_propagate.
+ */
+#define ERRP_FUNCTION_BEGIN() \
+g_auto(ErrorPropagator) __auto_errp_prop = {.errp = errp}; \
+Error **__local_errp_unused __attribute__ ((unused)) = \
+    (errp = (errp == NULL || *errp == error_fatal ? \
+             &__auto_errp_prop.local_err : errp))
+
+
 /*
  * Special error destination to abort on error.
  * See error_setg() and error_propagate() for details.
Signature · 1 line
2.21.0
#2 lore raw
Quoted 5 lines · Vladimir Sementsov-Ogievskiy

Here is introduced ERRP_FUNCTION_BEGIN macro, to be used at start of any function with errp parameter.

It has three goals:

Quoted 8 lines

1. Fix issue with error_fatal & error_append_hint: user can't see these hints, because exit() happens in error_setg earlier than hint is appended. [Reported by Greg Kurz]

2. Fix issue with error_abort & error_propagate: when we wrap error_abort by local_err+error_propagate, resulting coredump will refer to error_propagate and not to the place where error happened. (the macro itself don't fix the issue, but it allows to [3.] drop all

doesn't

Quoted 6 lines

local_err+error_propagate pattern, which will definitely fix the issue) [Reported by Kevin Wolf]

3. Drop local_err+error_propagate pattern, which is used to workaround void functions with errp parameter, when caller wants to know resulting status. (Note: actually these functions should be merely updated to

Maybe:

s/should/could/

Quoted 22 lines

return int error code).

---
 include/qapi/error.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
include/qapi/error.h +7 -0
index 3f95141a01..f6f4fa0fac 100644
@@ -322,6 +322,43 @@ void error_set_internal(Error **errp,
                         ErrorClass err_class, const char *fmt, ...)
     GCC_FMT_ATTR(6, 7);
 
+typedef struct ErrorPropagator {
+    Error *local_err;
+    Error **errp;
+} ErrorPropagator;
+
+static inline void error_propagator_cleanup(ErrorPropagator *prop)
+{

include/qapi/error.h void error_set_internal(Error **errp, · line 341

Quoted 10 lines
include/qapi/error.h +10 -0
+    error_propagate(prop->errp, prop->local_err);
+}
+
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(ErrorPropagator, error_propagator_cleanup);
+
+/*
+ * ERRP_FUNCTION_BEGIN
+ *
+ * This macro MUST be the first line of EACH function with Error **errp
+ * parameter.

Maybe s/EACH function/ANY non-empty function/ (allowing our stub functions to be exemptions).

include/qapi/error.h void error_set_internal(Error **errp, · line 343

Quoted 2 lines
include/qapi/error.h +2 -0
+ *
+ * If errp is NULL or points to error_fatal, it is rewritten to point to

s/to/to a/

include/qapi/error.h void error_set_internal(Error **errp, · line 344

Quoted 1 line
include/qapi/error.h +1 -0
+ * local Error object, which will be automatically propagated to original

s/to/to the/

include/qapi/error.h void error_set_internal(Error **errp, · line 348

Quoted 4 lines
include/qapi/error.h +4 -0
+ * errp on function exit (see error_propagator_cleanup).
+ *
+ * After invocation of this macro it is always safe to dereference errp
+ * (as it's not NULL anymore) and to append hint (by error_append_hint)

s/append hint/append hints/

include/qapi/error.h void error_set_internal(Error **errp, · line 349

Quoted 1 line
include/qapi/error.h +1 -0
+ * (as, if it was error_fatal, we swapped it by local_error to be

s/by local_error/with a local error/

include/qapi/error.h void error_set_internal(Error **errp, · line 353

Quoted 4 lines
include/qapi/error.h +4 -0
+ * propagated on cleanup).
+ *
+ * Note: we don't wrap error_abort case, as we want resulting coredump
+ * to point to the place where the error happened, not to error_propagate.

s/wrap/wrap the/

include/qapi/error.h void error_set_internal(Error **errp, · line 359

Quoted 6 lines
include/qapi/error.h +6 -0
+ */
+#define ERRP_FUNCTION_BEGIN() \
+g_auto(ErrorPropagator) __auto_errp_prop = {.errp = errp}; \
+Error **__local_errp_unused __attribute__ ((unused)) = \
+    (errp = (errp == NULL || *errp == error_fatal ? \
+             &__auto_errp_prop.local_err : errp))

I'm not sold on why we need the dummy declaration (yeah, I know it's so that you don't have to fight the battle of mixing declarations and statements - but this is in a macro call whose usage LOOKS like a statement rather than a declaration, so we're already on fuzzy ground). We could make this macro expansion one line shorter and still be correct, but I'm not going to insist (we'll see what consensus is, and/or what Markus says).

Quoted 6 lines
include/qapi/error.h +2 -0
+
+
 /*
  * Special error destination to abort on error.
  * See error_setg() and error_propagate() for details.
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw

RFC v2 2/9 qapi/error: add (Error **errp) cleaning APIs

In reply to Vladimir Sementsov-Ogievskiy
---
 include/qapi/error.h | 22 ++++++++++++++++++++++
 util/error.c         |  6 +++---
 2 files changed, 25 insertions(+), 3 deletions(-)
include/qapi/error.h +22 -0
index f6f4fa0fac..551385aa91 100644
@@ -297,6 +297,28 @@ void warn_report_err(Error *err);
  */
 void error_report_err(Error *err);
 
+/*
+ * Functions to clean Error **errp: call corresponding Error *err cleaning
+ * function an set pointer to NULL
+ */
+static inline void error_free_errp(Error **errp)
+{
+    error_free(*errp_in);
+    *errp_in = NULL;
+}
+
+static inline void error_report_errp(Error **errp)
+{
+    error_report_err(*errp_in);
+    *errp_in = NULL;
+}
+
+static inline void warn_report_errp(Error **errp)
+{
+    warn_report_err(*errp_in);
+    *errp_in = NULL;
+}
+
 /*
  * Convenience function to error_prepend(), warn_report() and free @err.
  */
util/error.c +3 -3
index d4532ce318..dfba091757 100644
@@ -273,9 +273,9 @@ void error_free(Error *err)
 
 void error_free_or_abort(Error **errp)
 {
-    assert(errp && *errp);
-    error_free(*errp);
-    *errp = NULL;
+    assert(errp_in && *errp_in);
+    error_free(*errp_in);
+    *errp_in = NULL;
 }
 
 void error_propagate(Error **dst_errp, Error *local_err)
Signature · 1 line
2.21.0
#4 lore raw

Re: [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs

Quoted 2 lines · Vladimir Sementsov-Ogievskiy

---

A "why" as the commit message body wouldn't hurt.

Quoted 9 lines
 include/qapi/error.h | 22 ++++++++++++++++++++++
 util/error.c         |  6 +++---
 2 files changed, 25 insertions(+), 3 deletions(-)
include/qapi/error.h +0 -0
index f6f4fa0fac..551385aa91 100644

include/qapi/error.h void warn_report_err(Error *err); · line 302

Quoted 6 lines
include/qapi/error.h +3 -0
@@ -297,6 +297,28 @@ void warn_report_err(Error *err);
  */
 void error_report_err(Error *err);
 
+/*
+ * Functions to clean Error **errp: call corresponding Error *err cleaning
+ * function an set pointer to NULL

s/an/and/

include/qapi/error.h void warn_report_err(Error *err); · line 306

Quoted 4 lines
include/qapi/error.h +4 -0
+ */
+static inline void error_free_errp(Error **errp)
+{
+    error_free(*errp_in);

Fails to compile. Did you mean for this to come after 3/9?

Quoted 23 lines
include/qapi/error.h +15 -0
+    *errp_in = NULL;
+}
+
+static inline void error_report_errp(Error **errp)
+{
+    error_report_err(*errp_in);
+    *errp_in = NULL;
+}
+
+static inline void warn_report_errp(Error **errp)
+{
+    warn_report_err(*errp_in);
+    *errp_in = NULL;
+}
+
 /*
  * Convenience function to error_prepend(), warn_report() and free @err.
  */
util/error.c +0 -0
index d4532ce318..dfba091757 100644

util/error.c void error_free(Error *err) · line 278

Quoted 9 lines
util/error.c +3 -3
@@ -273,9 +273,9 @@ void error_free(Error *err)
 
 void error_free_or_abort(Error **errp)
 {
-    assert(errp && *errp);
-    error_free(*errp);
-    *errp = NULL;
+    assert(errp_in && *errp_in);
+    error_free(*errp_in);
+    *errp_in = NULL;

Did you mean to use error_free_errp() instead of these last two lines?

Quoted 4 lines
util/error.c +0 -0
 }
 
 void error_propagate(Error **dst_errp, Error *local_err)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#5 lore raw

RFC v2 3/9 errp: rename errp to errp_in where it is IN-argument

In reply to Vladimir Sementsov-Ogievskiy

Error **errp is almost always OUT-argument: it's assumed to be NULL, or pointer to NULL-initialized pointer, or pointer to error_abort or error_fatal, for callee to report error.

But very few functions (most of the are error API) instead get Error **errp as IN-argument: it's assumed to be set, and callee should clean it. In such cases, rename errp to errp_in.

---
 include/monitor/hmp.h |  2 +-
 include/qapi/error.h  |  8 ++++----
 ui/vnc.h              |  2 +-
 monitor/hmp-cmds.c    |  8 ++++----
 ui/vnc.c              | 10 +++++-----
 util/error.c          |  2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)
include/monitor/hmp.h +1 -1
index a0e9511440..f929814f1a 100644
@@ -16,7 +16,7 @@
 
 #include "qemu/readline.h"
 
-void hmp_handle_error(Monitor *mon, Error **errp);
+void hmp_handle_error(Monitor *mon, Error **errp_in);
 
 void hmp_info_name(Monitor *mon, const QDict *qdict);
 void hmp_info_version(Monitor *mon, const QDict *qdict);
include/qapi/error.h +4 -4
index 551385aa91..4264d22223 100644
@@ -283,7 +283,7 @@ void error_free(Error *err);
 /*
  * Convenience function to assert that *@errp is set, then silently free it.
  */
-void error_free_or_abort(Error **errp);
+void error_free_or_abort(Error **errp_in);
 
 /*
  * Convenience function to warn_report() and free @err.
@@ -301,19 +301,19 @@ void error_report_err(Error *err);
  * Functions to clean Error **errp: call corresponding Error *err cleaning
  * function an set pointer to NULL
  */
-static inline void error_free_errp(Error **errp)
+static inline void error_free_errp(Error **errp_in)
 {
     error_free(*errp_in);
     *errp_in = NULL;
 }
 
-static inline void error_report_errp(Error **errp)
+static inline void error_report_errp(Error **errp_in)
 {
     error_report_err(*errp_in);
     *errp_in = NULL;
 }
 
-static inline void warn_report_errp(Error **errp)
+static inline void warn_report_errp(Error **errp_in)
 {
     warn_report_err(*errp_in);
     *errp_in = NULL;
ui/vnc.h +1 -1
index fea79c2fc9..00e0b48f2f 100644
@@ -547,7 +547,7 @@ uint32_t read_u32(uint8_t *data, size_t offset);
 
 /* Protocol stage functions */
 void vnc_client_error(VncState *vs);
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp);
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp_in);
 
 void start_client_init(VncState *vs);
 void start_auth_vnc(VncState *vs);
monitor/hmp-cmds.c +4 -4
index b2551c16d1..941d5d0a45 100644
@@ -60,11 +60,11 @@
 #include <spice/enums.h>
 #endif
 
-void hmp_handle_error(Monitor *mon, Error **errp)
+void hmp_handle_error(Monitor *mon, Error **errp_in)
 {
-    assert(errp);
-    if (*errp) {
-        error_reportf_err(*errp, "Error: ");
+    assert(errp_in);
+    if (*errp_in) {
+        error_reportf_err(*errp_in, "Error: ");
     }
 }
 
ui/vnc.c +5 -5
index 87b8045afe..9d6384d9b1 100644
@@ -1312,7 +1312,7 @@ void vnc_disconnect_finish(VncState *vs)
     g_free(vs);
 }
 
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp_in)
 {
     if (ret <= 0) {
         if (ret == 0) {
@@ -1320,14 +1320,14 @@ size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
             vnc_disconnect_start(vs);
         } else if (ret != QIO_CHANNEL_ERR_BLOCK) {
             trace_vnc_client_io_error(vs, vs->ioc,
-                                      errp ? error_get_pretty(*errp) :
+                                      errp_in ? error_get_pretty(*errp_in) :
                                       "Unknown");
             vnc_disconnect_start(vs);
         }
 
-        if (errp) {
-            error_free(*errp);
-            *errp = NULL;
+        if (errp_in) {
+            error_free(*errp_in);
+            *errp_in = NULL;
         }
         return 0;
     }
util/error.c +1 -1
index dfba091757..b3ff3832d6 100644
@@ -271,7 +271,7 @@ void error_free(Error *err)
     }
 }
 
-void error_free_or_abort(Error **errp)
+void error_free_or_abort(Error **errp_in)
 {
     assert(errp_in && *errp_in);
     error_free(*errp_in);
Signature · 1 line
2.21.0
Reviewed-by on v2 3/9
#6 lore raw

Re: [RFC v2 3/9] errp: rename errp to errp_in where it is IN-argument

Quoted 9 lines · Vladimir Sementsov-Ogievskiy

Error **errp is almost always OUT-argument: it's assumed to be NULL, or pointer to NULL-initialized pointer, or pointer to error_abort or error_fatal, for callee to report error.

But very few functions (most of the are error API) instead get Error **errp as IN-argument: it's assumed to be set, and callee should clean it. In such cases, rename errp to errp_in.

Quoted 8 lines
---
 include/monitor/hmp.h |  2 +-
 include/qapi/error.h  |  8 ++++----
 ui/vnc.h              |  2 +-
 monitor/hmp-cmds.c    |  8 ++++----
 ui/vnc.c              | 10 +++++-----
 util/error.c          |  2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)

This is worthwhile, regardless of the fate of the rest of the series.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#7 lore raw

RFC v2 4/9 hw/core/loader-fit: fix freeing errp in fit_load_fdt

In reply to Vladimir Sementsov-Ogievskiy

fit_load_fdt forget to zero errp. Fix it.

---
 hw/core/loader-fit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/loader-fit.c +1 -1
index 953b16bc82..fe5bcc6700 100644
@@ -200,7 +200,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
     err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
     if (err == -ENOENT) {
         load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
-        error_free(*errp);
+        error_free_errp(errp);
     } else if (err) {
         error_prepend(errp, "unable to read FDT load address from FIT: ");
         ret = err;
Signature · 1 line
2.21.0
Reviewed-by on v2 4/9
#8 lore raw

Re: [RFC v2 4/9] hw/core/loader-fit: fix freeing errp in fit_load_fdt

Quoted 7 lines · Vladimir Sementsov-Ogievskiy

fit_load_fdt forget to zero errp. Fix it.

---
 hw/core/loader-fit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Independent bug fix. Either we take the (fixed) 2-3 (to rely on the new error_free_errp), or you could open-code the assignment of errp=NULL to take this on its own, regardless of the hfate of the rest of the series.

Quoted 14 lines
hw/core/loader-fit.c +1 -1
index 953b16bc82..fe5bcc6700 100644
@@ -200,7 +200,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
     err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
     if (err == -ENOENT) {
         load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
-        error_free(*errp);
+        error_free_errp(errp);
     } else if (err) {
         error_prepend(errp, "unable to read FDT load address from FIT: ");
         ret = err;
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#9 lore raw

RFC v2 5/9 net/net: fix local variable shadowing in net_client_init

In reply to Vladimir Sementsov-Ogievskiy

Don't shadow Error *err: it's a bad thing. This patch also simplifies following Error propagation conversion.

---
 net/net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/net.c +3 -3
index 84aa6d8d00..5fc72511c1 100644
@@ -1128,10 +1128,10 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
 
             if (substrings[1]) {
                 /* User-specified prefix length.  */
-                int err;
+                int ret2;
 
-                err = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
-                if (err) {
+                ret2 = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
+                if (ret2) {
                     error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                                "ipv6-prefixlen", "a number");
                     goto out;
Signature · 1 line
2.21.0
Reviewed-by on v2 5/9
#10 lore raw

Re: [RFC v2 5/9] net/net: fix local variable shadowing in net_client_init

Quoted 7 lines · Vladimir Sementsov-Ogievskiy

Don't shadow Error *err: it's a bad thing. This patch also simplifies following Error propagation conversion.

---
 net/net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Can be applied independently of the rest of this series.

Quoted 6 lines
net/net.c +0 -0
index 84aa6d8d00..5fc72511c1 100644

net/net.c static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) · line 1134

Quoted 10 lines
net/net.c +3 -3
@@ -1128,10 +1128,10 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
 
             if (substrings[1]) {
                 /* User-specified prefix length.  */
-                int err;
+                int ret2;
 
-                err = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
-                if (err) {
+                ret2 = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
+                if (ret2) {

In fact, you don't need ret2; you could just:

if (qemu_strtoul(...)) {

at which point you could then join:

if (substrings[1] &&

    qemus_strtoul(...)) {

net/net.c static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) · line 1137

Quoted 4 lines
net/net.c +0 -0
                     error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                                "ipv6-prefixlen", "a number");
                     goto out;

Either way,

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#11 lore raw

RFC v2 6/9 scripts: add coccinelle script to use auto propagated errp

In reply to Vladimir Sementsov-Ogievskiy
---
 scripts/coccinelle/auto-propagated-errp.cocci | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
scripts/coccinelle/auto-propagated-errp.cocci new file +82 -0
new file mode 100644
index 0000000000..1a3f006f0b
@@ -0,0 +1,82 @@
+@@
+identifier fn;
+identifier local_err;
+@@
+
+ fn(..., Error **errp)
+ {
++    ERRP_FUNCTION_BEGIN();
+ }
+
+@rule1@
+identifier fn;
+identifier local_err;
+@@
+
+ fn(..., Error **errp)
+ {
+     <...
+-    Error *local_err = NULL;
+     ...>
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+identifier out;
+@@
+
+ fn(...)
+ {
+     <...
+-    goto out;
++    return;
+     ...>
+- out:
+-    error_propagate(errp, local_err);
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {
+     <...
+(
+-    error_free(local_err);
+-    local_err = NULL;
++    error_free_errp(errp);
+|
+-    error_free(local_err);
++    error_free_errp(errp);
+|
+-    error_report_err(local_err);
++    error_report_errp(errp);
+|
+-    warn_report_err(local_err);
++    warn_report_errp(errp);
+|
+-    error_propagate(errp, local_err);
+)
+     ...>
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {
+     <...
+(
+-    &local_err
++    errp
+|
+-    local_err
++    *errp
+)
+     ...>
+ }
Signature · 1 line
2.21.0
#12 lore raw

Re: [RFC v2 6/9] scripts: add coccinelle script to use auto propagated errp

Quoted 12 lines · Vladimir Sementsov-Ogievskiy
---
 scripts/coccinelle/auto-propagated-errp.cocci | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci
scripts/coccinelle/auto-propagated-errp.cocci new file +0 -0
new file mode 100644
index 0000000000..1a3f006f0b

scripts/coccinelle/auto-propagated-errp.cocci line 9

Quoted 9 lines
scripts/coccinelle/auto-propagated-errp.cocci new file +9 -0
@@ -0,0 +1,82 @@
+@@
+identifier fn;
+identifier local_err;
+@@
+
+ fn(..., Error **errp)
+ {
++    ERRP_FUNCTION_BEGIN();
+ }

This doesn't catch functions where Error **errp is not the last parameter. Some examples (some of which may need independent tweaking in their own right for being inconsistent, although we DO want errp to appear before any 'format, ...' arguments):

block/ssh.c:sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
exec.c:static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)

Does running this Coccinelle script 2 times in a row add a second ERRP_FUNCTION_BEGIN() line? We want it to be idempotent (no changes on a second run). (Admittedly, I did not actually test that yet). Also, I don't know if this can be tweaked to avoid adding the line to a function with an empty body, maybe:

fn(..., Error **errp, ...)
{

+    ERRP_FUNCTION_BEGIN();
     ...

}

to only add it to a function that already has a body (thanks to the ...)
- but I'm fuzzy enough on Coccinelle that I may be saying something totally wrong.

Quoted 64 lines
scripts/coccinelle/auto-propagated-errp.cocci new file +63 -0
+
+@rule1@
+identifier fn;
+identifier local_err;
+@@
+
+ fn(..., Error **errp)
+ {
+     <...
+-    Error *local_err = NULL;
+     ...>
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+identifier out;
+@@
+
+ fn(...)
+ {
+     <...
+-    goto out;
++    return;
+     ...>
+- out:
+-    error_propagate(errp, local_err);
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {
+     <...
+(
+-    error_free(local_err);
+-    local_err = NULL;
++    error_free_errp(errp);
+|
+-    error_free(local_err);
++    error_free_errp(errp);
+|
+-    error_report_err(local_err);
++    error_report_errp(errp);
+|
+-    warn_report_err(local_err);
++    warn_report_errp(errp);
+|
+-    error_propagate(errp, local_err);
+)
+     ...>
+ }
+
+@@
+identifier rule1.fn;
+identifier rule1.local_err;
+@@
+
+ fn(...)
+ {

scripts/coccinelle/auto-propagated-errp.cocci line 82

Quoted 10 lines
scripts/coccinelle/auto-propagated-errp.cocci new file +10 -0
+     <...
+(
+-    &local_err
++    errp
+|
+-    local_err
++    *errp
+)
+     ...>
+ }

Overall, the script makes sense in my reading (but no idea if it actually catches everything we want, or if it missed something). At any rate, once patch 7 is split into more manageable chunks, we can definitely spot-check results to make sure they all look reasonable.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#13 lore raw

Re: [RFC v2 6/9] scripts: add coccinelle script to use auto propagated errp

Quoted 11 lines · Eric Blake

Does running this Coccinelle script 2 times in a row add a second ERRP_FUNCTION_BEGIN() line? We want it to be idempotent (no changes on a second run). (Admittedly, I did not actually test that yet). Also, I don't know if this can be tweaked to avoid adding the line to a function with an empty body, maybe:

fn(..., Error **errp, ...)
{

+    ERRP_FUNCTION_BEGIN();
     ...

}

Also untested:

fn(..., Error **errp, ...)
{
(
|

     ERRP_FUNCTION_BEGIN();
     ...
|
+    ERRP_FUNCTION_BEGIN()
     ...

)
}

Quoted 2 lines

Overall, the script makes sense in my reading (but no idea if it actually catches everything we want, or if it missed something).

Having spot-checked 7, it definitely misses cases where it was supposed to add ERRP_FUNCTION_BEGIN().

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#14 lore raw

Re: [RFC v2 6/9] scripts: add coccinelle script to use auto propagated errp

Quoted 8 lines · Eric Blake
Quoted 6 lines · Eric Blake

Does running this Coccinelle script 2 times in a row add a second ERRP_FUNCTION_BEGIN() line? We want it to be idempotent (no changes on a second run). (Admittedly, I did not actually test that yet). Also, I don't know if this can be tweaked to avoid adding the line to a function with an empty body, maybe:

Quoted 5 lines
Quoted 5 lines

fn(..., Error **errp, ...)
{

+    ERRP_FUNCTION_BEGIN();
      ...

}

No, we need exactly this to match not only empty functions. But with ... it matches empty functions as well.

Quoted 7 lines

Also untested:

fn(..., Error **errp, ...)
{
(
|

Quoted 7 lines
      ERRP_FUNCTION_BEGIN();
      ...
|
+    ERRP_FUNCTION_BEGIN()
      ...

)
}

Seems, that doesn't work..

It says:
12: no available token to attach to

where 12 is line "+ ERRP_FUNCTION_BEGIN()"

So, I tend to just add chunk to remove duplicated invocation :)

Quoted 8 lines
Quoted 4 lines

Overall, the script makes sense in my reading (but no idea if it actually catches everything we want, or if it missed something).

Having spot-checked 7, it definitely misses cases where it was supposed to add ERRP_FUNCTION_BEGIN().

Signature · 2 lines
Best regards,
Vladimir
#15 lore raw

RFC v2 7/9 Use auto-propagated errp

In reply to Vladimir Sementsov-Ogievskiy

This commit is generated by command

git grep -l 'Error \*\*errp' | while read f; \
do spatch --sp-file \
scripts/coccinelle/auto-propagated-errp.cocci --in-place $f; done

---
 include/hw/pci-host/spapr.h         |   2 +
 target/ppc/kvm_ppc.h                |   1 +
 target/s390x/cpu_models.h           |   2 +
 audio/audio.c                       |  12 +-
 authz/pamacct.c                     |   1 +
 backends/cryptodev-vhost-user.c     |   9 +-
 backends/cryptodev.c                |  19 +--
 backends/hostmem-file.c             |  19 +--
 backends/hostmem-memfd.c            |  17 +--
 backends/hostmem.c                  |  38 ++---
 backends/rng.c                      |   6 +-
 block.c                             | 208 ++++++++++----------------
 block/blkdebug.c                    |  33 ++---
 block/blklogwrites.c                |  21 +--
 block/blkreplay.c                   |   6 +-
 block/blkverify.c                   |  16 +-
 block/block-backend.c               |  17 +--
 block/commit.c                      |   6 +-
 block/crypto.c                      |  12 +-
 block/curl.c                        |   6 +-
 block/file-posix.c                  |  71 ++++-----
 block/file-win32.c                  |  27 ++--
 block/gluster.c                     |  64 ++++----
 block/io.c                          |  11 +-
 block/iscsi.c                       |  33 ++---
 block/mirror.c                      |  17 +--
 block/nbd.c                         |  44 +++---
 block/nfs.c                         |   6 +-
 block/nvme.c                        |  17 +--
 block/parallels.c                   |  28 ++--
 block/qapi.c                        |  23 +--
 block/qcow.c                        |  15 +-
 block/qcow2-bitmap.c                |   6 +-
 block/qcow2.c                       |  90 +++++-------
 block/qed.c                         |  16 +-
 block/quorum.c                      |  22 ++-
 block/raw-format.c                  |   6 +-
 block/rbd.c                         |  25 +---
 block/replication.c                 |  36 ++---
 block/sheepdog.c                    |  66 ++++-----
 block/snapshot.c                    |  14 +-
 block/ssh.c                         |  11 +-
 block/throttle-groups.c             |  22 ++-
 block/throttle.c                    |   6 +-
 block/vdi.c                         |  12 +-
 block/vhdx.c                        |  20 +--
 block/vmdk.c                        |  36 ++---
 block/vpc.c                         |  25 ++--
 block/vvfat.c                       |  11 +-
 block/vxhs.c                        |  22 ++-
 blockdev.c                          | 220 ++++++++++------------------
 blockjob.c                          |   7 +-
 bootdevice.c                        |  29 ++--
 chardev/char-socket.c               |   6 +-
 chardev/char.c                      |  18 +--
 crypto/block-luks.c                 |  31 ++--
 crypto/secret.c                     |  16 +-
 crypto/tlssession.c                 |   6 +-
 dump/dump.c                         | 142 +++++++-----------
 dump/win_dump.c                     |  27 ++--
 exec.c                              |  12 +-
 hw/9pfs/9p-local.c                  |   7 +-
 hw/acpi/core.c                      |  17 +--
 hw/acpi/ich9.c                      |  27 ++--
 hw/acpi/memory_hotplug.c            |   6 +-
 hw/arm/allwinner-a10.c              |  26 ++--
 hw/arm/armv7m.c                     |  51 +++----
 hw/arm/bcm2835_peripherals.c        |  84 +++++------
 hw/arm/bcm2836.c                    |  40 ++---
 hw/arm/digic.c                      |  21 +--
 hw/arm/fsl-imx25.c                  |  61 +++-----
 hw/arm/fsl-imx31.c                  |  56 +++----
 hw/arm/fsl-imx6.c                   |  80 ++++------
 hw/arm/integratorcp.c               |   6 +-
 hw/arm/msf2-soc.c                   |  21 +--
 hw/arm/nrf51_soc.c                  |  46 +++---
 hw/arm/smmu-common.c                |   6 +-
 hw/arm/smmuv3.c                     |   6 +-
 hw/arm/stm32f205_soc.c              |  38 ++---
 hw/arm/tosa.c                       |   1 +
 hw/arm/xlnx-versal-virt.c           |   6 +-
 hw/arm/xlnx-zynqmp.c                |  84 +++++------
 hw/audio/intel-hda.c                |  12 +-
 hw/block/dataplane/xen-block.c      |  16 +-
 hw/block/fdc.c                      |  17 +--
 hw/block/onenand.c                  |   6 +-
 hw/block/pflash_cfi01.c             |   6 +-
 hw/block/pflash_cfi02.c             |   6 +-
 hw/block/vhost-user-blk.c           |   5 +-
 hw/block/virtio-blk.c               |   6 +-
 hw/block/xen-block.c                | 114 ++++++--------
 hw/char/debugcon.c                  |   6 +-
 hw/char/serial-pci-multi.c          |   6 +-
 hw/char/serial-pci.c                |   6 +-
 hw/char/virtio-serial-bus.c         |   6 +-
 hw/core/bus.c                       |  14 +-
 hw/core/machine.c                   |  18 +--
 hw/core/numa.c                      |  48 +++---
 hw/core/qdev-properties-system.c    |  24 +--
 hw/core/qdev-properties.c           |  78 ++++------
 hw/core/qdev.c                      |  36 ++---
 hw/core/sysbus.c                    |   1 +
 hw/cpu/a15mpcore.c                  |   6 +-
 hw/cpu/a9mpcore.c                   |  26 ++--
 hw/cpu/arm11mpcore.c                |  21 +--
 hw/cpu/core.c                       |  12 +-
 hw/cpu/realview_mpcore.c            |  11 +-
 hw/display/bcm2835_fb.c             |   5 +-
 hw/display/qxl.c                    |   6 +-
 hw/display/virtio-gpu-base.c        |   6 +-
 hw/display/virtio-gpu-pci.c         |   6 +-
 hw/display/virtio-vga.c             |   6 +-
 hw/dma/bcm2835_dma.c                |   5 +-
 hw/dma/xilinx_axidma.c              |  14 +-
 hw/gpio/aspeed_gpio.c               |   6 +-
 hw/gpio/bcm2835_gpio.c              |   9 +-
 hw/i386/kvm/apic.c                  |   1 +
 hw/i386/pc.c                        | 109 +++++---------
 hw/ide/qdev.c                       |  15 +-
 hw/input/virtio-input.c             |  12 +-
 hw/intc/apic_common.c               |   6 +-
 hw/intc/arm_gic.c                   |   6 +-
 hw/intc/arm_gic_kvm.c               |  11 +-
 hw/intc/arm_gicv3.c                 |  11 +-
 hw/intc/arm_gicv3_its_kvm.c         |   6 +-
 hw/intc/arm_gicv3_kvm.c             |  16 +-
 hw/intc/armv7m_nvic.c               |  11 +-
 hw/intc/nios2_iic.c                 |   5 +-
 hw/intc/pnv_xive.c                  |  14 +-
 hw/intc/realview_gic.c              |   6 +-
 hw/intc/s390_flic_kvm.c             |  10 +-
 hw/intc/spapr_xive.c                |  11 +-
 hw/intc/spapr_xive_kvm.c            |  49 +++----
 hw/intc/xics.c                      |  31 ++--
 hw/intc/xics_kvm.c                  |  28 ++--
 hw/intc/xics_pnv.c                  |   6 +-
 hw/intc/xive.c                      |  23 +--
 hw/ipack/ipack.c                    |   4 +-
 hw/isa/pc87312.c                    |   6 +-
 hw/mem/memory-device.c              |  19 +--
 hw/mem/nvdimm.c                     |  23 ++-
 hw/mem/pc-dimm.c                    |  21 +--
 hw/microblaze/xlnx-zynqmp-pmu.c     |  11 +-
 hw/mips/cps.c                       |  45 +++---
 hw/misc/arm11scu.c                  |   1 +
 hw/misc/bcm2835_mbox.c              |   5 +-
 hw/misc/bcm2835_property.c          |   9 +-
 hw/misc/ivshmem.c                   |  33 ++---
 hw/misc/macio/macio.c               |  65 ++++----
 hw/misc/mps2-scc.c                  |   1 +
 hw/misc/tmp105.c                    |   6 +-
 hw/misc/tmp421.c                    |   6 +-
 hw/net/dp8393x.c                    |   6 +-
 hw/net/eepro100.c                   |   6 +-
 hw/net/ne2000-isa.c                 |  16 +-
 hw/net/xilinx_axienet.c             |  14 +-
 hw/nvram/fw_cfg.c                   |  12 +-
 hw/nvram/nrf51_nvm.c                |   6 +-
 hw/pci-bridge/dec.c                 |   1 +
 hw/pci-bridge/gen_pcie_root_port.c  |   6 +-
 hw/pci-bridge/pci_bridge_dev.c      |  12 +-
 hw/pci-bridge/pci_expander_bridge.c |   6 +-
 hw/pci-bridge/pcie_pci_bridge.c     |   7 +-
 hw/pci-host/piix.c                  |   6 +-
 hw/pci/pci.c                        |  17 +--
 hw/pci/pcie.c                       |   6 +-
 hw/pci/shpc.c                       |  12 +-
 hw/ppc/e500.c                       |   6 +-
 hw/ppc/pnv.c                        |  92 +++++-------
 hw/ppc/pnv_core.c                   |  21 +--
 hw/ppc/pnv_lpc.c                    |  22 +--
 hw/ppc/pnv_occ.c                    |   4 +-
 hw/ppc/pnv_psi.c                    |  21 +--
 hw/ppc/spapr.c                      | 121 +++++++--------
 hw/ppc/spapr_caps.c                 |  50 +++----
 hw/ppc/spapr_cpu_core.c             |  30 ++--
 hw/ppc/spapr_drc.c                  |  44 ++----
 hw/ppc/spapr_irq.c                  |  95 +++++-------
 hw/ppc/spapr_pci.c                  |  88 +++++------
 hw/ppc/spapr_vio.c                  |  11 +-
 hw/riscv/riscv_hart.c               |   7 +-
 hw/riscv/sifive_e.c                 |   6 +-
 hw/riscv/sifive_u.c                 |  10 +-
 hw/s390x/3270-ccw.c                 |  12 +-
 hw/s390x/css-bridge.c               |   6 +-
 hw/s390x/css.c                      |   6 +-
 hw/s390x/ipl.c                      |  23 ++-
 hw/s390x/s390-ccw.c                 |  14 +-
 hw/s390x/s390-pci-bus.c             |  34 ++---
 hw/s390x/s390-skeys.c               |   6 +-
 hw/s390x/s390-virtio-ccw.c          |  10 +-
 hw/s390x/sclp.c                     |  14 +-
 hw/s390x/tod-kvm.c                  |  13 +-
 hw/s390x/virtio-ccw-crypto.c        |   6 +-
 hw/s390x/virtio-ccw-rng.c           |   6 +-
 hw/s390x/virtio-ccw.c               |  12 +-
 hw/scsi/esp-pci.c                   |   6 +-
 hw/scsi/megasas.c                   |  10 +-
 hw/scsi/mptsas.c                    |  12 +-
 hw/scsi/scsi-bus.c                  |  22 +--
 hw/scsi/scsi-disk.c                 |   6 +-
 hw/scsi/vhost-scsi.c                |  11 +-
 hw/scsi/vhost-user-scsi.c           |   6 +-
 hw/scsi/virtio-scsi.c               |   6 +-
 hw/sd/milkymist-memcard.c           |  10 +-
 hw/sd/sdhci-pci.c                   |   6 +-
 hw/sd/sdhci.c                       |  20 +--
 hw/sd/ssi-sd.c                      |  13 +-
 hw/smbios/smbios.c                  |  41 ++----
 hw/sparc/sun4m.c                    |  18 +--
 hw/sparc64/sun4u.c                  |   6 +-
 hw/timer/aspeed_timer.c             |   6 +-
 hw/tpm/tpm_util.c                   |   6 +-
 hw/usb/bus.c                        |  33 ++---
 hw/usb/dev-serial.c                 |   6 +-
 hw/usb/dev-smartcard-reader.c       |  12 +-
 hw/usb/dev-storage.c                |  16 +-
 hw/usb/hcd-ohci-pci.c               |   6 +-
 hw/usb/hcd-ohci.c                   |  12 +-
 hw/usb/hcd-uhci.c                   |   6 +-
 hw/usb/hcd-xhci.c                   |  12 +-
 hw/vfio/ap.c                        |   6 +-
 hw/vfio/ccw.c                       |  20 ++-
 hw/vfio/pci-quirks.c                |   6 +-
 hw/vfio/pci.c                       |  36 ++---
 hw/virtio/virtio-balloon.c          |  33 ++---
 hw/virtio/virtio-bus.c              |  16 +-
 hw/virtio/virtio-rng-pci.c          |   6 +-
 hw/virtio/virtio-rng.c              |   6 +-
 hw/virtio/virtio.c                  |  17 +--
 hw/watchdog/wdt_aspeed.c            |   4 +-
 hw/xen/xen-backend.c                |   6 +-
 hw/xen/xen-bus.c                    |  85 +++++------
 hw/xen/xen-host-pci-device.c        |  26 ++--
 hw/xen/xen_pt.c                     |  24 ++-
 hw/xen/xen_pt_config_init.c         |  19 ++-
 io/dns-resolver.c                   |   6 +-
 io/net-listener.c                   |   6 +-
 iothread.c                          |  25 ++--
 job.c                               |   6 +-
 memory.c                            |  54 +++----
 memory_mapping.c                    |   6 +-
 migration/colo.c                    |  33 ++---
 migration/migration.c               |  35 ++---
 migration/ram.c                     |  12 +-
 migration/rdma.c                    |  11 +-
 migration/socket.c                  |  16 +-
 monitor/misc.c                      |   8 +-
 monitor/qmp-cmds.c                  |   6 +-
 net/can/can_host.c                  |   6 +-
 net/dump.c                          |  14 +-
 net/filter-buffer.c                 |  14 +-
 net/filter.c                        |   6 +-
 net/net.c                           |  38 ++---
 net/netmap.c                        |   6 +-
 net/slirp.c                         |   6 +-
 net/tap-bsd.c                       |   1 +
 net/tap-solaris.c                   |   1 +
 net/tap-stub.c                      |   1 +
 net/tap.c                           |  44 ++----
 qapi/opts-visitor.c                 |   1 +
 qapi/qapi-dealloc-visitor.c         |   7 +
 qapi/qapi-visit-core.c              |  53 ++-----
 qapi/qmp-dispatch.c                 |   6 +-
 qapi/string-input-visitor.c         |   6 +-
 qdev-monitor.c                      |  37 ++---
 qga/commands-posix.c                | 197 ++++++++++---------------
 qga/commands-win32.c                | 127 ++++++----------
 qom/object.c                        | 187 +++++++++--------------
 qom/object_interfaces.c             |  26 ++--
 qom/qom-qobject.c                   |   6 +-
 replication.c                       |  24 +--
 scsi/pr-manager-helper.c            |   6 +-
 stubs/xen-hvm.c                     |   2 +
 target/alpha/cpu.c                  |   6 +-
 target/arm/cpu.c                    |   6 +-
 target/arm/cpu64.c                  |  10 +-
 target/cris/cpu.c                   |   6 +-
 target/hppa/cpu.c                   |   6 +-
 target/i386/cpu.c                   | 107 ++++++--------
 target/lm32/cpu.c                   |   6 +-
 target/m68k/cpu.c                   |   6 +-
 target/microblaze/cpu.c             |   6 +-
 target/mips/cpu.c                   |   6 +-
 target/moxie/cpu.c                  |   6 +-
 target/nios2/cpu.c                  |   6 +-
 target/openrisc/cpu.c               |   6 +-
 target/ppc/compat.c                 |  18 +--
 target/ppc/kvm.c                    |   6 +-
 target/ppc/translate_init.inc.c     |  23 +--
 target/riscv/cpu.c                  |   6 +-
 target/s390x/cpu.c                  |  25 ++--
 target/s390x/kvm-stub.c             |   1 +
 target/sh4/cpu.c                    |   6 +-
 target/sparc/cpu.c                  |  12 +-
 target/tilegx/cpu.c                 |   6 +-
 target/tricore/cpu.c                |   6 +-
 target/unicore32/cpu.c              |   6 +-
 target/xtensa/cpu.c                 |   6 +-
 tests/test-image-locking.c          |   6 +-
 tests/test-qmp-cmds.c               |   7 +
 tpm.c                               |   6 +-
 trace/qmp.c                         |  12 +-
 ui/input-barrier.c                  |   6 +-
 ui/input.c                          |  12 +-
 ui/vnc.c                            |  17 +--
 util/main-loop.c                    |   4 +-
 util/oslib-posix.c                  |   5 +-
 util/qemu-config.c                  |  27 ++--
 util/qemu-option.c                  |  50 +++----
 util/qemu-sockets.c                 |  25 +---
 vl.c                                |  13 +-
 312 files changed, 2551 insertions(+), 4199 deletions(-)
include/hw/pci-host/spapr.h +2 -0
index abd87605b2..3498635302 100644
@@ -193,6 +193,7 @@ static inline void spapr_phb_vfio_reset(DeviceState *qdev)
 }
 static inline void spapr_phb_nvgpu_setup(SpaprPhbState *sphb, Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
 }
 static inline void spapr_phb_nvgpu_free(SpaprPhbState *sphb)
 {
@@ -200,6 +201,7 @@ static inline void spapr_phb_nvgpu_free(SpaprPhbState *sphb)
 static inline void spapr_phb_nvgpu_populate_dt(SpaprPhbState *sphb, void *fdt,
                                                int bus_off, Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
 }
 static inline void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb,
                                                    void *fdt)
target/ppc/kvm_ppc.h +1 -0
index 98bd7d5da6..807c245e90 100644
@@ -254,6 +254,7 @@ static inline bool kvmppc_hpt_needs_host_contiguous_pages(void)
 
 static inline void kvm_check_mmu(PowerPCCPU *cpu, Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
 }
 
 static inline bool kvmppc_has_cap_spapr_vfio(void)
target/s390x/cpu_models.h +2 -0
index 88bd01a616..5329045a71 100644
@@ -114,10 +114,12 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model,  Error **errp);
 static inline void kvm_s390_get_host_cpu_model(S390CPUModel *model,
                                                Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
 }
 static inline void kvm_s390_apply_cpu_model(const S390CPUModel *model,
                                             Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
 }
 static inline bool kvm_s390_cpu_models_supported(void)
 {
audio/audio.c +4 -8
index e99fcd0694..bc5dd86522 100644
@@ -1739,19 +1739,15 @@ static void audio_validate_per_direction_opts(
 
 static void audio_validate_opts(Audiodev *dev, Error **errp)
 {
-    Error *err = NULL;
-
     audio_create_pdos(dev);
 
-    audio_validate_per_direction_opts(audio_get_pdo_in(dev), &err);
-    if (err) {
-        error_propagate(errp, err);
+    audio_validate_per_direction_opts(audio_get_pdo_in(dev), errp);
+    if (*errp) {
         return;
     }
 
-    audio_validate_per_direction_opts(audio_get_pdo_out(dev), &err);
-    if (err) {
-        error_propagate(errp, err);
+    audio_validate_per_direction_opts(audio_get_pdo_out(dev), errp);
+    if (*errp) {
         return;
     }
 
authz/pamacct.c +1 -0
index a8ad25b6c7..bf903b6736 100644
@@ -84,6 +84,7 @@ qauthz_pam_prop_get_service(Object *obj,
 static void
 qauthz_pam_complete(UserCreatable *uc, Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
 }
 
 
backends/cryptodev-vhost-user.c +3 -6
index b344283940..db32391df0 100644
@@ -179,15 +179,13 @@ static void cryptodev_vhost_user_init(
 {
     int queues = backend->conf.peers.queues;
     size_t i;
-    Error *local_err = NULL;
     Chardev *chr;
     CryptoDevBackendClient *cc;
     CryptoDevBackendVhostUser *s =
                       CRYPTODEV_BACKEND_VHOST_USER(backend);
 
-    chr = cryptodev_vhost_claim_chardev(s, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    chr = cryptodev_vhost_claim_chardev(s, errp);
+    if (*errp) {
         return;
     }
 
@@ -204,8 +202,7 @@ static void cryptodev_vhost_user_init(
         backend->conf.peers.ccs[i] = cc;
 
         if (i == 0) {
-            if (!qemu_chr_fe_init(&s->chr, chr, &local_err)) {
-                error_propagate(errp, local_err);
+            if (!qemu_chr_fe_init(&s->chr, chr, errp)) {
                 return;
             }
         }
backends/cryptodev.c +7 -12
index 3c071eab95..dcdb8481b2 100644
@@ -154,21 +154,18 @@ cryptodev_backend_set_queues(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
     CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
-    Error *local_err = NULL;
     uint32_t value;
 
-    visit_type_uint32(v, name, &value, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_uint32(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     if (!value) {
-        error_setg(&local_err, "Property '%s.%s' doesn't take value '%"
+        error_setg(errp, "Property '%s.%s' doesn't take value '%"
                    PRIu32 "'", object_get_typename(obj), name, value);
-        goto out;
+        return;
     }
     backend->conf.peers.queues = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void
@@ -176,11 +173,10 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
 {
     CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
     CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
-    Error *local_err = NULL;
 
     if (bc->init) {
-        bc->init(backend, &local_err);
-        if (local_err) {
+        bc->init(backend, errp);
+        if (*errp) {
             goto out;
         }
     }
@@ -188,7 +184,6 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
     return;
 
 out:
-    error_propagate(errp, local_err);
 }
 
 void cryptodev_backend_set_used(CryptoDevBackend *backend, bool used)
backends/hostmem-file.c +6 -13
index be64020746..c59c92a031 100644
@@ -118,23 +118,19 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,
 {
     HostMemoryBackend *backend = MEMORY_BACKEND(o);
     HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
-    Error *local_err = NULL;
     uint64_t val;
 
     if (host_memory_backend_mr_inited(backend)) {
-        error_setg(&local_err, "cannot change property '%s' of %s",
+        error_setg(errp, "cannot change property '%s' of %s",
                    name, object_get_typename(o));
-        goto out;
+        return;
     }
 
-    visit_type_size(v, name, &val, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_size(v, name, &val, errp);
+    if (*errp) {
+        return;
     }
     fb->align = val;
-
- out:
-    error_propagate(errp, local_err);
 }
 
 static bool file_memory_backend_get_pmem(Object *o, Error **errp)
@@ -156,13 +152,10 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
 
 #ifndef CONFIG_LIBPMEM
     if (value) {
-        Error *local_err = NULL;
-
-        error_setg(&local_err,
+        error_setg(errp,
                    "Lack of libpmem support while setting the 'pmem=on'"
                    " of %s. We can't ensure data persistence.",
                    object_get_typename(o));
-        error_propagate(errp, local_err);
         return;
     }
 #endif
backends/hostmem-memfd.c +7 -10
index 26070b425e..2de7e8687b 100644
@@ -78,26 +78,23 @@ memfd_backend_set_hugetlbsize(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
     HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(obj);
-    Error *local_err = NULL;
     uint64_t value;
 
     if (host_memory_backend_mr_inited(MEMORY_BACKEND(obj))) {
-        error_setg(&local_err, "cannot change property value");
-        goto out;
+        error_setg(errp, "cannot change property value");
+        return;
     }
 
-    visit_type_size(v, name, &value, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_size(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     if (!value) {
-        error_setg(&local_err, "Property '%s.%s' doesn't take value '%"
+        error_setg(errp, "Property '%s.%s' doesn't take value '%"
                    PRIu64 "'", object_get_typename(obj), name, value);
-        goto out;
+        return;
     }
     m->hugetlbsize = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void
backends/hostmem.c +15 -23
index 6d333dc23c..47ff08e770 100644
@@ -54,28 +54,25 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
 {
     HostMemoryBackend *backend = MEMORY_BACKEND(obj);
-    Error *local_err = NULL;
     uint64_t value;
 
     if (host_memory_backend_mr_inited(backend)) {
-        error_setg(&local_err, "cannot change property %s of %s ",
+        error_setg(errp, "cannot change property %s of %s ",
                    name, object_get_typename(obj));
-        goto out;
+        return;
     }
 
-    visit_type_size(v, name, &value, &local_err);
-    if (local_err) {
-        goto out;
+    visit_type_size(v, name, &value, errp);
+    if (*errp) {
+        return;
     }
     if (!value) {
-        error_setg(&local_err,
+        error_setg(errp,
                    "property '%s' of %s doesn't take value '%" PRIu64 "'",
                    name, object_get_typename(obj), value);
-        goto out;
+        return;
     }
     backend->size = value;
-out:
-    error_propagate(errp, local_err);
 }
 
 static void
@@ -221,7 +218,6 @@ static bool host_memory_backend_get_prealloc(Object *obj, Error **errp)
 static void host_memory_backend_set_prealloc(Object *obj, bool value,
                                              Error **errp)
 {
-    Error *local_err = NULL;
     HostMemoryBackend *backend = MEMORY_BACKEND(obj);
     MachineState *ms = MACHINE(qdev_get_machine());
 
@@ -243,9 +239,8 @@ static void host_memory_backend_set_prealloc(Object *obj, bool value,
         void *ptr = memory_region_get_ram_ptr(&backend->mr);
         uint64_t sz = memory_region_size(&backend->mr);
 
-        os_mem_prealloc(fd, ptr, sz, ms->smp.cpus, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        os_mem_prealloc(fd, ptr, sz, ms->smp.cpus, errp);
+        if (*errp) {
             return;
         }
         backend->prealloc = true;
@@ -314,14 +309,13 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
     HostMemoryBackend *backend = MEMORY_BACKEND(uc);
     HostMemoryBackendClass *bc = MEMORY_BACKEND_GET_CLASS(uc);
     MachineState *ms = MACHINE(qdev_get_machine());
-    Error *local_err = NULL;
     void *ptr;
     uint64_t sz;
 
     if (bc->alloc) {
-        bc->alloc(backend, &local_err);
-        if (local_err) {
-            goto out;
+        bc->alloc(backend, errp);
+        if (*errp) {
+            return;
         }
 
         ptr = memory_region_get_ram_ptr(&backend->mr);
@@ -378,14 +372,12 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
          */
         if (backend->prealloc) {
             os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz,
-                            ms->smp.cpus, &local_err);
-            if (local_err) {
-                goto out;
+                            ms->smp.cpus, errp);
+            if (*errp) {
+                return;
             }
         }
     }
-out:
-    error_propagate(errp, local_err);
 }
 
 static bool
backends/rng.c +2 -4
index 391888b8b3..76e8097a66 100644
@@ -55,7 +55,6 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
 {
     RngBackend *s = RNG_BACKEND(obj);
     RngBackendClass *k = RNG_BACKEND_GET_CLASS(s);
-    Error *local_err = NULL;
 
     if (value == s->opened) {
         return;
@@ -67,9 +66,8 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
     }
 
     if (k->opened) {
-        k->opened(s, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        k->opened(s, errp);
+        if (*errp) {
             return;
         }
     }
block.c +80 -128

593 lines not on this page · raw message

block/blkdebug.c +12 -21
index 5ae96c52b0..918ccf5704 100644
@@ -171,7 +171,6 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
     struct BlkdebugRule *rule;
     int64_t sector;
     BlkdebugIOType iotype;
-    Error *local_error = NULL;
 
     /* Find the right event for the rule */
     event_name = qemu_opt_get(opts, "event");
@@ -205,9 +204,8 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
 
         iotype = qapi_enum_parse(&BlkdebugIOType_lookup,
                                  qemu_opt_get(opts, "iotype"),
-                                 BLKDEBUG_IO_TYPE__MAX, &local_error);
-        if (local_error) {
-            error_propagate(errp, local_error);
+                                 BLKDEBUG_IO_TYPE__MAX, errp);
+        if (*errp) {
             return -1;
         }
         if (iotype != BLKDEBUG_IO_TYPE__MAX) {
@@ -262,7 +260,6 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
     FILE *f = NULL;
     int ret;
     struct add_rule_data d;
-    Error *local_err = NULL;
 
     if (filename) {
         f = fopen(filename, "r");
@@ -278,26 +275,23 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
         }
     }
 
-    qemu_config_parse_qdict(options, config_groups, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_config_parse_qdict(options, config_groups, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
     d.s = s;
     d.action = ACTION_INJECT_ERROR;
-    qemu_opts_foreach(&inject_error_opts, add_rule, &d, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_foreach(&inject_error_opts, add_rule, &d, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
     d.action = ACTION_SET_STATE;
-    qemu_opts_foreach(&set_state_opts, add_rule, &d, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_foreach(&set_state_opts, add_rule, &d, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -397,14 +391,12 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
 {
     BDRVBlkdebugState *s = bs->opaque;
     QemuOpts *opts;
-    Error *local_err = NULL;
     int ret;
     uint64_t align;
 
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -421,10 +413,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
 
     /* Open the image file */
     bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image",
-                               bs, &child_file, false, &local_err);
-    if (local_err) {
+                               bs, &child_file, false, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto out;
     }
 
block/blklogwrites.c +8 -13
index 04d8b33607..62455dc684 100644
@@ -143,34 +143,30 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
 {
     BDRVBlkLogWritesState *s = bs->opaque;
     QemuOpts *opts;
-    Error *local_err = NULL;
     int ret;
     uint64_t log_sector_size;
     bool log_append;
 
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
     /* Open the file */
     bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false,
-                               &local_err);
-    if (local_err) {
+                               errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
     /* Open the log file */
     s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, false,
-                                  &local_err);
-    if (local_err) {
+                                  errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
@@ -220,10 +216,9 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
         if (blk_log_writes_sector_size_valid(log_sector_size)) {
             s->cur_log_sector =
                 blk_log_writes_find_cur_log_sector(s->log_file, log_sector_size,
-                                    le64_to_cpu(log_sb.nr_entries), &local_err);
-            if (local_err) {
+                                    le64_to_cpu(log_sb.nr_entries), errp);
+            if (*errp) {
                 ret = -EINVAL;
-                error_propagate(errp, local_err);
                 goto fail_log;
             }
 
block/blkreplay.c +2 -4
index 2b7931b940..74d2ba7f9b 100644
@@ -23,15 +23,13 @@ typedef struct Request {
 static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
                           Error **errp)
 {
-    Error *local_err = NULL;
     int ret;
 
     /* Open the image file */
     bs->file = bdrv_open_child(NULL, options, "image",
-                               bs, &child_file, false, &local_err);
-    if (local_err) {
+                               bs, &child_file, false, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
block/blkverify.c +6 -10
index 304b0a1368..0fddf94f0f 100644
@@ -112,33 +112,29 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
 {
     BDRVBlkverifyState *s = bs->opaque;
     QemuOpts *opts;
-    Error *local_err = NULL;
     int ret;
 
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
 
     /* Open the raw file */
     bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw",
-                               bs, &child_file, false, &local_err);
-    if (local_err) {
+                               bs, &child_file, false, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
     /* Open the test file */
     s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options,
                                    "test", bs, &child_format, false,
-                                   &local_err);
-    if (local_err) {
+                                   errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
block/block-backend.c +6 -11
index 1c605d5444..371efeb1c8 100644
@@ -187,7 +187,6 @@ static void blk_vm_state_changed(void *opaque, int running, RunState state)
 static void blk_root_activate(BdrvChild *child, Error **errp)
 {
     BlockBackend *blk = child->opaque;
-    Error *local_err = NULL;
 
     if (!blk->disable_perm) {
         return;
@@ -195,9 +194,8 @@ static void blk_root_activate(BdrvChild *child, Error **errp)
 
     blk->disable_perm = false;
 
-    blk_set_perm(blk, blk->perm, BLK_PERM_ALL, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    blk_set_perm(blk, blk->perm, BLK_PERM_ALL, errp);
+    if (*errp) {
         blk->disable_perm = true;
         return;
     }
@@ -213,9 +211,8 @@ static void blk_root_activate(BdrvChild *child, Error **errp)
         return;
     }
 
-    blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    blk_set_perm(blk, blk->perm, blk->shared_perm, errp);
+    if (*errp) {
         blk->disable_perm = true;
         return;
     }
@@ -963,13 +960,11 @@ void blk_dev_change_media_cb(BlockBackend *blk, bool load, Error **errp)
 {
     if (blk->dev_ops && blk->dev_ops->change_media_cb) {
         bool tray_was_open, tray_is_open;
-        Error *local_err = NULL;
 
         tray_was_open = blk_dev_is_tray_open(blk);
-        blk->dev_ops->change_media_cb(blk->dev_opaque, load, &local_err);
-        if (local_err) {
+        blk->dev_ops->change_media_cb(blk->dev_opaque, load, errp);
+        if (*errp) {
             assert(load == true);
-            error_propagate(errp, local_err);
             return;
         }
         tray_is_open = blk_dev_is_tray_open(blk);
block/commit.c +2 -4
index bc8454463d..aa5541ecf1 100644
@@ -264,7 +264,6 @@ void commit_start(const char *job_id, BlockDriverState *bs,
     CommitBlockJob *s;
     BlockDriverState *iter;
     BlockDriverState *commit_top_bs = NULL;
-    Error *local_err = NULL;
     int ret;
 
     assert(top != bs);
@@ -303,10 +302,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
 
     commit_top_bs->total_sectors = top->total_sectors;
 
-    bdrv_append(commit_top_bs, top, &local_err);
-    if (local_err) {
+    bdrv_append(commit_top_bs, top, errp);
+    if (*errp) {
         commit_top_bs = NULL;
-        error_propagate(errp, local_err);
         goto fail;
     }
 
block/crypto.c +4 -8
index 7eb698774e..38995f7490 100644
@@ -194,7 +194,6 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
 {
     BlockCrypto *crypto = bs->opaque;
     QemuOpts *opts = NULL;
-    Error *local_err = NULL;
     int ret = -EINVAL;
     QCryptoBlockOpenOptions *open_opts = NULL;
     unsigned int cflags = 0;
@@ -210,9 +209,8 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
         bs->file->bs->supported_write_flags;
 
     opts = qemu_opts_create(opts_spec, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto cleanup;
     }
 
@@ -550,17 +548,15 @@ static int coroutine_fn block_crypto_co_create_opts_luks(const char *filename,
     char *buf = NULL;
     int64_t size;
     int ret;
-    Error *local_err = NULL;
 
     /* Parse options */
     size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
 
     buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
     prealloc = qapi_enum_parse(&PreallocMode_lookup, buf,
-                               PREALLOC_MODE_OFF, &local_err);
+                               PREALLOC_MODE_OFF, errp);
     g_free(buf);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return -EINVAL;
     }
 
block/curl.c +2 -4
index f86299378e..73c7006096 100644
@@ -645,7 +645,6 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
     BDRVCURLState *s = bs->opaque;
     CURLState *state = NULL;
     QemuOpts *opts;
-    Error *local_err = NULL;
     const char *file;
     const char *cookie;
     const char *cookie_secret;
@@ -671,9 +670,8 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
 
     qemu_mutex_init(&s->mutex);
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto out_noclean;
     }
 
block/file-posix.c +27 -44

200 lines not on this page · raw message

block/file-win32.c +10 -17
index 41f55dfece..26ae0f114c 100644
@@ -330,7 +330,6 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
     int access_flags;
     DWORD overlapped;
     QemuOpts *opts;
-    Error *local_err = NULL;
     const char *filename;
     bool use_aio;
     int ret;
@@ -338,9 +337,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
     s->type = FTYPE_FILE;
 
     opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -353,9 +351,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
 
     filename = qemu_opt_get(opts, "filename");
 
-    use_aio = get_aio_option(opts, flags, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    use_aio = get_aio_option(opts, flags, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -727,28 +724,24 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
     int ret = 0;
     DWORD overlapped;
     char device_name[64];
-
-    Error *local_err = NULL;
     const char *filename;
     bool use_aio;
 
     QemuOpts *opts = qemu_opts_create(&raw_runtime_opts, NULL, 0,
                                       &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto done;
     }
 
     filename = qemu_opt_get(opts, "filename");
 
-    use_aio = get_aio_option(opts, flags, &local_err);
-    if (!local_err && use_aio) {
-        error_setg(&local_err, "AIO is not supported on Windows host devices");
+    use_aio = get_aio_option(opts, flags, errp);
+    if (!*errp && use_aio) {
+        error_setg(errp, "AIO is not supported on Windows host devices");
     }
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto done;
     }
block/gluster.c +29 -35

183 lines not on this page · raw message

block/io.c +4 -7
index f8c3596131..cebf76bed5 100644
@@ -136,7 +136,6 @@ static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
 void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
 {
     BlockDriver *drv = bs->drv;
-    Error *local_err = NULL;
 
     memset(&bs->bl, 0, sizeof(bs->bl));
 
@@ -151,9 +150,8 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
 
     /* Take some limits from the children as a default */
     if (bs->file) {
-        bdrv_refresh_limits(bs->file->bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_refresh_limits(bs->file->bs, errp);
+        if (*errp) {
             return;
         }
         bdrv_merge_limits(&bs->bl, &bs->file->bs->bl);
@@ -166,9 +164,8 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
     }
 
     if (bs->backing) {
-        bdrv_refresh_limits(bs->backing->bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_refresh_limits(bs->backing->bs, errp);
+        if (*errp) {
             return;
         }
         bdrv_merge_limits(&bs->bl, &bs->backing->bs->bl);
block/iscsi.c +12 -21
index 506bf5f875..f150550501 100644
@@ -1786,7 +1786,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     struct scsi_inquiry_supported_pages *inq_vpd;
     char *initiator_name = NULL;
     QemuOpts *opts;
-    Error *local_err = NULL;
     const char *transport_name, *portal, *target;
 #if LIBISCSI_API_VERSION >= (20160603)
     enum iscsi_transport_type transport;
@@ -1794,9 +1793,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     int i, ret = 0, timeout = 0, lun;
 
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto out;
     }
@@ -1850,9 +1848,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     /* check if we got CHAP username/password via the options */
-    apply_chap(iscsi, opts, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    apply_chap(iscsi, opts, errp);
+    if (*errp != NULL) {
         ret = -EINVAL;
         goto out;
     }
@@ -1864,9 +1861,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     /* check if we got HEADER_DIGEST via the options */
-    apply_header_digest(iscsi, opts, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    apply_header_digest(iscsi, opts, errp);
+    if (*errp != NULL) {
         ret = -EINVAL;
         goto out;
     }
@@ -1918,9 +1914,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
         flags &= ~BDRV_O_RDWR;
     }
 
-    iscsi_readcapacity_sync(iscsilun, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    iscsi_readcapacity_sync(iscsilun, errp);
+    if (*errp != NULL) {
         ret = -EINVAL;
         goto out;
     }
@@ -2125,7 +2120,6 @@ static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset,
                                           PreallocMode prealloc, Error **errp)
 {
     IscsiLun *iscsilun = bs->opaque;
-    Error *local_err = NULL;
 
     if (prealloc != PREALLOC_MODE_OFF) {
         error_setg(errp, "Unsupported preallocation mode '%s'",
@@ -2138,9 +2132,8 @@ static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset,
         return -ENOTSUP;
     }
 
-    iscsi_readcapacity_sync(iscsilun, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    iscsi_readcapacity_sync(iscsilun, errp);
+    if (*errp != NULL) {
         return -EIO;
     }
 
@@ -2164,7 +2157,6 @@ static int coroutine_fn iscsi_co_create_opts(const char *filename, QemuOpts *opt
     BlockDriverState *bs;
     IscsiLun *iscsilun = NULL;
     QDict *bs_options;
-    Error *local_err = NULL;
 
     bs = bdrv_new();
 
@@ -2175,9 +2167,8 @@ static int coroutine_fn iscsi_co_create_opts(const char *filename, QemuOpts *opt
     iscsilun = bs->opaque;
 
     bs_options = qdict_new();
-    iscsi_parse_filename(filename, bs_options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    iscsi_parse_filename(filename, bs_options, errp);
+    if (*errp) {
         ret = -EINVAL;
     } else {
         ret = iscsi_open(bs, bs_options, 0, NULL);
block/mirror.c +6 -11
index fe984efb90..c1beaf9f8a 100644
@@ -1512,7 +1512,6 @@ static BlockJob *mirror_start_job(
     BlockDriverState *mirror_top_bs;
     bool target_graph_mod;
     bool target_is_backing;
-    Error *local_err = NULL;
     int ret;
 
     if (granularity == 0) {
@@ -1561,12 +1560,11 @@ static BlockJob *mirror_start_job(
      * it alive until block_job_create() succeeds even if bs has no parent. */
     bdrv_ref(mirror_top_bs);
     bdrv_drained_begin(bs);
-    bdrv_append(mirror_top_bs, bs, &local_err);
+    bdrv_append(mirror_top_bs, bs, errp);
     bdrv_drained_end(bs);
 
-    if (local_err) {
+    if (*errp) {
         bdrv_unref(mirror_top_bs);
-        error_propagate(errp, local_err);
         return NULL;
     }
 
@@ -1647,9 +1645,8 @@ static BlockJob *mirror_start_job(
      * (We start tracking writes as of the following
      * bdrv_create_dirty_bitmap() call.)
      */
-    bdrv_refresh_limits(mirror_top_bs, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    bdrv_refresh_limits(mirror_top_bs, errp);
+    if (*errp) {
         goto fail;
     }
 
@@ -1761,7 +1758,6 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
                               bool auto_complete, Error **errp)
 {
     bool base_read_only;
-    Error *local_err = NULL;
     BlockJob *ret;
 
     base_read_only = bdrv_is_read_only(base);
@@ -1778,9 +1774,8 @@ BlockJob *commit_active_start(const char *job_id, BlockDriverState *bs,
                      on_error, on_error, true, cb, opaque,
                      &commit_active_job_driver, false, base, auto_complete,
                      filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND,
-                     &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+                     errp);
+    if (*errp) {
         goto error_restore_flags;
     }
 
block/nbd.c +18 -26

131 lines not on this page · raw message

block/nfs.c +2 -4
index f39acfdb28..d1c41625de 100644
@@ -564,18 +564,16 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options,
     BlockdevOptionsNfs *opts = NULL;
     Visitor *v;
     const QDictEntry *e;
-    Error *local_err = NULL;
 
     v = qobject_input_visitor_new_flat_confused(options, errp);
     if (!v) {
         return NULL;
     }
 
-    visit_type_BlockdevOptionsNfs(v, NULL, &opts, &local_err);
+    visit_type_BlockdevOptionsNfs(v, NULL, &opts, errp);
     visit_free(v);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return NULL;
     }
 
block/nvme.c +6 -11
index 5be3a39b63..1b55d640ef 100644
@@ -189,7 +189,6 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs,
 {
     int i, r;
     BDRVNVMeState *s = bs->opaque;
-    Error *local_err = NULL;
     NVMeQueuePair *q = g_new0(NVMeQueuePair, 1);
     uint64_t prp_list_iova;
 
@@ -209,16 +208,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs,
         req->prp_list_page = q->prp_list_pages + i * s->page_size;
         req->prp_list_iova = prp_list_iova + i * s->page_size;
     }
-    nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp);
+    if (*errp) {
         goto fail;
     }
     q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale];
 
-    nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp);
+    if (*errp) {
         goto fail;
     }
     q->cq.doorbell = &s->regs->doorbells[(idx * 2 + 1) * s->doorbell_scale];
@@ -574,7 +571,6 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
     uint64_t cap;
     uint64_t timeout_ms;
     uint64_t deadline, now;
-    Error *local_err = NULL;
 
     qemu_co_mutex_init(&s->dma_map_lock);
     qemu_co_queue_init(&s->dma_flush_queue);
@@ -666,9 +662,8 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
     aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
                            false, nvme_handle_event, nvme_poll_cb);
 
-    nvme_identify(bs, namespace, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    nvme_identify(bs, namespace, errp);
+    if (*errp) {
         ret = -EIO;
         goto out;
     }
block/parallels.c +11 -17
index 7cd2714b69..c32ac09391 100644
@@ -614,7 +614,6 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
                                                  Error **errp)
 {
     BlockdevCreateOptions *create_options = NULL;
-    Error *local_err = NULL;
     BlockDriverState *bs = NULL;
     QDict *qdict;
     Visitor *v;
@@ -635,9 +634,8 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
     }
 
     /* Create and open the file (protocol layer) */
-    ret = bdrv_create_file(filename, opts, &local_err);
+    ret = bdrv_create_file(filename, opts, errp);
     if (ret < 0) {
-        error_propagate(errp, local_err);
         goto done;
     }
 
@@ -658,11 +656,10 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
         goto done;
     }
 
-    visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+    visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
     visit_free(v);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto done;
     }
@@ -725,7 +722,6 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
     ParallelsHeader ph;
     int ret, size, i;
     QemuOpts *opts = NULL;
-    Error *local_err = NULL;
     char *buf;
 
     bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
@@ -813,13 +809,13 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
         }
     }
 
-    opts = qemu_opts_create(&parallels_runtime_opts, NULL, 0, &local_err);
-    if (local_err != NULL) {
+    opts = qemu_opts_create(&parallels_runtime_opts, NULL, 0, errp);
+    if (*errp != NULL) {
         goto fail_options;
     }
 
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err != NULL) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp != NULL) {
         goto fail_options;
     }
 
@@ -829,9 +825,9 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
     buf = qemu_opt_get_del(opts, PARALLELS_OPT_PREALLOC_MODE);
     s->prealloc_mode = qapi_enum_parse(&prealloc_mode_lookup, buf,
                                        PRL_PREALLOC_MODE_FALLOCATE,
-                                       &local_err);
+                                       errp);
     g_free(buf);
-    if (local_err != NULL) {
+    if (*errp != NULL) {
         goto fail_options;
     }
 
@@ -855,9 +851,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
     error_setg(&s->migration_blocker, "The Parallels format used by node '%s' "
                "does not support live migration",
                bdrv_get_device_or_node_name(bs));
-    ret = migrate_add_blocker(s->migration_blocker, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ret = migrate_add_blocker(s->migration_blocker, errp);
+    if (*errp) {
         error_free(s->migration_blocker);
         goto fail;
     }
@@ -872,7 +867,6 @@ fail:
     return ret;
 
 fail_options:
-    error_propagate(errp, local_err);
     ret = -EINVAL;
     goto fail;
 }
block/qapi.c +8 -15
index 15f1030264..30898c60b7 100644
@@ -148,10 +148,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
     p_image_info = &info->image;
     info->backing_file_depth = 0;
     while (1) {
-        Error *local_err = NULL;
-        bdrv_query_image_info(bs0, p_image_info, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_query_image_info(bs0, p_image_info, errp);
+        if (*errp) {
             qapi_free_BlockDeviceInfo(info);
             return NULL;
         }
@@ -261,7 +259,6 @@ void bdrv_query_image_info(BlockDriverState *bs,
     const char *backing_filename;
     BlockDriverInfo bdi;
     int ret;
-    Error *err = NULL;
     ImageInfo *info;
 
     aio_context_acquire(bdrv_get_aio_context(bs));
@@ -293,9 +290,8 @@ void bdrv_query_image_info(BlockDriverState *bs,
         info->dirty_flag = bdi.is_dirty;
         info->has_dirty_flag = true;
     }
-    info->format_specific = bdrv_get_specific_info(bs, &err);
-    if (err) {
-        error_propagate(errp, err);
+    info->format_specific = bdrv_get_specific_info(bs, errp);
+    if (*errp) {
         qapi_free_ImageInfo(info);
         goto out;
     }
@@ -322,7 +318,7 @@ void bdrv_query_image_info(BlockDriverState *bs,
         g_free(backing_filename2);
     }
 
-    ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, &err);
+    ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, errp);
     switch (ret) {
     case 0:
         if (info->snapshots) {
@@ -332,10 +328,9 @@ void bdrv_query_image_info(BlockDriverState *bs,
     /* recoverable error */
     case -ENOMEDIUM:
     case -ENOTSUP:
-        error_free(err);
+        error_free_errp(errp);
         break;
     default:
-        error_propagate(errp, err);
         qapi_free_ImageInfo(info);
         goto out;
     }
@@ -554,7 +549,6 @@ BlockInfoList *qmp_query_block(Error **errp)
 {
     BlockInfoList *head = NULL, **p_next = &head;
     BlockBackend *blk;
-    Error *local_err = NULL;
 
     for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
         BlockInfoList *info;
@@ -564,9 +558,8 @@ BlockInfoList *qmp_query_block(Error **errp)
         }
 
         info = g_malloc0(sizeof(*info));
-        bdrv_query_info(blk, &info->value, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_query_info(blk, &info->value, errp);
+        if (*errp) {
             g_free(info);
             qapi_free_BlockInfoList(head);
             return NULL;
block/qcow.c +5 -10
index 5bdf72ba33..fcf1fb0812 100644
@@ -121,7 +121,6 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
     unsigned int len, i, shift;
     int ret;
     QCowHeader header;
-    Error *local_err = NULL;
     QCryptoBlockOpenOptions *crypto_opts = NULL;
     unsigned int cflags = 0;
     QDict *encryptopts = NULL;
@@ -314,9 +313,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
     error_setg(&s->migration_blocker, "The qcow format used by node '%s' "
                "does not support live migration",
                bdrv_get_device_or_node_name(bs));
-    ret = migrate_add_blocker(s->migration_blocker, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    ret = migrate_add_blocker(s->migration_blocker, errp);
+    if (*errp) {
         error_free(s->migration_blocker);
         goto fail;
     }
@@ -947,7 +945,6 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
     QDict *qdict;
     Visitor *v;
     const char *val;
-    Error *local_err = NULL;
     int ret;
 
     static const QDictRenames opt_renames[] = {
@@ -977,9 +974,8 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
     }
 
     /* Create and open the file (protocol layer) */
-    ret = bdrv_create_file(filename, opts, &local_err);
+    ret = bdrv_create_file(filename, opts, errp);
     if (ret < 0) {
-        error_propagate(errp, local_err);
         goto fail;
     }
 
@@ -1000,11 +996,10 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
         goto fail;
     }
 
-    visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+    visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
     visit_free(v);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
block/qcow2-bitmap.c +2 -4
index b2487101ed..902345a8e3 100644
@@ -1594,11 +1594,9 @@ fail:
 int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp)
 {
     BdrvDirtyBitmap *bitmap;
-    Error *local_err = NULL;
 
-    qcow2_store_persistent_dirty_bitmaps(bs, &local_err);
-    if (local_err != NULL) {
-        error_propagate(errp, local_err);
+    qcow2_store_persistent_dirty_bitmaps(bs, errp);
+    if (*errp != NULL) {
         return -EINVAL;
     }
 
block/qcow2.c +35 -55

258 lines not on this page · raw message

block/qed.c +6 -10
index 0d8fd507aa..7697dd0f4c 100644
@@ -725,7 +725,6 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
     QDict *qdict;
     Visitor *v;
     BlockDriverState *bs = NULL;
-    Error *local_err = NULL;
     int ret;
 
     static const QDictRenames opt_renames[] = {
@@ -745,9 +744,8 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
     }
 
     /* Create and open the file (protocol layer) */
-    ret = bdrv_create_file(filename, opts, &local_err);
+    ret = bdrv_create_file(filename, opts, errp);
     if (ret < 0) {
-        error_propagate(errp, local_err);
         goto fail;
     }
 
@@ -768,11 +766,10 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
         goto fail;
     }
 
-    visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
+    visit_type_BlockdevCreateOptions(v, NULL, &create_options, errp);
     visit_free(v);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         ret = -EINVAL;
         goto fail;
     }
@@ -1588,17 +1585,16 @@ static void coroutine_fn bdrv_qed_co_invalidate_cache(BlockDriverState *bs,
                                                       Error **errp)
 {
     BDRVQEDState *s = bs->opaque;
-    Error *local_err = NULL;
     int ret;
 
     bdrv_qed_close(bs);
 
     bdrv_qed_init_state(bs);
     qemu_co_mutex_lock(&s->table_lock);
-    ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, &local_err);
+    ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, errp);
     qemu_co_mutex_unlock(&s->table_lock);
-    if (local_err) {
-        error_propagate_prepend(errp, local_err,
+    if (*errp) {
+        error_propagate_prepend(errp, *errp,
                                 "Could not reopen qed layer: ");
         return;
     } else if (ret < 0) {
block/quorum.c +10 -12
index df68adcfaa..0b6b09afc7 100644
@@ -862,7 +862,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
                        Error **errp)
 {
     BDRVQuorumState *s = bs->opaque;
-    Error *local_err = NULL;
     QemuOpts *opts = NULL;
     const char *pattern_str;
     bool *opened;
@@ -874,27 +873,27 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     /* count how many different children are present */
     s->num_children = qdict_array_entries(options, "children.");
     if (s->num_children < 0) {
-        error_setg(&local_err, "Option children is not a valid array");
+        error_setg(errp, "Option children is not a valid array");
         ret = -EINVAL;
         goto exit;
     }
     if (s->num_children < 1) {
-        error_setg(&local_err,
+        error_setg(errp,
                    "Number of provided children must be 1 or more");
         ret = -EINVAL;
         goto exit;
     }
 
     opts = qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto exit;
     }
 
     s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0);
     /* and validate it against s->num_children */
-    ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err);
+    ret = quorum_valid_threshold(s->threshold, s->num_children, errp);
     if (ret < 0) {
         goto exit;
     }
@@ -907,7 +906,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
                               -EINVAL, NULL);
     }
     if (ret < 0) {
-        error_setg(&local_err, "Please set read-pattern as fifo or quorum");
+        error_setg(errp, "Please set read-pattern as fifo or quorum");
         goto exit;
     }
     s->read_pattern = ret;
@@ -915,7 +914,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) {
         s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false);
         if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) {
-            error_setg(&local_err, "blkverify=on can only be set if there are "
+            error_setg(errp, "blkverify=on can only be set if there are "
                        "exactly two files and vote-threshold is 2");
             ret = -EINVAL;
             goto exit;
@@ -924,7 +923,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
         s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE,
                                                  false);
         if (s->rewrite_corrupted && s->is_blkverify) {
-            error_setg(&local_err,
+            error_setg(errp,
                        "rewrite-corrupted=on cannot be used with blkverify=on");
             ret = -EINVAL;
             goto exit;
@@ -941,8 +940,8 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
         assert(ret < 32);
 
         s->children[i] = bdrv_open_child(NULL, options, indexstr, bs,
-                                         &child_format, false, &local_err);
-        if (local_err) {
+                                         &child_format, false, errp);
+        if (*errp) {
             ret = -EINVAL;
             goto close_exit;
         }
@@ -969,7 +968,6 @@ close_exit:
 exit:
     qemu_opts_del(opts);
     /* propagate error */
-    error_propagate(errp, local_err);
     return ret;
 }
 
block/raw-format.c +2 -4
index 42c28cc29a..e83a30c3b5 100644
@@ -74,7 +74,6 @@ static QemuOptsList raw_create_opts = {
 static int raw_read_options(QDict *options, BlockDriverState *bs,
     BDRVRawState *s, Error **errp)
 {
-    Error *local_err = NULL;
     QemuOpts *opts = NULL;
     int64_t real_size = 0;
     int ret;
@@ -86,9 +85,8 @@ static int raw_read_options(QDict *options, BlockDriverState *bs,
     }
 
     opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         ret = -EINVAL;
         goto end;
     }
block/rbd.c +8 -17
index 057af43d48..ae4dd9e705 100644
@@ -431,7 +431,6 @@ static int coroutine_fn qemu_rbd_co_create_opts(const char *filename,
     BlockdevCreateOptions *create_options;
     BlockdevCreateOptionsRbd *rbd_opts;
     BlockdevOptionsRbd *loc;
-    Error *local_err = NULL;
     const char *keypairs, *password_secret;
     QDict *options = NULL;
     int ret = 0;
@@ -452,10 +451,9 @@ static int coroutine_fn qemu_rbd_co_create_opts(const char *filename,
     rbd_opts->has_cluster_size = (rbd_opts->cluster_size != 0);
 
     options = qdict_new();
-    qemu_rbd_parse_filename(filename, options, &local_err);
-    if (local_err) {
+    qemu_rbd_parse_filename(filename, options, errp);
+    if (*errp) {
         ret = -EINVAL;
-        error_propagate(errp, local_err);
         goto exit;
     }
 
@@ -573,7 +571,6 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
                             Error **errp)
 {
     char *mon_host = NULL;
-    Error *local_err = NULL;
     int r;
 
     if (secretid) {
@@ -586,9 +583,8 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
         opts->has_key_secret = true;
     }
 
-    mon_host = qemu_rbd_mon_host(opts, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    mon_host = qemu_rbd_mon_host(opts, errp);
+    if (*errp) {
         r = -EINVAL;
         goto failed_opts;
     }
@@ -661,7 +657,6 @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
                                     Error **errp)
 {
     Visitor *v;
-    Error *local_err = NULL;
 
     /* Convert the remaining options into a QAPI object */
     v = qobject_input_visitor_new_flat_confused(options, errp);
@@ -669,11 +664,10 @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
         return -EINVAL;
     }
 
-    visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
+    visit_type_BlockdevOptionsRbd(v, NULL, opts, errp);
     visit_free(v);
 
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (*errp) {
         return -EINVAL;
     }
 
@@ -713,7 +707,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
     BDRVRBDState *s = bs->opaque;
     BlockdevOptionsRbd *opts = NULL;
     const QDictEntry *e;
-    Error *local_err = NULL;
     char *keypairs, *secretid;
     int r;
 
@@ -727,13 +720,12 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         qdict_del(options, "password-secret");
     }
 
-    r = qemu_rbd_convert_options(options, &opts, &local_err);
-    if (local_err) {
+    r = qemu_rbd_convert_options(options, &opts, errp);
+    if (*errp) {
         /* If keypairs are present, that means some options are present in
          * the modern option format.  Don't attempt to parse legacy option
          * formats, as we won't support mixed usage. */
         if (keypairs) {
-            error_propagate(errp, local_err);
             goto out;
         }
 
@@ -746,7 +738,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         if (r < 0) {
             /* Propagate the original error, not the legacy parsing fallback
              * error, as the latter was just a best-effort attempt. */
-            error_propagate(errp, local_err);
             goto out;
         }
         /* Take care whenever deciding to actually deprecate; once this ability
block/replication.c +14 -22
index 936b2f8b5a..22ae1067ec 100644
@@ -85,7 +85,6 @@ static int replication_open(BlockDriverState *bs, QDict *options,
 {
     int ret;
     BDRVReplicationState *s = bs->opaque;
-    Error *local_err = NULL;
     QemuOpts *opts = NULL;
     const char *mode;
     const char *top_id;
@@ -98,14 +97,14 @@ static int replication_open(BlockDriverState *bs, QDict *options,
 
     ret = -EINVAL;
     opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort);
-    qemu_opts_absorb_qdict(opts, options, &local_err);
-    if (local_err) {
+    qemu_opts_absorb_qdict(opts, options, errp);
+    if (*errp) {
         goto fail;
     }
 
     mode = qemu_opt_get(opts, REPLICATION_MODE);
     if (!mode) {
-        error_setg(&local_err, "Missing the option mode");
+        error_setg(errp, "Missing the option mode");
         goto fail;
     }
 
@@ -113,7 +112,8 @@ static int replication_open(BlockDriverState *bs, QDict *options,
         s->mode = REPLICATION_MODE_PRIMARY;
         top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
         if (top_id) {
-            error_setg(&local_err, "The primary side does not support option top-id");
+            error_setg(errp,
+                       "The primary side does not support option top-id");
             goto fail;
         }
     } else if (!strcmp(mode, "secondary")) {
@@ -121,11 +121,11 @@ static int replication_open(BlockDriverState *bs, QDict *options,
         top_id = qemu_opt_get(opts, REPLICATION_TOP_ID);
         s->top_id = g_strdup(top_id);
         if (!s->top_id) {
-            error_setg(&local_err, "Missing the option top-id");
+            error_setg(errp, "Missing the option top-id");
             goto fail;
         }
     } else {
-        error_setg(&local_err,
+        error_setg(errp,
                    "The option mode's value should be primary or secondary");
         goto fail;
     }
@@ -136,7 +136,6 @@ static int replication_open(BlockDriverState *bs, QDict *options,
 
 fail:
     qemu_opts_del(opts);
-    error_propagate(errp, local_err);
 
     return ret;
 }
@@ -314,7 +313,6 @@ static bool replication_recurse_is_first_non_filter(BlockDriverState *bs,
 
 static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp)
 {
-    Error *local_err = NULL;
     int ret;
 
     if (!s->backup_job) {
@@ -322,9 +320,8 @@ static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp)
         return;
     }
 
-    backup_do_checkpoint(s->backup_job, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    backup_do_checkpoint(s->backup_job, errp);
+    if (*errp) {
         return;
     }
 
@@ -363,7 +360,6 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable,
 {
     BDRVReplicationState *s = bs->opaque;
     BlockReopenQueue *reopen_queue = NULL;
-    Error *local_err = NULL;
 
     if (writable) {
         s->orig_hidden_read_only = bdrv_is_read_only(s->hidden_disk->bs);
@@ -388,8 +384,7 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable,
     }
 
     if (reopen_queue) {
-        bdrv_reopen_multiple(reopen_queue, &local_err);
-        error_propagate(errp, local_err);
+        bdrv_reopen_multiple(reopen_queue, errp);
     }
 
     bdrv_subtree_drained_end(s->hidden_disk->bs);
@@ -450,7 +445,6 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
     BlockDriverState *top_bs;
     int64_t active_length, hidden_length, disk_length;
     AioContext *aio_context;
-    Error *local_err = NULL;
 
     aio_context = bdrv_get_aio_context(bs);
     aio_context_acquire(aio_context);
@@ -519,9 +513,8 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
         }
 
         /* reopen the backing file in r/w mode */
-        reopen_backing_file(bs, true, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        reopen_backing_file(bs, true, errp);
+        if (*errp) {
             aio_context_release(aio_context);
             return;
         }
@@ -546,9 +539,8 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
                                 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false,
                                 BLOCKDEV_ON_ERROR_REPORT,
                                 BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
-                                backup_job_completed, bs, NULL, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+                                backup_job_completed, bs, NULL, errp);
+        if (*errp) {
             backup_job_cleanup(bs);
             aio_context_release(aio_context);
             return;
block/sheepdog.c +26 -40

154 lines not on this page · raw message

block/snapshot.c +4 -10
index f2f48f926a..ca1c79f80f 100644

Lines of this file are not shown. View the raw message.

block/ssh.c +4 -7
index 84d01e892b..7c41b2a416 100644

Lines of this file are not shown. View the raw message.

block/throttle-groups.c +9 -13
index 77014c741b..90834e31ee 100644

Lines of this file are not shown. View the raw message.

block/throttle.c +2 -4
index 0349f42257..b3a9ceec55 100644

Lines of this file are not shown. View the raw message.

block/vdi.c +4 -8
index 806ba7f53c..2d405d6cf9 100644

Lines of this file are not shown. View the raw message.

block/vhdx.c +7 -13
index 6a09d0a55c..1dff40932e 100644

Lines of this file are not shown. View the raw message.

block/vmdk.c +12 -24
index fed3b50c8a..3a0170312c 100644

Lines of this file are not shown. View the raw message.

block/vpc.c +9 -16
index 5cd3890780..2de4f83e4f 100644

Lines of this file are not shown. View the raw message.

block/vvfat.c +4 -7
index 019b8f1341..71428ea5a4 100644

Lines of this file are not shown. View the raw message.

block/vxhs.c +10 -12
index 77fd5eb20d..6e98d4338f 100644

Lines of this file are not shown. View the raw message.

blockdev.c +78 -142

220 lines not on this page · raw message

blockjob.c +2 -5
index c6e20e2fcd..8718ead3b8 100644

Lines of this file are not shown. View the raw message.

bootdevice.c +10 -19
index 1d225202f9..fccd47dd44 100644

Lines of this file are not shown. View the raw message.

chardev/char-socket.c +2 -4
index 185fe38dda..4eb881f998 100644

Lines of this file are not shown. View the raw message.

chardev/char.c +7 -11
index 7b6b2cb123..d0385958c4 100644

Lines of this file are not shown. View the raw message.

crypto/block-luks.c +12 -19
index 743949adbf..023c4dfeea 100644

Lines of this file are not shown. View the raw message.

crypto/secret.c +6 -10
index 1cf0ad0ce8..34400f42df 100644

Lines of this file are not shown. View the raw message.

crypto/tlssession.c +2 -4
index 33203e8ca7..3ba25c6834 100644

Lines of this file are not shown. View the raw message.

dump/dump.c +52 -90

142 lines not on this page · raw message

dump/win_dump.c +10 -17
index eda2a48974..73b3b454d4 100644

Lines of this file are not shown. View the raw message.

exec.c +4 -8
index 8b998974f8..a0aaa1b24a 100644

Lines of this file are not shown. View the raw message.

hw/9pfs/9p-local.c +3 -4
index 08e673a79c..730d58e9ef 100644

Lines of this file are not shown. View the raw message.

hw/acpi/core.c +7 -10
index 45cbed49ab..b644616697 100644

Lines of this file are not shown. View the raw message.

hw/acpi/ich9.c +9 -18
index 2034dd749e..232b550fa2 100644

Lines of this file are not shown. View the raw message.

hw/acpi/memory_hotplug.c +2 -4
index 9483d66e86..38f36aa9d8 100644

Lines of this file are not shown. View the raw message.

hw/arm/allwinner-a10.c +10 -16
index 118032c8c7..02932fec88 100644

Lines of this file are not shown. View the raw message.

hw/arm/armv7m.c +20 -31

51 lines not on this page · raw message

hw/arm/bcm2835_peripherals.c +34 -50

84 lines not on this page · raw message

hw/arm/bcm2836.c +16 -24
index 493a913f89..cd605eb53d 100644

Lines of this file are not shown. View the raw message.

hw/arm/digic.c +8 -13
index 22434a65a2..024aa10509 100644

Lines of this file are not shown. View the raw message.

hw/arm/fsl-imx25.c +24 -37

61 lines not on this page · raw message

hw/arm/fsl-imx31.c +22 -34

56 lines not on this page · raw message

hw/arm/fsl-imx6.c +32 -48

80 lines not on this page · raw message

hw/arm/integratorcp.c +2 -4
index 524970840d..dcdb2fd156 100644

Lines of this file are not shown. View the raw message.

hw/arm/msf2-soc.c +8 -13
index 008fd9327a..8f23674d81 100644

Lines of this file are not shown. View the raw message.

hw/arm/nrf51_soc.c +18 -28

46 lines not on this page · raw message

hw/arm/smmu-common.c +2 -4
index 245817d23e..868f18c5e5 100644

Lines of this file are not shown. View the raw message.

hw/arm/smmuv3.c +2 -4
index db051dcac8..2831f024bd 100644

Lines of this file are not shown. View the raw message.

hw/arm/stm32f205_soc.c +15 -23
index f5a5c2d80c..52042d6d80 100644

Lines of this file are not shown. View the raw message.

hw/arm/tosa.c +1 -0
index 4d95a1f3e2..567c56f726 100644

Lines of this file are not shown. View the raw message.

hw/arm/xlnx-versal-virt.c +2 -4
index 462493c467..2223d3281c 100644

Lines of this file are not shown. View the raw message.

hw/arm/xlnx-zynqmp.c +34 -50

84 lines not on this page · raw message

hw/audio/intel-hda.c +5 -7
index 6ecd383540..13c2be81ac 100644

Lines of this file are not shown. View the raw message.

hw/block/dataplane/xen-block.c +6 -10
index 3b9caeb2fa..ae3fcd9308 100644

Lines of this file are not shown. View the raw message.

hw/block/fdc.c +6 -11
index ac5d31e8c1..1019cae4eb 100644

Lines of this file are not shown. View the raw message.

hw/block/onenand.c +2 -4
index fcc5a69b90..48af07bb11 100644

Lines of this file are not shown. View the raw message.

hw/block/pflash_cfi01.c +2 -4
index 566c0acb77..4ba559677e 100644

Lines of this file are not shown. View the raw message.

hw/block/pflash_cfi02.c +2 -4
index 4baca701b7..d5110c12d0 100644

Lines of this file are not shown. View the raw message.

hw/block/vhost-user-blk.c +2 -3
index 63da9bb619..5906fac6aa 100644

Lines of this file are not shown. View the raw message.

hw/block/virtio-blk.c +2 -4
index 18851601cb..3a76f231c9 100644

Lines of this file are not shown. View the raw message.

hw/block/xen-block.c +45 -69

114 lines not on this page · raw message

hw/char/debugcon.c +2 -4
index 5c592e091b..92ef636b1b 100644

Lines of this file are not shown. View the raw message.

hw/char/serial-pci-multi.c +2 -4
index 5f13b5663b..fc4b1fed70 100644

Lines of this file are not shown. View the raw message.

hw/char/serial-pci.c +2 -4
index cb9b76e22b..bb804bd7b2 100644

Lines of this file are not shown. View the raw message.

hw/char/virtio-serial-bus.c +2 -4
index 4e0ed829ae..466bd4b1bd 100644

Lines of this file are not shown. View the raw message.

hw/core/bus.c +6 -8
index 7f3d2a3dbd..50b3cf4b36 100644

Lines of this file are not shown. View the raw message.

hw/core/machine.c +6 -12
index 1689ad3bf8..a998e210af 100644

Lines of this file are not shown. View the raw message.

hw/core/numa.c +20 -28

48 lines not on this page · raw message

hw/core/qdev-properties-system.c +8 -16
index 70bfd4809b..b53056a5fa 100644

Lines of this file are not shown. View the raw message.

hw/core/qdev-properties.c +27 -51

78 lines not on this page · raw message

hw/core/qdev.c +16 -20
index cbad6c1d55..34eca74089 100644

Lines of this file are not shown. View the raw message.

hw/core/sysbus.c +1 -0
index 9e69c83aed..bb7d25df38 100644

Lines of this file are not shown. View the raw message.

hw/cpu/a15mpcore.c +2 -4
index 7e9983aa19..6dfcc9a042 100644

Lines of this file are not shown. View the raw message.

hw/cpu/a9mpcore.c +10 -16
index 6872a3a00a..e1c010c158 100644

Lines of this file are not shown. View the raw message.

hw/cpu/arm11mpcore.c +8 -13
index e78f5d080c..2292c2dbf6 100644

Lines of this file are not shown. View the raw message.

hw/cpu/core.c +4 -8
index 9874c5c870..8f2d4e3b64 100644

Lines of this file are not shown. View the raw message.

hw/cpu/realview_mpcore.c +4 -7
index ae2c9913f6..d6331192a5 100644

Lines of this file are not shown. View the raw message.

hw/display/bcm2835_fb.c +2 -3
index 8f856878cd..584fc0164c 100644

Lines of this file are not shown. View the raw message.

hw/display/qxl.c +2 -4
index cd7eb39d20..c693726253 100644

Lines of this file are not shown. View the raw message.

hw/display/virtio-gpu-base.c +2 -4
index 55e07995fe..241839e83f 100644

Lines of this file are not shown. View the raw message.

hw/display/virtio-gpu-pci.c +2 -4
index 25e4038874..b6f8c207c9 100644

Lines of this file are not shown. View the raw message.

hw/display/virtio-vga.c +2 -4
index cc6e66ea1c..bd7cc06f86 100644

Lines of this file are not shown. View the raw message.

hw/dma/bcm2835_dma.c +2 -3
index 192bd377a0..331779bbd9 100644

Lines of this file are not shown. View the raw message.

hw/dma/xilinx_axidma.c +6 -8
index a254275b64..b5f49e6f88 100644

Lines of this file are not shown. View the raw message.

hw/gpio/aspeed_gpio.c +2 -4
index 25fbfec3b8..695c91aec1 100644

Lines of this file are not shown. View the raw message.

hw/gpio/bcm2835_gpio.c +4 -5
index 91ce3d10cc..363ada96d2 100644

Lines of this file are not shown. View the raw message.

hw/i386/kvm/apic.c +1 -0
index 91fb622d63..d125b370f4 100644

Lines of this file are not shown. View the raw message.

hw/i386/pc.c +39 -70

109 lines not on this page · raw message

hw/ide/qdev.c +6 -9
index 6fba6b62b8..58fbb9263b 100644

Lines of this file are not shown. View the raw message.

hw/input/virtio-input.c +4 -8
index 51617a5885..ff2c849e68 100644

Lines of this file are not shown. View the raw message.

hw/intc/apic_common.c +2 -4
index aafd8e0e33..38c1b5b5c5 100644

Lines of this file are not shown. View the raw message.

hw/intc/arm_gic.c +2 -4
index 1d7da7baa2..8c340e2e28 100644

Lines of this file are not shown. View the raw message.

hw/intc/arm_gic_kvm.c +4 -7
index b56fda144f..beb9476c1e 100644

Lines of this file are not shown. View the raw message.

hw/intc/arm_gicv3.c +4 -7
index 66eaa97198..0074733d25 100644

Lines of this file are not shown. View the raw message.

hw/intc/arm_gicv3_its_kvm.c +2 -4
index d66f2431ee..e5c3a83613 100644

Lines of this file are not shown. View the raw message.

hw/intc/arm_gicv3_kvm.c +6 -10
index 9c7f4ab871..e25067b659 100644

Lines of this file are not shown. View the raw message.

hw/intc/armv7m_nvic.c +4 -7
index 8e93e51e81..2f84185e8b 100644

Lines of this file are not shown. View the raw message.

hw/intc/nios2_iic.c +2 -3
index 3a5d86c2a4..c24651cafd 100644

Lines of this file are not shown. View the raw message.

hw/intc/pnv_xive.c +5 -9
index ed6e9d71bb..57855e0da3 100644

Lines of this file are not shown. View the raw message.

hw/intc/realview_gic.c +2 -4
index 73fe8cd815..55ac9100b0 100644

Lines of this file are not shown. View the raw message.

hw/intc/s390_flic_kvm.c +4 -6
index 819aa5e198..57fb678823 100644

Lines of this file are not shown. View the raw message.

hw/intc/spapr_xive.c +4 -7
index c1c97192a7..5159f35df7 100644

Lines of this file are not shown. View the raw message.

hw/intc/spapr_xive_kvm.c +18 -31

49 lines not on this page · raw message

hw/intc/xics.c +12 -19
index b2fca2975c..60523f0241 100644

Lines of this file are not shown. View the raw message.

hw/intc/xics_kvm.c +12 -16
index a4d2e876cc..a51f2fe4e8 100644

Lines of this file are not shown. View the raw message.

hw/intc/xics_pnv.c +2 -4
index 35f3811264..5028e5897d 100644

Lines of this file are not shown. View the raw message.

hw/intc/xive.c +7 -16
index b7417210d8..f161e1d650 100644

Lines of this file are not shown. View the raw message.

hw/ipack/ipack.c +1 -3
index 30e16696c0..dc66fe62d8 100644

Lines of this file are not shown. View the raw message.

hw/isa/pc87312.c +2 -4
index b9bd57471e..acef6fd670 100644

Lines of this file are not shown. View the raw message.

hw/mem/memory-device.c +8 -11
index 53953fdc3a..ed9c421150 100644

Lines of this file are not shown. View the raw message.

hw/mem/nvdimm.c +9 -14
index 375f9a588a..5b0a969d83 100644

Lines of this file are not shown. View the raw message.

hw/mem/pc-dimm.c +8 -13
index 99e2faf01b..3f0d696cf8 100644

Lines of this file are not shown. View the raw message.

hw/microblaze/xlnx-zynqmp-pmu.c +4 -7
index 028f31894d..f8edb32c8c 100644

Lines of this file are not shown. View the raw message.

hw/mips/cps.c +20 -25

45 lines not on this page · raw message

hw/misc/arm11scu.c +1 -0
index 3023284d6f..befc85f321 100644

Lines of this file are not shown. View the raw message.

hw/misc/bcm2835_mbox.c +2 -3
index 79bad11631..ab59d874cb 100644

Lines of this file are not shown. View the raw message.

hw/misc/bcm2835_property.c +4 -5
index d86d510572..eebda73a94 100644

Lines of this file are not shown. View the raw message.

hw/misc/ivshmem.c +12 -21
index 5e3b05eae0..136a8874ed 100644

Lines of this file are not shown. View the raw message.

hw/misc/macio/macio.c +25 -40

65 lines not on this page · raw message

hw/misc/mps2-scc.c +1 -0
index 25779a1dca..f2a00d3235 100644

Lines of this file are not shown. View the raw message.

hw/misc/tmp105.c +2 -4
index 75ddad3a12..480eae23dd 100644

Lines of this file are not shown. View the raw message.

hw/misc/tmp421.c +2 -4
index 9f044705fa..cdb42379c4 100644

Lines of this file are not shown. View the raw message.

hw/net/dp8393x.c +2 -4
index a5678e11fa..9c4cd39083 100644

Lines of this file are not shown. View the raw message.

hw/net/eepro100.c +2 -4
index cc2dd8b1c9..616083b662 100644

Lines of this file are not shown. View the raw message.

hw/net/ne2000-isa.c +6 -10
index 6fcf3d5cd9..43a6ee7f3d 100644

Lines of this file are not shown. View the raw message.

hw/net/xilinx_axienet.c +6 -8
index 2c8c065401..5f87a6336b 100644

Lines of this file are not shown. View the raw message.

hw/nvram/fw_cfg.c +4 -8
index 7dc3ac378e..6f4d102cf3 100644

Lines of this file are not shown. View the raw message.

hw/nvram/nrf51_nvm.c +2 -4
index 4d678f994e..396f72b2b0 100644

Lines of this file are not shown. View the raw message.

hw/pci-bridge/dec.c +1 -0
index 3ae2f788a4..fbe781474e 100644

Lines of this file are not shown. View the raw message.

hw/pci-bridge/gen_pcie_root_port.c +2 -4
index 9eaefebca8..bfb288ccf7 100644

Lines of this file are not shown. View the raw message.

hw/pci-bridge/pci_bridge_dev.c +5 -7
index cc80cb4898..0069322a3a 100644

Lines of this file are not shown. View the raw message.

hw/pci-bridge/pci_expander_bridge.c +2 -4
index 0592818447..b9e87e8158 100644

Lines of this file are not shown. View the raw message.

hw/pci-bridge/pcie_pci_bridge.c +2 -5
index 7679bef6c1..00065c3aa8 100644

Lines of this file are not shown. View the raw message.

hw/pci-host/piix.c +2 -4
index 135c645535..319fa71e52 100644

Lines of this file are not shown. View the raw message.

hw/pci/pci.c +6 -11
index aa05c2b9b2..42f5fb49fa 100644

Lines of this file are not shown. View the raw message.

hw/pci/pcie.c +2 -4
index a6beb567bd..3a688d54b0 100644

Lines of this file are not shown. View the raw message.

hw/pci/shpc.c +4 -8
index 7f0aa28e44..2cfb7942da 100644

Lines of this file are not shown. View the raw message.

hw/ppc/e500.c +2 -4
index 91cd4c26f9..7b79a18a9f 100644

Lines of this file are not shown. View the raw message.

hw/ppc/pnv.c +34 -58

92 lines not on this page · raw message

hw/ppc/pnv_core.c +8 -13
index b1a7489e7a..ac7bc78e3a 100644

Lines of this file are not shown. View the raw message.

hw/ppc/pnv_lpc.c +7 -15
index 9466d4a1be..68dd4b720f 100644

Lines of this file are not shown. View the raw message.

hw/ppc/pnv_occ.c +1 -3
index 8bead2c930..248aac6757 100644

Lines of this file are not shown. View the raw message.

hw/ppc/pnv_psi.c +8 -13
index 88ba8e7b9b..7e31712a31 100644

Lines of this file are not shown. View the raw message.

hw/ppc/spapr.c +49 -72

121 lines not on this page · raw message

hw/ppc/spapr_caps.c +19 -31

50 lines not on this page · raw message

hw/ppc/spapr_cpu_core.c +12 -18
index 1d93de8161..93f9b0e0c9 100644

Lines of this file are not shown. View the raw message.

hw/ppc/spapr_drc.c +16 -28

44 lines not on this page · raw message

hw/ppc/spapr_irq.c +33 -62

95 lines not on this page · raw message

hw/ppc/spapr_pci.c +33 -55

88 lines not on this page · raw message

hw/ppc/spapr_vio.c +4 -7
index 0803649658..625957a2cd 100644

Lines of this file are not shown. View the raw message.

hw/riscv/riscv_hart.c +2 -5
index 5b98227db6..7e21738bbb 100644

Lines of this file are not shown. View the raw message.

hw/riscv/sifive_e.c +2 -4
index 0f9d641a0e..17f19ff338 100644

Lines of this file are not shown. View the raw message.

hw/riscv/sifive_u.c +4 -6
index 9f8e84bf2e..7eecf31a3d 100644

Lines of this file are not shown. View the raw message.

hw/s390x/3270-ccw.c +5 -7
index c19a75b9b7..fb954bd952 100644

Lines of this file are not shown. View the raw message.

hw/s390x/css-bridge.c +2 -4
index 15a8ed96de..c423c43e6d 100644

Lines of this file are not shown. View the raw message.

hw/s390x/css.c +2 -4
index 844caab408..d201aed5cc 100644

Lines of this file are not shown. View the raw message.

hw/s390x/ipl.c +10 -13
index ca544d64c5..d25f2ca200 100644

Lines of this file are not shown. View the raw message.

hw/s390x/s390-ccw.c +6 -8
index 0c5a5b60bd..0ae1951507 100644

Lines of this file are not shown. View the raw message.

hw/s390x/s390-pci-bus.c +13 -21
index 963a41c7f5..200b9626dd 100644

Lines of this file are not shown. View the raw message.

hw/s390x/s390-skeys.c +2 -4
index bd37f39120..6963ff9cde 100644

Lines of this file are not shown. View the raw message.

hw/s390x/s390-virtio-ccw.c +4 -6
index 8bfb6684cb..966de57826 100644

Lines of this file are not shown. View the raw message.

hw/s390x/sclp.c +5 -9
index fac7c3bb6c..5d8778bf2a 100644

Lines of this file are not shown. View the raw message.

hw/s390x/tod-kvm.c +4 -9
index 6e21d83181..096966521c 100644

Lines of this file are not shown. View the raw message.

hw/s390x/virtio-ccw-crypto.c +2 -4
index 086b397ad2..d042e74bcd 100644

Lines of this file are not shown. View the raw message.

hw/s390x/virtio-ccw-rng.c +2 -4
index 854254dd50..20b0e84250 100644

Lines of this file are not shown. View the raw message.

hw/s390x/virtio-ccw.c +5 -7
index 6580ce5907..7cd1ec4862 100644

Lines of this file are not shown. View the raw message.

hw/scsi/esp-pci.c +2 -4
index d5a1f9e017..966b509ef0 100644

Lines of this file are not shown. View the raw message.

hw/scsi/megasas.c +4 -6
index de9bd20887..8907915f49 100644

Lines of this file are not shown. View the raw message.

hw/scsi/mptsas.c +5 -7
index b8a4b37cf3..71edc9e38a 100644

Lines of this file are not shown. View the raw message.

hw/scsi/scsi-bus.c +8 -14
index bccb7cc4c6..c238e8ea2d 100644

Lines of this file are not shown. View the raw message.

hw/scsi/scsi-disk.c +2 -4
index 915641a0f1..bc6306d38e 100644

Lines of this file are not shown. View the raw message.

hw/scsi/vhost-scsi.c +4 -7
index c693fc748a..91783a91f7 100644

Lines of this file are not shown. View the raw message.

hw/scsi/vhost-user-scsi.c +2 -4
index 6a6c15dd32..c211dc5998 100644

Lines of this file are not shown. View the raw message.

hw/scsi/virtio-scsi.c +2 -4
index ee52aa7d17..aab0b318e7 100644

Lines of this file are not shown. View the raw message.

hw/sd/milkymist-memcard.c +5 -5
index 926e1af475..8ac2c84515 100644

Lines of this file are not shown. View the raw message.

hw/sd/sdhci-pci.c +2 -4
index 2c8d8f59b5..27470a1a8f 100644

Lines of this file are not shown. View the raw message.

hw/sd/sdhci.c +6 -14
index e08ec3e398..f95a49619d 100644

Lines of this file are not shown. View the raw message.

hw/sd/ssi-sd.c +7 -6
index 91db069212..1810d89f31 100644

Lines of this file are not shown. View the raw message.

hw/smbios/smbios.c +16 -25

41 lines not on this page · raw message

hw/sparc/sun4m.c +6 -12
index 6c5a17a020..806238798b 100644

Lines of this file are not shown. View the raw message.

hw/sparc64/sun4u.c +2 -4
index 1ded2a4c9a..9f1043f58e 100644

Lines of this file are not shown. View the raw message.

hw/timer/aspeed_timer.c +3 -3
index 2bda826882..0ef8669aa6 100644

Lines of this file are not shown. View the raw message.

hw/tpm/tpm_util.c +2 -4
index 62b091f0c0..4e30235c5d 100644

Lines of this file are not shown. View the raw message.

hw/usb/bus.c +12 -21
index a6522f5429..8517f496fd 100644

Lines of this file are not shown. View the raw message.

hw/usb/dev-serial.c +2 -4
index 45cc74128a..d6ff55baf6 100644

Lines of this file are not shown. View the raw message.

hw/usb/dev-smartcard-reader.c +4 -8
index 4568db2568..cbdf2d9658 100644

Lines of this file are not shown. View the raw message.

hw/usb/dev-storage.c +6 -10
index 8545193488..cd670f8e44 100644

Lines of this file are not shown. View the raw message.

hw/usb/hcd-ohci-pci.c +2 -4
index c052f10521..be76b441c4 100644

Lines of this file are not shown. View the raw message.

hw/usb/hcd-ohci.c +4 -8
index 145ee21fd6..14e002e4b5 100644

Lines of this file are not shown. View the raw message.

hw/usb/hcd-uhci.c +2 -4
index 23507ad3b5..6f6ee790fd 100644

Lines of this file are not shown. View the raw message.

hw/usb/hcd-xhci.c +5 -7
index 80988bb305..fb3fcbbd3d 100644

Lines of this file are not shown. View the raw message.

hw/vfio/ap.c +2 -4
index da6a20669d..e072a08f1d 100644

Lines of this file are not shown. View the raw message.

hw/vfio/ccw.c +9 -11
index 6863f6c69f..d2b526667e 100644

Lines of this file are not shown. View the raw message.

hw/vfio/pci-quirks.c +2 -4
index 136f3a9ad6..c7bc17ed8a 100644

Lines of this file are not shown. View the raw message.

hw/vfio/pci.c +13 -23
index dc3479c374..839dda3424 100644

Lines of this file are not shown. View the raw message.

hw/virtio/virtio-balloon.c +14 -19
index 40b04f5180..afe6448c7b 100644

Lines of this file are not shown. View the raw message.

hw/virtio/virtio-bus.c +6 -10
index b2c804292e..5c54cead72 100644

Lines of this file are not shown. View the raw message.

hw/virtio/virtio-rng-pci.c +2 -4
index 8aaf54b781..8978c0bbe1 100644

Lines of this file are not shown. View the raw message.

hw/virtio/virtio-rng.c +2 -4
index e93bed020f..aeb3aac1fa 100644

Lines of this file are not shown. View the raw message.

hw/virtio/virtio.c +6 -11
index 527df03bfd..75ad25b120 100644

Lines of this file are not shown. View the raw message.

hw/watchdog/wdt_aspeed.c +1 -3
index 9b93213417..43b262c3c0 100644

Lines of this file are not shown. View the raw message.

hw/xen/xen-backend.c +2 -4
index da065f81b7..e55520f97c 100644

Lines of this file are not shown. View the raw message.

hw/xen/xen-bus.c +36 -49

85 lines not on this page · raw message

hw/xen/xen-host-pci-device.c +12 -14
index 1b44dcafaf..6bb65bf567 100644

Lines of this file are not shown. View the raw message.

hw/xen/xen_pt.c +10 -14
index 8fbaf2eae9..8d4cf7291f 100644

Lines of this file are not shown. View the raw message.

hw/xen/xen_pt_config_init.c +9 -10
index 31ec5add1d..bc1feacc3c 100644

Lines of this file are not shown. View the raw message.

io/dns-resolver.c +2 -4
index 6ebe2a5650..1aab5cfef2 100644

Lines of this file are not shown. View the raw message.

io/net-listener.c +2 -4
index 5d8a226872..73a8a71449 100644

Lines of this file are not shown. View the raw message.

iothread.c +9 -16
index 7130be58e3..b977e5c1b0 100644

Lines of this file are not shown. View the raw message.

job.c +2 -4
index 04409b40aa..b0adde1670 100644

Lines of this file are not shown. View the raw message.

memory.c +18 -36

54 lines not on this page · raw message

memory_mapping.c +2 -4
index 18d0b8067c..33103c16d3 100644

Lines of this file are not shown. View the raw message.

migration/colo.c +12 -21
index 2c88aa57a2..31dac8c0bd 100644

Lines of this file are not shown. View the raw message.

migration/migration.c +13 -22
index 01863a95f5..9309008555 100644

Lines of this file are not shown. View the raw message.

migration/ram.c +5 -7
index 01df326767..6935afe2ea 100644

Lines of this file are not shown. View the raw message.

migration/rdma.c +4 -7
index 78e6b72bac..2b40157240 100644

Lines of this file are not shown. View the raw message.

migration/socket.c +6 -10
index 97c9efde59..ca4326e02c 100644

Lines of this file are not shown. View the raw message.

monitor/misc.c +3 -5
index aef16f6cfb..feadf9780c 100644

Lines of this file are not shown. View the raw message.

monitor/qmp-cmds.c +2 -4
index 0880341a2d..d85b6693e5 100644

Lines of this file are not shown. View the raw message.

net/can/can_host.c +2 -4
index 1dfaf0ced0..e9b4ac9075 100644

Lines of this file are not shown. View the raw message.

net/dump.c +5 -9
index 23b3628dde..ac6900e34f 100644

Lines of this file are not shown. View the raw message.

net/filter-buffer.c +5 -9
index 88da78f821..69f37e273b 100644

Lines of this file are not shown. View the raw message.

net/filter.c +2 -4
index 4b932e79f9..114723a6db 100644

Lines of this file are not shown. View the raw message.

net/net.c +15 -23
index 5fc72511c1..ea8975b219 100644

Lines of this file are not shown. View the raw message.

net/netmap.c +2 -4
index 350f097f91..57c7dcdaed 100644

Lines of this file are not shown. View the raw message.

net/slirp.c +2 -4
index f42f496641..121bc8e6ab 100644

Lines of this file are not shown. View the raw message.

net/tap-bsd.c +1 -0
index a5c3707f80..0eb836a020 100644

Lines of this file are not shown. View the raw message.

net/tap-solaris.c +1 -0
index 4725d2314e..14f201fced 100644

Lines of this file are not shown. View the raw message.

net/tap-stub.c +1 -0
index a9ab8f8293..32abb54bc9 100644

Lines of this file are not shown. View the raw message.

net/tap.c +16 -28

44 lines not on this page · raw message

qapi/opts-visitor.c +1 -0
index 324b197495..35c510c959 100644

Lines of this file are not shown. View the raw message.

qapi/qapi-dealloc-visitor.c +7 -0
index d192724b13..3ee4c7a2e7 100644

Lines of this file are not shown. View the raw message.

qapi/qapi-visit-core.c +16 -37

53 lines not on this page · raw message

qapi/qmp-dispatch.c +2 -4
index 3037d353a4..5c75322a7d 100644

Lines of this file are not shown. View the raw message.

qapi/string-input-visitor.c +2 -4
index 9be418b6d6..302c5ddadf 100644

Lines of this file are not shown. View the raw message.

qdev-monitor.c +14 -23
index 148df9cacf..dd17ad4967 100644

Lines of this file are not shown. View the raw message.

qga/commands-posix.c +74 -123

197 lines not on this page · raw message

qga/commands-win32.c +48 -79

127 lines not on this page · raw message

qom/object.c +70 -117

187 lines not on this page · raw message

qom/object_interfaces.c +12 -14
index cb5809934a..58bb78e4e9 100644

Lines of this file are not shown. View the raw message.

qom/qom-qobject.c +2 -4
index c3b95aa354..6a76a3fc5a 100644

Lines of this file are not shown. View the raw message.

replication.c +8 -16
index be3a42f9c9..d98966934e 100644

Lines of this file are not shown. View the raw message.

scsi/pr-manager-helper.c +2 -4
index ca27c93283..c39fc429f7 100644

Lines of this file are not shown. View the raw message.

stubs/xen-hvm.c +2 -0
index b7d53b5e2f..840a2a0d09 100644

Lines of this file are not shown. View the raw message.

target/alpha/cpu.c +2 -4
index b3fd6643e8..0e305cb1f6 100644

Lines of this file are not shown. View the raw message.

target/arm/cpu.c +2 -4
index 2399c14471..110c28bdbe 100644

Lines of this file are not shown. View the raw message.

target/arm/cpu64.c +4 -6
index d7f5bf610a..5520c71863 100644

Lines of this file are not shown. View the raw message.

target/cris/cpu.c +2 -4
index 7adfd6caf4..6f54341093 100644

Lines of this file are not shown. View the raw message.

target/hppa/cpu.c +2 -4
index 71b6aca45d..b98b26b521 100644

Lines of this file are not shown. View the raw message.

target/i386/cpu.c +42 -65

107 lines not on this page · raw message

target/lm32/cpu.c +2 -4
index b35537de62..550e851fef 100644

Lines of this file are not shown. View the raw message.

target/m68k/cpu.c +2 -4
index e6596de29c..2c7af9df5f 100644

Lines of this file are not shown. View the raw message.

target/microblaze/cpu.c +2 -4
index 9cfd7445e7..b893b18675 100644

Lines of this file are not shown. View the raw message.

target/mips/cpu.c +2 -4
index bbcf7ca463..4bc17ef036 100644

Lines of this file are not shown. View the raw message.

target/moxie/cpu.c +2 -4
index 48996d0554..49f7764619 100644

Lines of this file are not shown. View the raw message.

target/nios2/cpu.c +2 -4
index ca9c7a6df5..8c617fd657 100644

Lines of this file are not shown. View the raw message.

target/openrisc/cpu.c +2 -4
index 506aec6bfb..cd8efc6d2d 100644

Lines of this file are not shown. View the raw message.

target/ppc/compat.c +6 -12
index 7de4bf3122..a82d8d1056 100644

Lines of this file are not shown. View the raw message.

target/ppc/kvm.c +2 -4
index 8c5b1f25cc..bad73ff036 100644

Lines of this file are not shown. View the raw message.

target/ppc/translate_init.inc.c +8 -15
index 0fb11c7ac6..8ec93169b3 100644

Lines of this file are not shown. View the raw message.

target/riscv/cpu.c +2 -4
index f13e298a36..08aef7c77d 100644

Lines of this file are not shown. View the raw message.

target/s390x/cpu.c +11 -14
index 3abe7e80fd..11ce0c2114 100644

Lines of this file are not shown. View the raw message.

target/s390x/kvm-stub.c +1 -0
index 5152e2bdf1..2472ed6239 100644

Lines of this file are not shown. View the raw message.

target/sh4/cpu.c +2 -4
index d0a7707991..787bb53010 100644

Lines of this file are not shown. View the raw message.

target/sparc/cpu.c +4 -8
index bc65929552..853b6277fc 100644

Lines of this file are not shown. View the raw message.

target/tilegx/cpu.c +2 -4
index 2b2a7ccc31..4190974aaf 100644

Lines of this file are not shown. View the raw message.

target/tricore/cpu.c +2 -4
index df807c1d74..f7a19d309c 100644

Lines of this file are not shown. View the raw message.

target/unicore32/cpu.c +2 -4
index b27fb9689f..7bf74222f7 100644

Lines of this file are not shown. View the raw message.

target/xtensa/cpu.c +2 -4
index c65dcf9dd7..b2b9617f81 100644

Lines of this file are not shown. View the raw message.

tests/test-image-locking.c +2 -4
index ba057bd66c..49c6c9ed7b 100644

Lines of this file are not shown. View the raw message.

tests/test-qmp-cmds.c +7 -0
index ab389f42da..3cf918ab6e 100644

Lines of this file are not shown. View the raw message.

tpm.c +2 -4
index 9c9e20bbb7..a3a0eb76f0 100644

Lines of this file are not shown. View the raw message.

trace/qmp.c +4 -8
index 38246e1aa6..1fc19d2eb0 100644

Lines of this file are not shown. View the raw message.

ui/input-barrier.c +2 -4
index a2c961f285..84491744c5 100644

Lines of this file are not shown. View the raw message.

ui/input.c +4 -8
index 4791b089c7..276c34900e 100644

Lines of this file are not shown. View the raw message.

ui/vnc.c +6 -11
index 9d6384d9b1..37721e971b 100644

Lines of this file are not shown. View the raw message.

util/main-loop.c +1 -3
index e3eaa55866..6f3492d943 100644

Lines of this file are not shown. View the raw message.

util/oslib-posix.c +2 -3
index f8693384fc..b1671f11e6 100644

Lines of this file are not shown. View the raw message.

util/qemu-config.c +10 -17
index 772f5a219e..b0266f9954 100644

Lines of this file are not shown. View the raw message.

util/qemu-option.c +17 -33

50 lines not on this page · raw message

util/qemu-sockets.c +8 -17
index 98ff3a1cce..9832d8278d 100644

Lines of this file are not shown. View the raw message.

vl.c +4 -9
index 630f5c5e9c..21f5679964 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.21.0

Part of the diff is not shown here. View the raw message.

#16 lore raw

Re: [RFC v2 7/9] Use auto-propagated errp

Quoted 6 lines · Vladimir Sementsov-Ogievskiy

This commit is generated by command

git grep -l 'Error \*\*errp' | while read f; \
do spatch --sp-file \
scripts/coccinelle/auto-propagated-errp.cocci --in-place $f; done

As mentioned in your cover letter, this fails syntax-check and compilation without squashing in some followups; if we can't improve the .cocci script to do it automatically, then manually squashing in cleanups (and documenting what types of cleanups they were) is fine. (The goal for a mechanical patch like this is to make it easy enough to automate downstream, even where the file contents are changed, but where the process for creating those changes are the same).

Quoted 2 lines

---

Spot-checking

Quoted 5 lines
 block/io.c                          |  11 +-
 block/nbd.c                         |  44 +++---
 qapi/qapi-visit-core.c              |  53 ++-----

just to see how it looks.

block/io.c static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) · line 139

Quoted 7 lines

+++ b/block/io.c

block/io.c +0 -1
@@ -136,7 +136,6 @@ static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
 void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
 {
     BlockDriver *drv = bs->drv;
-    Error *local_err = NULL;
 

Umm, no insertion of ERR_FUNCTION_BEGIN(). Oops.

Quoted 15 lines
block/io.c +2 -3
     memset(&bs->bl, 0, sizeof(bs->bl));
 
@@ -151,9 +150,8 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
 
     /* Take some limits from the children as a default */
     if (bs->file) {
-        bdrv_refresh_limits(bs->file->bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_refresh_limits(bs->file->bs, errp);
+        if (*errp) {
             return;
         }
         bdrv_merge_limits(&bs->bl, &bs->file->bs->bl);

block/io.c void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) · line 169

Quoted 9 lines
block/io.c +2 -3
@@ -166,9 +164,8 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
     }
 
     if (bs->backing) {
-        bdrv_refresh_limits(bs->backing->bs, &local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
+        bdrv_refresh_limits(bs->backing->bs, errp);
+        if (*errp) {
             return;

Rest of the changes in this file are good if the macro gets added correctly.

block/io.c static int nbd_co_receive_cmdread_reply(BDRVNBDState *s, uint64_t handle, · line 811

Quoted 9 lines
block/io.c +1 -1
         }
         bdrv_merge_limits(&bs->bl, &bs->backing->bs->bl);
 
+++ b/block/nbd.c
@@ -808,7 +808,6 @@ static int nbd_co_receive_cmdread_reply(BDRVNBDState *s, uint64_t handle,
     NBDReplyChunkIter iter;
     NBDReply reply;
     void *payload = NULL;
-    Error *local_err = NULL;

Recurring problem of not inserting the macro as expected.

Quoted 12 lines
block/nbd.c +1 -2
     NBD_FOREACH_REPLY_CHUNK(s, iter, handle, s->info.structured_reply,
                             qiov, &reply, &payload)
@@ -827,20 +826,20 @@ static int nbd_co_receive_cmdread_reply(BDRVNBDState *s, uint64_t handle,
             break;
         case NBD_REPLY_TYPE_OFFSET_HOLE:
             ret = nbd_parse_offset_hole_payload(s, &reply.structured, payload,
-                                                offset, qiov, &local_err);
+                                                offset, qiov, errp);
             if (ret < 0) {
                 nbd_channel_error(s, ret);
-                nbd_iter_channel_error(&iter, ret, &local_err);

block/nbd.c static int nbd_co_receive_cmdread_reply(BDRVNBDState *s, uint64_t handle, · line 840

Quoted 10 lines
block/nbd.c +2 -1
+                nbd_iter_channel_error(&iter, ret, errp);
             }
             break;
         default:
             if (!nbd_reply_type_is_error(chunk->type)) {
                 /* not allowed reply type */
                 nbd_channel_error(s, -EINVAL);
-                error_setg(&local_err,
+                error_setg(errp,
                            "Unexpected reply type: %d (%s) for CMD_READ",

Could almost fold these lines (but I'm not asking you to; keeping this patch as mechanical as possible is fine).

block/nbd.c static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s, · line 863

Quoted 12 lines
block/nbd.c +1 -2
                            chunk->type, nbd_reply_type_lookup(chunk->type));
-                nbd_iter_channel_error(&iter, -EINVAL, &local_err);
+                nbd_iter_channel_error(&iter, -EINVAL, errp);
             }
         }
 
@@ -861,7 +860,6 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
     NBDReplyChunkIter iter;
     NBDReply reply;
     void *payload = NULL;
-    Error *local_err = NULL;
     bool received = false;

Oops on the macro.

Quoted 6 lines
block/nbd.c +0 -1
@@ -1174,15 +1172,13 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
                                                   Error **errp)
 {
     QIOChannelSocket *sioc;
-    Error *local_err = NULL;
 

block/nbd.c static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, · line 1182

Quoted 10 lines
block/nbd.c +2 -3
     sioc = qio_channel_socket_new();
     qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
 
-    qio_channel_socket_connect_sync(sioc, saddr, &local_err);
-    if (local_err) {
+    qio_channel_socket_connect_sync(sioc, saddr, errp);
+    if (*errp) {
         object_unref(OBJECT(sioc));
-        error_propagate(errp, local_err);
         return NULL;

But getting rid of error_propagate() is nice.

Did you grep for instances of error_propagate() after your mechanical patch, to see what else the Coccinelle script might have missed?

qapi/opts-visitor.c opts_next_list(Visitor *v, GenericList *tail, size_t size) · line 281

Quoted 9 lines
qapi/opts-visitor.c +2 -0
+++ b/qapi/opts-visitor.c
@@ -275,6 +275,7 @@ opts_next_list(Visitor *v, GenericList *tail, size_t size)
 static void
 opts_check_list(Visitor *v, Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
     /*
      * Unvisited list elements will be reported later when checking
      * whether unvisited struct members remain.

Here the macro got added, but with no obvious benefit later on (although we also argued that adding it even when it makes no difference is not bad, if that's easier to automate for style checking).

qapi/qapi-dealloc-visitor.c struct QapiDeallocVisitor · line 29

Quoted 10 lines
qapi/qapi-dealloc-visitor.c +1 -0
index d192724b13..3ee4c7a2e7 100644
@@ -25,6 +25,7 @@ struct QapiDeallocVisitor
 static void qapi_dealloc_start_struct(Visitor *v, const char *name, void **obj,
                                       size_t unused, Error **errp)
 {
+	ERRP_FUNCTION_BEGIN();
 }

Here's an example where exempting empty functions would be nicer.

qapi/qapi-dealloc-visitor.c void visit_free(Visitor *v) · line 43

Quoted 7 lines
qapi/qapi-dealloc-visitor.c +1 -2
+++ b/qapi/qapi-visit-core.c
@@ -39,18 +39,15 @@ void visit_free(Visitor *v)
 void visit_start_struct(Visitor *v, const char *name, void **obj,
                         size_t size, Error **errp)
 {
-    Error *err = NULL;
-

Oops, macro not added.

qapi/qapi-dealloc-visitor.c void visit_free(Visitor *v) · line 51

Quoted 13 lines
qapi/qapi-dealloc-visitor.c +2 -3
     trace_visit_start_struct(v, name, obj, size);
     if (obj) {
         assert(size);
         assert(!(v->type & VISITOR_OUTPUT) || *obj);
     }
-    v->start_struct(v, name, obj, size, &err);
+    v->start_struct(v, name, obj, size, errp);
     if (obj && (v->type & VISITOR_INPUT)) {
-        assert(!err != !*obj);
+        assert(!*errp != !*obj);
     }
-    error_propagate(errp, err);
 }

But the cleanup is sane, once the macro is present.

Quoted 5 lines
qapi/qapi-dealloc-visitor.c +0 -1
@@ -152,12 +143,10 @@ void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp)
 static void visit_type_uintN(Visitor *v, uint64_t *obj, const char *name,
                              uint64_t max, const char *type, Error **errp)
 {
-    Error *err = NULL;

qapi/qapi-dealloc-visitor.c void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp) · line 152

Quoted 10 lines
qapi/qapi-dealloc-visitor.c +2 -3
     uint64_t value = *obj;
 
-    v->type_uint64(v, name, &value, &err);
-    if (err) {
-        error_propagate(errp, err);
+    v->type_uint64(v, name, &value, errp);
+    if (*errp) {
     } else if (value > max) {
         error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                    name ? name : "null", type);

Results in an empty if which looks funny. This one could be a manual touchup later.

qapi/qapi-dealloc-visitor.c static void visit_type_intN(Visitor *v, int64_t *obj, const char *name, · line 207

Quoted 13 lines
qapi/qapi-dealloc-visitor.c +2 -4
@@ -211,12 +200,10 @@ static void visit_type_intN(Visitor *v, int64_t *obj, const char *name,
                             int64_t min, int64_t max, const char *type,
                             Error **errp)
 {
-    Error *err = NULL;
     int64_t value = *obj;
 
-    v->type_int64(v, name, &value, &err);
-    if (err) {
-        error_propagate(errp, err);
+    v->type_int64(v, name, &value, errp);
+    if (*errp) {
     } else if (value < min || value > max) {

and again

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#17 lore raw

Re: [RFC v2 7/9] Use auto-propagated errp

Quoted 29 lines · Eric Blake
Quoted 6 lines · Vladimir Sementsov-Ogievskiy

This commit is generated by command

git grep -l 'Error \*\*errp' | while read f; \
do spatch --sp-file \
scripts/coccinelle/auto-propagated-errp.cocci --in-place $f; done

As mentioned in your cover letter, this fails syntax-check and compilation without squashing in some followups; if we can't improve the .cocci script to do it automatically, then manually squashing in cleanups (and documenting what types of cleanups they were) is fine. (The goal for a mechanical patch like this is to make it easy enough to automate downstream, even where the file contents are changed, but where the process for creating those changes are the same).

Quoted 2 lines

---

Spot-checking

Quoted 5 lines
  block/io.c                          |  11 +-
  block/nbd.c                         |  44 +++---
  qapi/qapi-visit-core.c              |  53 ++-----

just to see how it looks.

Quoted 9 lines

block/io.c static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) · line 139

Quoted 7 lines

+++ b/block/io.c

block/io.c +0 -1
@@ -136,7 +136,6 @@ static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
  void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
  {
      BlockDriver *drv = bs->drv;
-    Error *local_err = NULL;
 

Umm, no insertion of ERR_FUNCTION_BEGIN(). Oops.

Oops. Seems I injected it _only_ to empty functions. It's because I missed '...' in first hunk.

Signature · 2 lines
Best regards,
Vladimir
#18 lore raw

RFC v2 8/9 fix-compilation: empty goto

In reply to Vladimir Sementsov-Ogievskiy

I don't understand, why these special cases are not handled by coccinelle. Possibly, it's a bug in coccinelle itself.

If no other ideas, these fixes may be just merged to autogenerated commit(commits), with appropriate notice in commit message.

---
 backends/cryptodev.c    | 7 -------
 hw/dma/xilinx_axidma.c  | 7 ++-----
 hw/net/xilinx_axienet.c | 7 ++-----
 hw/ppc/spapr.c          | 3 +--
 hw/ppc/spapr_cpu_core.c | 3 +--
 hw/s390x/s390-ccw.c     | 3 +--
 hw/vfio/ap.c            | 3 +--
 hw/vfio/ccw.c           | 3 +--
 8 files changed, 9 insertions(+), 27 deletions(-)
backends/cryptodev.c +0 -7
index dcdb8481b2..aa4a62ace0 100644
@@ -176,14 +176,7 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
 
     if (bc->init) {
         bc->init(backend, errp);
-        if (*errp) {
-            goto out;
-        }
     }
-
-    return;
-
-out:
 }
 
 void cryptodev_backend_set_used(CryptoDevBackend *backend, bool used)
hw/dma/xilinx_axidma.c +2 -5
index b5f49e6f88..b5456f5db2 100644
@@ -536,12 +536,12 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
                              OBJ_PROP_LINK_STRONG,
                              errp);
     if (*errp) {
-        goto xilinx_axidma_realize_fail;
+        return;
     }
     object_property_set_link(OBJECT(ds), OBJECT(s), "dma", errp);
     object_property_set_link(OBJECT(cs), OBJECT(s), "dma", errp);
     if (*errp) {
-        goto xilinx_axidma_realize_fail;
+        return;
     }
 
     int i;
@@ -554,9 +554,6 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
         st->ptimer = ptimer_init(st->bh, PTIMER_POLICY_DEFAULT);
         ptimer_set_freq(st->ptimer, s->freqhz);
     }
-    return;
-
-xilinx_axidma_realize_fail:
 }
 
 static void xilinx_axidma_init(Object *obj)
hw/net/xilinx_axienet.c +2 -5
index 5f87a6336b..372ca88956 100644
@@ -963,12 +963,12 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
                              OBJ_PROP_LINK_STRONG,
                              errp);
     if (*errp) {
-        goto xilinx_enet_realize_fail;
+        return;
     }
     object_property_set_link(OBJECT(ds), OBJECT(s), "enet", errp);
     object_property_set_link(OBJECT(cs), OBJECT(s), "enet", errp);
     if (*errp) {
-        goto xilinx_enet_realize_fail;
+        return;
     }
 
     qemu_macaddr_default_if_unset(&s->conf.macaddr);
@@ -982,9 +982,6 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
     s->TEMAC.parent = s;
 
     s->rxmem = g_malloc(s->c_rxmem);
-    return;
-
-xilinx_enet_realize_fail:
 }
 
 static void xilinx_enet_init(Object *obj)
hw/ppc/spapr.c +1 -2
index 5ef043bd72..7b0ab71f23 100644
@@ -3503,7 +3503,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 
     pc_dimm_plug(dimm, MACHINE(ms), errp);
     if (*errp) {
-        goto out;
+        return;
     }
 
     addr = object_property_get_uint(OBJECT(dimm),
@@ -3522,7 +3522,6 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 
 out_unplug:
     pc_dimm_unplug(dimm, MACHINE(ms));
-out:
 }
 
 static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
hw/ppc/spapr_cpu_core.c +1 -2
index 93f9b0e0c9..c35696ff42 100644
@@ -224,7 +224,7 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
 
     object_property_set_bool(OBJECT(cpu), true, "realized", errp);
     if (*errp) {
-        goto error;
+        return;
     }
 
     /* Set time-base frequency to 512 MHz */
@@ -251,7 +251,6 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr,
 error_unregister:
     qemu_unregister_reset(spapr_cpu_reset, cpu);
     cpu_remove_sync(CPU(cpu));
-error:
 }
 
 static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp)
hw/s390x/s390-ccw.c +1 -2
index 0ae1951507..8695d2c445 100644
@@ -94,7 +94,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)
 
     s390_ccw_get_dev_info(cdev, sysfsdev, errp);
     if (*errp) {
-        goto out_err_propagate;
+        return;
     }
 
     sch = css_create_sch(ccw_dev->devno, errp);
@@ -127,7 +127,6 @@ out_err:
     g_free(sch);
 out_mdevid_free:
     g_free(cdev->mdevid);
-out_err_propagate:
 }
 
 static void s390_ccw_unrealize(S390CCWDevice *cdev, Error **errp)
hw/vfio/ap.c +1 -2
index e072a08f1d..8fbaa724c2 100644
@@ -95,7 +95,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
 
     vfio_group = vfio_ap_get_group(vapdev, errp);
     if (!vfio_group) {
-        goto out_err;
+        return;
     }
 
     vapdev->vdev.ops = &vfio_ap_ops;
@@ -122,7 +122,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
 out_get_dev_err:
     vfio_ap_put_device(vapdev);
     vfio_put_group(vfio_group);
-out_err:
 }
 
 static void vfio_ap_unrealize(DeviceState *dev, Error **errp)
hw/vfio/ccw.c +1 -2
index d2b526667e..c24ffdb3af 100644
@@ -486,7 +486,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
     if (cdc->realize) {
         cdc->realize(cdev, vcdev->vdev.sysfsdev, errp);
         if (*errp) {
-            goto out_err_propagate;
+            return;
         }
     }
 
@@ -522,7 +522,6 @@ out_group_err:
     if (cdc->unrealize) {
         cdc->unrealize(cdev, NULL);
     }
-out_err_propagate:
 }
 
 static void vfio_ccw_unrealize(DeviceState *dev, Error **errp)
Signature · 1 line
2.21.0
#19 lore raw

RFC v2 9/9 fix-compilation: includes

In reply to Vladimir Sementsov-Ogievskiy

Hmm. Should we allow empty stubs with errp parameter without calling new macro?

Or, just apply this commit before auto-generated commit.

---
 target/ppc/kvm_ppc.h        | 2 ++
 target/s390x/cpu_models.h   | 1 +
 hw/i386/kvm/apic.c          | 1 +
 hw/misc/arm11scu.c          | 1 +
 hw/misc/mps2-scc.c          | 1 +
 hw/pci-bridge/dec.c         | 1 +
 qapi/qapi-dealloc-visitor.c | 1 +
 stubs/xen-hvm.c             | 1 +
 8 files changed, 9 insertions(+)
target/ppc/kvm_ppc.h +2 -0
index 807c245e90..f6366c19aa 100644
@@ -9,6 +9,8 @@
 #ifndef KVM_PPC_H
 #define KVM_PPC_H
 
+#include "qapi/error.h"
+
 #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host")
 
 #ifdef CONFIG_KVM
target/s390x/cpu_models.h +1 -0
index 5329045a71..062161c5fa 100644
@@ -16,6 +16,7 @@
 #include "cpu_features.h"
 #include "gen-features.h"
 #include "hw/core/cpu.h"
+#include "qapi/error.h"
 
 /* static CPU definition */
 struct S390CPUDef {
hw/i386/kvm/apic.c +1 -0
index d125b370f4..cadf75b71c 100644
@@ -18,6 +18,7 @@
 #include "sysemu/hw_accel.h"
 #include "sysemu/kvm.h"
 #include "target/i386/kvm_i386.h"
+#include "qapi/error.h"
 
 static inline void kvm_apic_set_reg(struct kvm_lapic_state *kapic,
                                     int reg_id, uint32_t val)
hw/misc/arm11scu.c +1 -0
index befc85f321..9c1fec7825 100644
@@ -13,6 +13,7 @@
 #include "hw/qdev-properties.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
+#include "qapi/error.h"
 
 static uint64_t mpcore_scu_read(void *opaque, hwaddr offset,
                                 unsigned size)
hw/misc/mps2-scc.c +1 -0
index f2a00d3235..c41e776996 100644
@@ -26,6 +26,7 @@
 #include "hw/registerfields.h"
 #include "hw/misc/mps2-scc.h"
 #include "hw/qdev-properties.h"
+#include "qapi/error.h"
 
 REG32(CFG0, 0)
 REG32(CFG1, 4)
hw/pci-bridge/dec.c +1 -0
index fbe781474e..06445e0545 100644
@@ -31,6 +31,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci/pci_bus.h"
+#include "qapi/error.h"
 
 /* debug DEC */
 //#define DEBUG_DEC
qapi/qapi-dealloc-visitor.c +1 -0
index 3ee4c7a2e7..e265e29234 100644
@@ -16,6 +16,7 @@
 #include "qapi/dealloc-visitor.h"
 #include "qapi/qmp/qnull.h"
 #include "qapi/visitor-impl.h"
+#include "qapi/error.h"
 
 struct QapiDeallocVisitor
 {
stubs/xen-hvm.c +1 -0
index 840a2a0d09..350c762c64 100644
@@ -12,6 +12,7 @@
 #include "hw/xen/xen.h"
 #include "exec/memory.h"
 #include "qapi/qapi-commands-misc.h"
+#include "qapi/error.h"
 
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 {
Signature · 1 line
2.21.0
#20 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 10 lines · Vladimir Sementsov-Ogievskiy

Hi all!

Here is a proposal of auto propagation for local_err, to not call error_propagate on every exit point, when we deal with local_err.

It also fixes two issues:
1. Fix issue with error_fatal & error_append_hint: user can't see these hints, because exit() happens in error_setg earlier than hint is appended. [Reported by Greg Kurz]

Quoted 4 lines

2. Fix issue with error_abort & error_propagate: when we wrap error_abort by local_err+error_propagate, resulting coredump will refer to error_propagate and not to the place where error happened. (the macro itself don't fix the issue, but it allows to [3.] drop all

doesn't

Quoted 14 lines

local_err+error_propagate pattern, which will definitely fix the issue) [Reported by Kevin Wolf]

It's still an RFC, due to the following reasons:

1. I'm new to coccinella, so I failed to do the following pattern:

<...
- goto out;
+ return;
...>
- out:
- error_propagate(errp, local_err)

Quoted 2 lines

So, here is compilation fix 08.. Who can help with it? If nobody, 08 is to be merged to 07 by hand.

I'm not sure either; but I agree that if we can't figure out how to make Coccinelle do quite what we want, that we are better off squashing in compile fixes.

Also, while I like Coccinelle for automating the conversion, it's harder to get everyone to run it; it would be nice if we could also figure out a patch to scripts/checkpatch.pl that for any instance of 'Error **errp)\n{\n' not followed by either } or the new macro, we flag that as a checkpatch warning or error.

Quoted 2 lines

2. Question about using new macro in empty stub functions - see 09

It would be nice if we could exempt empty functions - no need to use the macro if there is no function body otherwise. I'm not sure if Coccinelle can do that filtering during the conversion, or if we clean up by hand after the fact.

Quoted 3 lines

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

It's big. I'd split it into multiple patches (and reduce the cc - except for the cover letter, the rest of the patches can be limited to the actual maintainer/subsystem affected rather than everyone involved anywhere else in the series. With the current large cc, anyone that replies gets several mail bounces about "too many recipients"). It may be easier to split along directory boundaries than by maintainer boundaries. Markus has applied large tree-wide Coccinelle cleanups before, maybe he has some advice.

Quoted 6 lines

4. Also, checkpatch has some complains about 07 patch:
- using tabs.. (hmm exactly stubs functions..)
- empty ifs
Again, I don't see any ways to fix it other that by hand and merge to 07..

Hand cleanups for formatting or compilation fixes to Coccinelle's work is not an uncommon issue after large patches; thankfully it's also not very difficult (and surprisingly needed in very few places compared to how much actually gets touched).

Quoted 11 lines

==================

Also, if we decide, that this all is too huge, here is plan B:

1. apply 01
2. fix only functions that don't use local_err and use error_append_hint, by just invocation of new macro at function start - it will substitute Greg's series with no pain.
3[optional]. Do full update for some subsystems, for example, only for block* and nbd*

Even if we go with plan B, it's still worth checking in a Coccinelle script that we can periodically run to make sure we aren't missing out on the use of the macro where it is needed.

Quoted 19 lines

Vladimir Sementsov-Ogievskiy (9):
error: auto propagated local_err
qapi/error: add (Error **errp) cleaning APIs
errp: rename errp to errp_in where it is IN-argument hw/core/loader-fit: fix freeing errp in fit_load_fdt net/net: fix local variable shadowing in net_client_init
scripts: add coccinelle script to use auto propagated errp Use auto-propagated errp
fix-compilation: empty goto
fix-compilation: includes

 include/hw/pci-host/spapr.h                   |   2 +
 include/monitor/hmp.h                         |   2 +-
 include/qapi/error.h                          |  61 ++++-
 target/ppc/kvm_ppc.h                          |   3 +
 target/s390x/cpu_models.h                     |   3 +
 ui/vnc.h                                      |   2 +-
Quoted 4 lines
 vl.c                                          |  13 +-
 scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++
 319 files changed, 2729 insertions(+), 4245 deletions(-)
 create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

The diffstat is huge, but promising.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#21 lore raw
Quoted 57 lines · Eric Blake
Quoted 10 lines · Vladimir Sementsov-Ogievskiy

Hi all!

Here is a proposal of auto propagation for local_err, to not call error_propagate on every exit point, when we deal with local_err.

It also fixes two issues:
1. Fix issue with error_fatal & error_append_hint: user can't see these hints, because exit() happens in error_setg earlier than hint is appended. [Reported by Greg Kurz]

Quoted 4 lines

2. Fix issue with error_abort & error_propagate: when we wrap error_abort by local_err+error_propagate, resulting coredump will refer to error_propagate and not to the place where error happened. (the macro itself don't fix the issue, but it allows to [3.] drop all

doesn't

Quoted 14 lines

local_err+error_propagate pattern, which will definitely fix the issue) [Reported by Kevin Wolf]

It's still an RFC, due to the following reasons:

1. I'm new to coccinella, so I failed to do the following pattern:

<...
- goto out;
+ return;
...>
- out:
- error_propagate(errp, local_err)

Quoted 2 lines

So, here is compilation fix 08.. Who can help with it? If nobody, 08 is to be merged to 07 by hand.

I'm not sure either; but I agree that if we can't figure out how to make Coccinelle do quite what we want, that we are better off squashing in compile fixes.

Also, while I like Coccinelle for automating the conversion, it's harder to get everyone to run it; it would be nice if we could also figure out a patch to scripts/checkpatch.pl that for any instance of 'Error **errp)\n{\n' not followed by either } or the new macro, we flag that as a checkpatch warning or error.

Quoted 2 lines

2. Question about using new macro in empty stub functions - see 09

It would be nice if we could exempt empty functions - no need to use the macro if there is no function body otherwise. I'm not sure if Coccinelle can do that filtering during the conversion, or if we clean up by hand after the fact.

Quoted 3 lines

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

Quoted 8 lines

It's big. I'd split it into multiple patches (and reduce the cc - except for the cover letter, the rest of the patches can be limited to the actual maintainer/subsystem affected rather than everyone involved anywhere else in the series. With the current large cc, anyone that replies gets several mail bounces about "too many recipients"). It may be easier to split along directory boundaries than by maintainer boundaries. Markus has applied large tree-wide Coccinelle cleanups before, maybe he has some advice.

If split by subsystem it would be 200+ patches:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205

Try to look at larger subsystem:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139

still too many.. Or is it OK?

Quoted 55 lines
Quoted 7 lines

4. Also, checkpatch has some complains about 07 patch:
- using tabs.. (hmm exactly stubs functions..)
- empty ifs
Again, I don't see any ways to fix it other that by hand and merge to 07..

Hand cleanups for formatting or compilation fixes to Coccinelle's work is not an uncommon issue after large patches; thankfully it's also not very difficult (and surprisingly needed in very few places compared to how much actually gets touched).

Quoted 11 lines

==================

Also, if we decide, that this all is too huge, here is plan B:

1. apply 01
2. fix only functions that don't use local_err and use error_append_hint, by just invocation of new macro at function start - it will substitute Greg's series with no pain.
3[optional]. Do full update for some subsystems, for example, only for block* and nbd*

Even if we go with plan B, it's still worth checking in a Coccinelle script that we can periodically run to make sure we aren't missing out on the use of the macro where it is needed.

Quoted 19 lines

Vladimir Sementsov-Ogievskiy (9):
error: auto propagated local_err
qapi/error: add (Error **errp) cleaning APIs
errp: rename errp to errp_in where it is IN-argument hw/core/loader-fit: fix freeing errp in fit_load_fdt net/net: fix local variable shadowing in net_client_init
scripts: add coccinelle script to use auto propagated errp Use auto-propagated errp
fix-compilation: empty goto
fix-compilation: includes

  include/hw/pci-host/spapr.h                   |   2 +
  include/monitor/hmp.h                         |   2 +-
  include/qapi/error.h                          |  61 ++++-
  target/ppc/kvm_ppc.h                          |   3 +
  target/s390x/cpu_models.h                     |   3 +
  ui/vnc.h                                      |   2 +-
Quoted 4 lines
  vl.c                                          |  13 +-
  scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++
  319 files changed, 2729 insertions(+), 4245 deletions(-)

create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

The diffstat is huge, but promising.

Signature · 2 lines
Best regards,
Vladimir
#22 lore raw
Quoted 18 lines · Vladimir Sementsov-Ogievskiy
Quoted 11 lines
Quoted 2 lines

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

It's big. I'd split it into multiple patches (and reduce the cc - except for the cover letter, the rest of the patches can be limited to the actual maintainer/subsystem affected rather than everyone involved anywhere else in the series. With the current large cc, anyone that replies gets several mail bounces about "too many recipients"). It may be easier to split along directory boundaries than by maintainer boundaries. Markus has applied large tree-wide Coccinelle cleanups before, maybe he has some advice.

If split by subsystem it would be 200+ patches:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205

Quoted 5 lines

Try to look at larger subsystem:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139

still too many.. Or is it OK?

Hmm - that becomes a tradeoff in length of the series (where individual patches may be reviewed fast, but where the overall process may be bogged down by sheer length), vs. length of individual emails (where the email itself is daunting, but as the review is mechanical and done by automation, it becomes a matter of spot-checking if we trust that the automation was done correctly). You can probably group it in fewer patches, by joining smaller patches across a couple of subsystems. It's an art form, there's probably several ways to do it that would work, and it comes down to a judgment call on how much work you want to do to try and reduce other's work in reviewing it. Maybe even an off-hand split of gathering files until you reach about 500 or so lines per diff. I wish I had easier advice on how to tackle this sort of project in the way that will get the fastest response time.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
  vl.c                                          |  13 +-
  scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++
  319 files changed, 2729 insertions(+), 4245 deletions(-)

create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

The diffstat is huge, but promising.

We also learned in reviews of 7/9 that the diffstat here is misleading, the number of insertions will definitely be increasing once the Coccinelle script is fixed to insert the macro in more functions, but hopefully it's still a net reduction in overall lines.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#23 lore raw
Quoted 46 lines · Eric Blake
Quoted 18 lines · Vladimir Sementsov-Ogievskiy
Quoted 11 lines
Quoted 2 lines

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

It's big. I'd split it into multiple patches (and reduce the cc - except for the cover letter, the rest of the patches can be limited to the actual maintainer/subsystem affected rather than everyone involved anywhere else in the series. With the current large cc, anyone that replies gets several mail bounces about "too many recipients"). It may be easier to split along directory boundaries than by maintainer boundaries. Markus has applied large tree-wide Coccinelle cleanups before, maybe he has some advice.

If split by subsystem it would be 200+ patches:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205

Quoted 5 lines

Try to look at larger subsystem:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139

still too many.. Or is it OK?

Hmm - that becomes a tradeoff in length of the series (where individual patches may be reviewed fast, but where the overall process may be bogged down by sheer length), vs. length of individual emails (where the email itself is daunting, but as the review is mechanical and done by automation, it becomes a matter of spot-checking if we trust that the automation was done correctly). You can probably group it in fewer patches, by joining smaller patches across a couple of subsystems. It's an art form, there's probably several ways to do it that would work, and it comes down to a judgment call on how much work you want to do to try and reduce other's work in reviewing it. Maybe even an off-hand split of gathering files until you reach about 500 or so lines per diff. I wish I had easier advice on how to tackle this sort of project in the way that will get the fastest response time.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
   vl.c                                          |  13 +-
   scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++
   319 files changed, 2729 insertions(+), 4245 deletions(-)

create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

Quoted 7 lines
Quoted 1 line
Quoted 1 line

The diffstat is huge, but promising.

We also learned in reviews of 7/9 that the diffstat here is misleading, the number of insertions will definitely be increasing once the Coccinelle script is fixed to insert the macro in more functions, but hopefully it's still a net reduction in overall lines.

No hope for us: with fixed script I now see

919 files changed, 6425 insertions(+), 4234 deletions(-)
Signature · 2 lines
Best regards,
Vladimir
#24 lore raw
Quoted 55 lines · Vladimir Sementsov-Ogievskiy
Quoted 46 lines · Eric Blake
Quoted 18 lines · Vladimir Sementsov-Ogievskiy
Quoted 11 lines
Quoted 2 lines

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

It's big. I'd split it into multiple patches (and reduce the cc - except for the cover letter, the rest of the patches can be limited to the actual maintainer/subsystem affected rather than everyone involved anywhere else in the series. With the current large cc, anyone that replies gets several mail bounces about "too many recipients").  It may be easier to split along directory boundaries than by maintainer boundaries.  Markus has applied large tree-wide Coccinelle cleanups before, maybe he has some advice.

If split by subsystem it would be 200+ patches:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205

Quoted 5 lines

Try to look at larger subsystem:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139

still too many.. Or is it OK?

Hmm - that becomes a tradeoff in length of the series (where individual patches may be reviewed fast, but where the overall process may be bogged down by sheer length), vs. length of individual emails (where the email itself is daunting, but as the review is mechanical and done by automation, it becomes a matter of spot-checking if we trust that the automation was done correctly).  You can probably group it in fewer patches, by joining smaller patches across a couple of subsystems.  It's an art form, there's probably several ways to do it that would work, and it comes down to a judgment call on how much work you want to do to try and reduce other's work in reviewing it.  Maybe even an off-hand split of gathering files until you reach about 500 or so lines per diff.  I wish I had easier advice on how to tackle this sort of project in the way that will get the fastest response time.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

   vl.c                                          |  13 +- scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++

   319 files changed, 2729 insertions(+), 4245 deletions(-)

   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

Quoted 7 lines
Quoted 1 line
Quoted 1 line

The diffstat is huge, but promising.

We also learned in reviews of 7/9 that the diffstat here is misleading, the number of insertions will definitely be increasing once the Coccinelle script is fixed to insert the macro in more functions, but hopefully it's still a net reduction in overall lines.

Quoted 4 lines

No hope for us: with fixed script I now see

919 files changed, 6425 insertions(+), 4234 deletions(-)

Also, I have add include "qapi/error.h" to files, where errp only passed to called functions (or for functions, which are not simple stubs):

# git diff | grep '+#include' | wc -l
253
Signature · 2 lines
Best regards,
Vladimir
#25 lore raw
Quoted 28 lines · Vladimir Sementsov-Ogievskiy
Quoted 27 lines · Vladimir Sementsov-Ogievskiy
Quoted 26 lines · Eric Blake
Quoted 23 lines · Vladimir Sementsov-Ogievskiy
Quoted 11 lines
Quoted 2 lines

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

It's big. I'd split it into multiple patches (and reduce the cc - except for the cover letter, the rest of the patches can be limited to the actual maintainer/subsystem affected rather than everyone involved anywhere else in the series. With the current large cc, anyone that replies gets several mail bounces about "too many recipients").  It may be easier to split along directory boundaries than by maintainer boundaries.  Markus has applied large tree-wide Coccinelle cleanups before, maybe he has some advice.

If split by subsystem it would be 200+ patches:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205

Try to look at larger subsystem:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139

still too many.. Or is it OK?

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines

Hmm - that becomes a tradeoff in length of the series (where individual patches may be reviewed fast, but where the overall process may be bogged down by sheer length), vs. length of individual emails (where the email itself is daunting, but as the review is mechanical and done by automation, it becomes a matter of spot-checking if we trust that the

Quoted 8 lines
Quoted 8 lines

automation was done correctly).  You can probably group it in fewer patches, by joining smaller patches across a couple of subsystems.  It's an art form, there's probably several ways to do it that would work, and it comes down to a judgment call on how much work you want to do to try and reduce other's work in reviewing it.  Maybe even an off-hand split of gathering files until you reach about 500 or so lines per diff.  I wish I had easier advice on how to tackle this sort of project in the way that will get the fastest response time.

git diff | wc -l
48941

so, by 500 lines it would be 97 patches.

Seems, we'll never be able to review this thing :(

Any ideas?

May be, separate big patch, which just add ERRP_FUNCTION_BEGIN() to all errp functions?

Quoted 27 lines
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

   vl.c                                          |  13 +- scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++

   319 files changed, 2729 insertions(+), 4245 deletions(-)

   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

Quoted 7 lines
Quoted 1 line
Quoted 1 line

The diffstat is huge, but promising.

We also learned in reviews of 7/9 that the diffstat here is misleading, the number of insertions will definitely be increasing once the Coccinelle script is fixed to insert the macro in more functions, but hopefully it's still a net reduction in overall lines.

Quoted 4 lines

No hope for us: with fixed script I now see

919 files changed, 6425 insertions(+), 4234 deletions(-)

Also, I have add include "qapi/error.h" to files, where errp only passed to called functions (or for functions, which are not simple stubs):

# git diff | grep '+#include' | wc -l
253
Signature · 2 lines
Best regards,
Vladimir
#26 lore raw
Quoted 46 lines · Vladimir Sementsov-Ogievskiy
Quoted 28 lines · Vladimir Sementsov-Ogievskiy
Quoted 27 lines · Vladimir Sementsov-Ogievskiy
Quoted 26 lines · Eric Blake
Quoted 23 lines · Vladimir Sementsov-Ogievskiy
Quoted 11 lines
Quoted 2 lines

3. What to do with huge auto-generated commit 07? Should I split it per-maintainer or per-subsystem, or leave it as-is?

It's big. I'd split it into multiple patches (and reduce the cc - except for the cover letter, the rest of the patches can be limited to the actual maintainer/subsystem affected rather than everyone involved anywhere else in the series. With the current large cc, anyone that replies gets several mail bounces about "too many recipients").  It may be easier to split along directory boundaries than by maintainer boundaries.  Markus has applied large tree-wide Coccinelle cleanups before, maybe he has some advice.

If split by subsystem it would be 200+ patches:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205

Try to look at larger subsystem:
git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139

still too many.. Or is it OK?

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines

Hmm - that becomes a tradeoff in length of the series (where individual patches may be reviewed fast, but where the overall process may be bogged down by sheer length), vs. length of individual emails (where the email itself is daunting, but as the review is mechanical and done by automation, it becomes a matter of spot-checking if we trust that the

Quoted 8 lines
Quoted 8 lines

automation was done correctly).  You can probably group it in fewer patches, by joining smaller patches across a couple of subsystems.  It's an art form, there's probably several ways to do it that would work, and it comes down to a judgment call on how much work you want to do to try and reduce other's work in reviewing it.  Maybe even an off-hand split of gathering files until you reach about 500 or so lines per diff.  I wish I had easier advice on how to tackle this sort of project in the way that will get the fastest response time.

git diff | wc -l
48941

Quoted 7 lines

so, by 500 lines it would be 97 patches.

Seems, we'll never be able to review this thing :(

Any ideas?

May be, separate big patch, which just add ERRP_FUNCTION_BEGIN() to all errp functions?

checked: for remaining improvements:
git diff | wc -l
20218

git diff --name-only | while read f; do scripts/get_maintainer.pl -f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 90

Still, too much..

I think we should switch to plan B, at least as something that may be merged to 4.2

Quoted 30 lines
Quoted 28 lines
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

   vl.c                                          |  13 +- scripts/coccinelle/auto-propagated-errp.cocci |  82 +++++++

   319 files changed, 2729 insertions(+), 4245 deletions(-)

   create mode 100644 scripts/coccinelle/auto-propagated-errp.cocci

Quoted 7 lines
Quoted 1 line
Quoted 1 line

The diffstat is huge, but promising.

We also learned in reviews of 7/9 that the diffstat here is misleading, the number of insertions will definitely be increasing once the Coccinelle script is fixed to insert the macro in more functions, but hopefully it's still a net reduction in overall lines.

Quoted 4 lines

No hope for us: with fixed script I now see

919 files changed, 6425 insertions(+), 4234 deletions(-)

Also, I have add include "qapi/error.h" to files, where errp only passed to called functions (or for functions, which are not simple stubs):

# git diff | grep '+#include' | wc -l
253
Signature · 2 lines
Best regards,
Vladimir