error: auto propagated local_err
Subsystems (15)
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
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
@@ -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
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
Here is introduced
ERRP_FUNCTION_BEGINmacro, 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, becauseexit()happens inerror_setgearlier than hint is appended. [Reported by Greg Kurz]2. Fix issue with
error_abort&error_propagate: when we wraperror_abortby local_err+error_propagate, resulting coredump will refer toerror_propagateand 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).
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/qapi/error.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)include/qapi/error.h +7
-0@@ -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
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
@@ -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
@@ -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
Re: [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs
Quoted 2 lines · Vladimir Sementsov-Ogievskiy
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
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
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
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
RFC v2 3/9 errp: rename errp to errp_in where it is IN-argument
In reply to Vladimir Sementsov-OgievskiyError **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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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_abortorerror_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.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>
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
RFC v2 4/9 hw/core/loader-fit: fix freeing errp in fit_load_fdt
In reply to Vladimir Sementsov-Ogievskiyfit_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
@@ -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
Re: [RFC v2 4/9] hw/core/loader-fit: fix freeing errp in fit_load_fdt
Quoted 7 lines · Vladimir Sementsov-Ogievskiy
fit_load_fdtforget to zero errp. Fix it.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- 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@@ -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
RFC v2 5/9 net/net: fix local variable shadowing in net_client_init
In reply to Vladimir Sementsov-OgievskiyDon'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
@@ -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
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.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- 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
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
-0error_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
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
@@ -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
Re: [RFC v2 6/9] scripts: add coccinelle script to use auto propagated errp
Quoted 12 lines · Vladimir Sementsov-Ogievskiy
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- scripts/coccinelle/auto-propagated-errp.cocci | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 scripts/coccinelle/auto-propagated-errp.cocciscripts/coccinelle/auto-propagated-errp.cocci new file +0
-0
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
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
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
RFC v2 7/9 Use auto-propagated errp
In reply to Vladimir Sementsov-OgievskiyThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 *optBlockDriverState *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
@@ -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
@@ -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
@@ -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
@@ -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 (¶llels_runtime_opts,NULL ,0 , &local_err); -if (local_err !=NULL ) { + opts =qemu_opts_create (¶llels_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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
blockdev.c +78 -142
220 lines not on this page · raw message
dump/dump.c +52 -90
142 lines not on this page · 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/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/nrf51_soc.c +18 -28
46 lines not on this page · raw message
hw/arm/xlnx-zynqmp.c +34 -50
84 lines not on this page · raw message
hw/block/xen-block.c +45 -69
114 lines not on this page · raw message
hw/core/numa.c +20 -28
48 lines not on this page · raw message
hw/core/qdev-properties.c +27 -51
78 lines not on this page · raw message
hw/i386/pc.c +39 -70
109 lines not on this page · raw message
hw/intc/spapr_xive_kvm.c +18 -31
49 lines not on this page · raw message
hw/mips/cps.c +20 -25
45 lines not on this page · raw message
hw/misc/macio/macio.c +25 -40
65 lines not on this page · raw message
hw/ppc/pnv.c +34 -58
92 lines not on this page · 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_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/smbios/smbios.c +16 -25
41 lines not on this page · raw message
hw/xen/xen-bus.c +36 -49
85 lines not on this page · raw message
memory.c +18 -36
54 lines not on this page · raw message
net/tap.c +16 -28
44 lines not on this page · raw message
qapi/qapi-visit-core.c +16 -37
53 lines not on this page · 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
target/i386/cpu.c +42 -65
107 lines not on this page · raw message
util/qemu-option.c +17 -33
50 lines not on this page · 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.
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
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
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.cblock/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
-3memset (&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
-2NBD_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
-2chunk->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
-3sioc =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@@ -25,6 +25,7 @@ struct QapiDeallocVisitorstatic 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
-3trace_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
-3uint64_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
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; doneAs 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
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
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.cblock/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
RFC v2 8/9 fix-compilation: empty goto
In reply to Vladimir Sementsov-OgievskiyI 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
RFC v2 9/9 fix-compilation: includes
In reply to Vladimir Sementsov-OgievskiyHmm. 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Quoted 10 lines · Vladimir Sementsov-Ogievskiy
Hi all!
Here is a proposal of auto propagation for
local_err, to not callerror_propagateon every exit point, when we deal withlocal_err.It also fixes two issues:
1. Fix issue witherror_fatal&error_append_hint: user can't see these hints, becauseexit()happens inerror_setgearlier than hint is appended. [Reported by Greg Kurz]
Quoted 4 lines
2. Fix issue with
error_abort&error_propagate: when we wraperror_abortby local_err+error_propagate, resulting coredump will refer toerror_propagateand 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 uselocal_errand useerror_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 propagatedlocal_err
qapi/error: add (Error **errp) cleaning APIs
errp: rename errp toerrp_inwhere it is IN-argument hw/core/loader-fit: fix freeing errp infit_load_fdtnet/net: fix local variable shadowing innet_client_init
scripts: add coccinelle script to use auto propagated errp Use auto-propagated errp
fix-compilation: empty goto
fix-compilation: includesinclude/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
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 callerror_propagateon every exit point, when we deal withlocal_err.It also fixes two issues:
1. Fix issue witherror_fatal&error_append_hint: user can't see these hints, becauseexit()happens inerror_setgearlier than hint is appended. [Reported by Greg Kurz]Quoted 4 lines
2. Fix issue with
error_abort&error_propagate: when we wraperror_abortby local_err+error_propagate, resulting coredump will refer toerror_propagateand not to the place where error happened. (the macro itself don't fix the issue, but it allows to [3.] drop alldoesn'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.plthat 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 uselocal_errand useerror_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 propagatedlocal_err
qapi/error: add (Error **errp) cleaning APIs
errp: rename errp toerrp_inwhere it is IN-argument hw/core/loader-fit: fix freeing errp infit_load_fdtnet/net: fix local variable shadowing innet_client_init
scripts: add coccinelle script to use auto propagated errp Use auto-propagated errp
fix-compilation: empty goto
fix-compilation: includesinclude/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.cocciThe diffstat is huge, but promising.
Signature · 2 lines
Best regards, Vladimir
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; doscripts/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; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139still 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.cocciThe 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
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; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205Quoted 5 lines
Try to look at larger subsystem:
git diff --name-only | while read f; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139still 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
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; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205Quoted 5 lines
Try to look at larger subsystem:
git diff --name-only | while read f; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139still 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.cocciQuoted 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
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; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205Try to look at larger subsystem:
git diff --name-only | while read f; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139still 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.cocciQuoted 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
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; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | head -1; done | sort | uniq | wc -l 205Try to look at larger subsystem:
git diff --name-only | while read f; doscripts/get_maintainer.pl-f $f --subsystem --no-rolestats 2>/dev/null | grep -v @ | tail -2 | head -1; done | sort | uniq | wc -l 139still 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.cocciQuoted 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