[PATCH v2 00/44] Less clumsy error checking

Markus Armbruster posted 44 patches 3 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200702155000.3455325-1-armbru@redhat.com
Test FreeBSD passed
Test docker-quick@centos7 failed
Test checkpatch failed
Test docker-mingw@fedora passed
Maintainers: Andrey Smirnov <andrew.smirnov@gmail.com>, Antony Pavlov <antonynpavlov@gmail.com>, Eric Blake <eblake@redhat.com>, Matthew Rosato <mjrosato@linux.ibm.com>, John Snow <jsnow@redhat.com>, Jason Wang <jasowang@redhat.com>, Richard Henderson <rth@twiddle.net>, Kevin Wolf <kwolf@redhat.com>, Paul Burton <pburton@wavecomp.com>, Artyom Tarasenko <atar4qemu@gmail.com>, Zhang Chen <chen.zhang@intel.com>, "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Paul Durrant <paul@xen.org>, Christian Borntraeger <borntraeger@de.ibm.com>, David Hildenbrand <david@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Max Reitz <mreitz@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Joel Stanley <joel@jms.id.au>, Igor Mammedov <imammedo@redhat.com>, Andrew Baumann <Andrew.Baumann@microsoft.com>, Wen Congyang <wencongyang2@huawei.com>, Liu Yuan <namei.unix@gmail.com>, Laurent Vivier <lvivier@redhat.com>, Jeff Cody <codyprime@gmail.com>, Stefan Berger <stefanb@linux.ibm.com>, Riku Voipio <riku.voipio@iki.fi>, Ronnie Sahlberg <ronniesahlberg@gmail.com>, Ari Sundholm <ari@tuxera.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Jan Kiszka <jan.kiszka@web.de>, Michael Roth <mdroth@linux.vnet.ibm.com>, Alex Williamson <alex.williamson@redhat.com>, Li Zhijian <lizhijian@cn.fujitsu.com>, Beniamino Galvani <b.galvani@gmail.com>, Alistair Francis <alistair@alistair23.me>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Stefan Weil <sw@weilnetz.de>, Yoshinori Sato <ysato@users.sourceforge.jp>, Aurelien Jarno <aurelien@aurel32.net>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, Leif Lindholm <leif@nuviainc.com>, "Hervé Poussineau" <hpoussin@reactos.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Peter Lieven <pl@kamp.de>, Eric Auger <eric.auger@redhat.com>, Xiao Guangrong <xiaoguangrong.eric@gmail.com>, Alberto Garcia <berto@igalia.com>, Niek Linnenbank <nieklinnenbank@gmail.com>, Xie Changlong <xiechanglong.d@gmail.com>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Markus Armbruster <armbru@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Fam Zheng <fam@euphon.net>, "Daniel P. Berrangé" <berrange@redhat.com>, Sagar Karandikar <sagark@eecs.berkeley.edu>, Igor Mitsyanko <i.mitsyanko@gmail.com>, Gerd Hoffmann <kraxel@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Peter Chubb <peter.chubb@nicta.com.au>, "Denis V. Lunev" <den@openvz.org>, Halil Pasic <pasic@linux.ibm.com>, Anthony Perard <anthony.perard@citrix.com>, Andrew Jeffery <andrew@aj.id.au>, Jason Dillaman <dillaman@redhat.com>, Rob Herring <robh@kernel.org>, "Richard W.M. Jones" <rjones@redhat.com>, "Cédric Le Goater" <clg@kaod.org>, Subbaraya Sundeep <sundeep.lkml@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Jean-Christophe Dubois <jcd@tribudubois.net>, David Gibson <david@gibson.dropbear.id.au>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Radoslaw Biernacki <radoslaw.biernacki@linaro.org>, Thomas Huth <thuth@redhat.com>, Amit Shah <amit@kernel.org>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
docs/devel/qapi-code-gen.txt             | 103 ++++-----
include/hw/audio/pcspk.h                 |   2 +-
include/hw/qdev-properties.h             |   4 +-
include/qapi/clone-visitor.h             |   8 +-
include/qapi/error.h                     |  45 +++-
include/qapi/visitor-impl.h              |  26 +--
include/qapi/visitor.h                   | 102 +++++----
include/qemu/option.h                    |  16 +-
include/qom/object.h                     | 105 +++++----
include/qom/object_interfaces.h          |  12 +-
include/qom/qom-qobject.h                |   9 +-
accel/kvm/kvm-all.c                      |  55 +++--
accel/tcg/tcg-all.c                      |   5 +-
audio/audio_legacy.c                     |  15 +-
backends/cryptodev-vhost-user.c          |   3 +-
backends/cryptodev.c                     |  16 +-
backends/hostmem-file.c                  |  22 +-
backends/hostmem-memfd.c                 |  18 +-
backends/hostmem.c                       |  33 ++-
backends/rng.c                           |   2 +-
backends/tpm/tpm_util.c                  |   5 +-
block.c                                  |  21 +-
block/blkdebug.c                         |   9 +-
block/blklogwrites.c                     |   4 +-
block/blkverify.c                        |   4 +-
block/crypto.c                           |   5 +-
block/curl.c                             |   5 +-
block/file-posix.c                       |  16 +-
block/file-win32.c                       |   8 +-
block/gluster.c                          |  17 +-
block/iscsi.c                            |   4 +-
block/nbd.c                              |  10 +-
block/nfs.c                              |   7 +-
block/parallels.c                        |  29 +--
block/qcow.c                             |  16 +-
block/qcow2.c                            |  21 +-
block/qed.c                              |  10 +-
block/quorum.c                           |  19 +-
block/raw-format.c                       |   5 +-
block/rbd.c                              |   7 +-
block/replication.c                      |  19 +-
block/sheepdog.c                         |  16 +-
block/ssh.c                              |  11 +-
block/throttle-groups.c                  |  31 +--
block/throttle.c                         |   5 +-
block/vdi.c                              |  13 +-
block/vhdx.c                             |  15 +-
block/vmdk.c                             |  13 +-
block/vpc.c                              |  19 +-
block/vvfat.c                            |  10 +-
block/vxhs.c                             |  15 +-
blockdev.c                               |  40 ++--
bootdevice.c                             |  13 +-
chardev/char.c                           |   6 +-
contrib/ivshmem-server/main.c            |   4 +-
crypto/secret.c                          |   2 +-
crypto/secret_keyring.c                  |   2 +-
crypto/tlscredsanon.c                    |   2 +-
crypto/tlscredspsk.c                     |   2 +-
crypto/tlscredsx509.c                    |   2 +-
dump/dump.c                              |   7 +-
hw/acpi/core.c                           |  19 +-
hw/acpi/cpu_hotplug.c                    |   4 +-
hw/acpi/ich9.c                           |   2 +-
hw/acpi/piix4.c                          |   2 +-
hw/arm/allwinner-a10.c                   |  27 +--
hw/arm/armsse.c                          | 208 ++++++------------
hw/arm/armv7m.c                          |  47 ++---
hw/arm/aspeed.c                          |  24 +--
hw/arm/aspeed_ast2600.c                  | 124 ++++-------
hw/arm/aspeed_soc.c                      |  85 +++-----
hw/arm/bcm2835_peripherals.c             |  81 ++-----
hw/arm/bcm2836.c                         |  35 +--
hw/arm/cubieboard.c                      |  14 +-
hw/arm/digic.c                           |  18 +-
hw/arm/digic_boards.c                    |   3 +-
hw/arm/exynos4210.c                      |  13 +-
hw/arm/fsl-imx25.c                       |  58 ++---
hw/arm/fsl-imx31.c                       |  34 +--
hw/arm/fsl-imx6.c                        |  85 +++-----
hw/arm/fsl-imx6ul.c                      |  24 +--
hw/arm/fsl-imx7.c                        |  31 ++-
hw/arm/highbank.c                        |  12 +-
hw/arm/integratorcp.c                    |   2 +-
hw/arm/microbit.c                        |   4 +-
hw/arm/mps2-tz.c                         |  31 ++-
hw/arm/mps2.c                            |  12 +-
hw/arm/msf2-soc.c                        |  29 +--
hw/arm/musca.c                           |  18 +-
hw/arm/musicpal.c                        |   4 +-
hw/arm/nrf51_soc.c                       |  36 +---
hw/arm/orangepi.c                        |  13 +-
hw/arm/raspi.c                           |   2 +-
hw/arm/realview.c                        |   6 +-
hw/arm/sbsa-ref.c                        |  16 +-
hw/arm/stellaris.c                       |   4 +-
hw/arm/stm32f205_soc.c                   |  37 +---
hw/arm/stm32f405_soc.c                   |  48 ++---
hw/arm/versatilepb.c                     |   4 +-
hw/arm/vexpress.c                        |   8 +-
hw/arm/virt.c                            |  44 ++--
hw/arm/xilinx_zynq.c                     |   6 +-
hw/arm/xlnx-versal-virt.c                |   8 +-
hw/arm/xlnx-versal.c                     |  30 ++-
hw/arm/xlnx-zcu102.c                     |   8 +-
hw/arm/xlnx-zynqmp.c                     | 117 ++++------
hw/block/fdc.c                           |  12 +-
hw/block/xen-block.c                     |  30 +--
hw/char/serial-pci-multi.c               |   5 +-
hw/char/serial-pci.c                     |   5 +-
hw/char/serial.c                         |  10 +-
hw/core/bus.c                            |  12 +-
hw/core/cpu.c                            |   3 +-
hw/core/machine.c                        |   5 +-
hw/core/numa.c                           |  55 ++---
hw/core/platform-bus.c                   |   6 +-
hw/core/qdev-properties-system.c         |  32 +--
hw/core/qdev-properties.c                |  93 +++-----
hw/core/qdev.c                           |  16 +-
hw/cpu/a15mpcore.c                       |   5 +-
hw/cpu/a9mpcore.c                        |  21 +-
hw/cpu/arm11mpcore.c                     |  17 +-
hw/cpu/core.c                            |  10 +-
hw/cpu/realview_mpcore.c                 |   9 +-
hw/display/bcm2835_fb.c                  |   8 +-
hw/display/virtio-gpu-base.c             |   5 +-
hw/display/virtio-gpu-pci.c              |  11 +-
hw/display/virtio-vga.c                  |  10 +-
hw/dma/bcm2835_dma.c                     |   9 +-
hw/dma/sparc32_dma.c                     |   6 +-
hw/dma/xilinx_axidma.c                   |   4 +-
hw/gpio/aspeed_gpio.c                    |   5 +-
hw/gpio/bcm2835_gpio.c                   |  15 +-
hw/hyperv/vmbus.c                        |   5 +-
hw/i386/pc.c                             |  48 ++---
hw/i386/pc_piix.c                        |   4 +-
hw/i386/pc_q35.c                         |  28 +--
hw/i386/x86.c                            |   7 +-
hw/ide/qdev.c                            |   7 +-
hw/intc/apic_common.c                    |   5 +-
hw/intc/arm_gic_kvm.c                    |   4 +-
hw/intc/arm_gicv3_its_kvm.c              |   5 +-
hw/intc/arm_gicv3_kvm.c                  |   4 +-
hw/intc/armv7m_nvic.c                    |   9 +-
hw/intc/nios2_iic.c                      |   8 +-
hw/intc/pnv_xive.c                       |  17 +-
hw/intc/realview_gic.c                   |   5 +-
hw/intc/spapr_xive.c                     |  17 +-
hw/intc/xics.c                           |   9 +-
hw/intc/xics_kvm.c                       |   4 +-
hw/intc/xive.c                           |  17 +-
hw/isa/piix4.c                           |   5 +-
hw/m68k/q800.c                           |   4 +-
hw/mem/nvdimm.c                          |  30 +--
hw/mem/pc-dimm.c                         |  18 +-
hw/microblaze/petalogix_ml605_mmu.c      |  24 +--
hw/microblaze/petalogix_s3adsp1800_mmu.c |   2 +-
hw/microblaze/xlnx-zynqmp-pmu.c          |  39 ++--
hw/mips/boston.c                         |   4 +-
hw/mips/cps.c                            |  41 ++--
hw/mips/jazz.c                           |   4 +-
hw/mips/malta.c                          |   4 +-
hw/misc/aspeed_sdmc.c                    |   8 +-
hw/misc/bcm2835_mbox.c                   |   9 +-
hw/misc/bcm2835_property.c               |  17 +-
hw/misc/iotkit-sysctl.c                  |   2 +-
hw/misc/ivshmem.c                        |   4 +-
hw/misc/macio/cuda.c                     |   5 +-
hw/misc/macio/macio.c                    |  35 ++-
hw/misc/macio/pmu.c                      |   5 +-
hw/misc/pca9552.c                        |   5 +-
hw/misc/tmp105.c                         |   5 +-
hw/misc/tmp421.c                         |   5 +-
hw/net/ne2000-isa.c                      |   7 +-
hw/net/virtio-net.c                      |   7 +-
hw/net/xilinx_axienet.c                  |   4 +-
hw/pci-host/pnv_phb3.c                   |  33 ++-
hw/pci-host/pnv_phb4.c                   |   9 +-
hw/pci-host/pnv_phb4_pec.c               |   9 +-
hw/pci-host/prep.c                       |   4 +-
hw/ppc/e500.c                            |   5 +-
hw/ppc/mac_newworld.c                    |  10 +-
hw/ppc/mac_oldworld.c                    |   4 +-
hw/ppc/pnv.c                             | 171 +++++++--------
hw/ppc/pnv_core.c                        |   4 +-
hw/ppc/pnv_psi.c                         |  22 +-
hw/ppc/rs6000_mc.c                       |   9 +-
hw/ppc/spapr.c                           |  77 +++----
hw/ppc/spapr_caps.c                      |  15 +-
hw/ppc/spapr_cpu_core.c                  |  15 +-
hw/ppc/spapr_drc.c                       |  16 +-
hw/ppc/spapr_hcall.c                     |   3 +-
hw/ppc/spapr_irq.c                       |  11 +-
hw/ppc/spapr_pci.c                       |  16 +-
hw/ppc/spapr_pci_nvlink2.c               |   3 +-
hw/riscv/opentitan.c                     |  13 +-
hw/riscv/sifive_e.c                      |  10 +-
hw/riscv/sifive_u.c                      |  11 +-
hw/riscv/spike.c                         |   4 +-
hw/riscv/virt.c                          |   4 +-
hw/rx/rx-gdbsim.c                        |  12 +-
hw/s390x/css.c                           |   5 +-
hw/s390x/event-facility.c                |  13 +-
hw/s390x/ipl.c                           |  27 ++-
hw/s390x/s390-pci-bus.c                  |  14 +-
hw/s390x/s390-skeys.c                    |   2 +-
hw/s390x/s390-stattrib.c                 |   2 +-
hw/s390x/s390-virtio-ccw.c               |  20 +-
hw/s390x/sclp.c                          |  13 +-
hw/s390x/virtio-ccw-crypto.c             |  10 +-
hw/s390x/virtio-ccw-rng.c                |   8 +-
hw/scsi/scsi-bus.c                       |  15 +-
hw/scsi/vhost-scsi.c                     |   4 +-
hw/sd/aspeed_sdhci.c                     |  15 +-
hw/sd/sd.c                               |   3 +-
hw/sd/ssi-sd.c                           |  11 +-
hw/smbios/smbios.c                       |  33 +--
hw/sparc/sun4m.c                         |   2 +-
hw/sparc64/sun4u.c                       |   2 +-
hw/usb/bus.c                             |   7 +-
hw/usb/dev-storage.c                     |   9 +-
hw/usb/hcd-dwc2.c                        |   9 +-
hw/vfio/pci-quirks.c                     |   5 +-
hw/vfio/pci.c                            |  10 +-
hw/virtio/virtio-balloon.c               |  17 +-
hw/virtio/virtio-crypto-pci.c            |   9 +-
hw/virtio/virtio-iommu-pci.c             |   4 +-
hw/virtio/virtio-pmem-pci.c              |   2 +-
hw/virtio/virtio-rng-pci.c               |   8 +-
hw/virtio/virtio-rng.c                   |  10 +-
hw/xen/xen_pt_config_init.c              |   3 +-
iothread.c                               |  18 +-
linux-user/syscall.c                     |   2 +-
monitor/hmp-cmds.c                       |  11 +-
monitor/monitor.c                        |  21 +-
net/colo-compare.c                       |  26 +--
net/dump.c                               |  13 +-
net/filter-buffer.c                      |  13 +-
net/filter.c                             |   2 +-
net/net.c                                |  10 +-
net/tap.c                                |   6 +-
qapi/opts-visitor.c                      |  58 ++---
qapi/qapi-clone-visitor.c                |  67 +++---
qapi/qapi-dealloc-visitor.c              |  27 ++-
qapi/qapi-visit-core.c                   | 197 ++++++++---------
qapi/qobject-input-visitor.c             | 109 ++++++----
qapi/qobject-output-visitor.c            |  27 ++-
qapi/string-input-visitor.c              |  67 +++---
qapi/string-output-visitor.c             |  32 +--
qdev-monitor.c                           |  38 ++--
qemu-img.c                               |  23 +-
qga/commands-posix.c                     |   4 +-
qga/commands-win32.c                     |  22 +-
qom/object.c                             | 235 ++++++++++-----------
qom/object_interfaces.c                  |  30 +--
qom/qom-hmp-cmds.c                       |   2 +-
qom/qom-qmp-cmds.c                       |   2 +-
qom/qom-qobject.c                        |  14 +-
softmmu/vl.c                             |  17 +-
target/arm/cpu64.c                       |  15 +-
target/arm/monitor.c                     |   7 +-
target/i386/cpu.c                        |  98 +++------
target/ppc/compat.c                      |   5 +-
target/ppc/translate_init.inc.c          |   2 +-
target/s390x/cpu_models.c                |  17 +-
target/sparc/cpu.c                       |   5 +-
tpm.c                                    |   5 +-
ui/console.c                             |   4 +-
ui/vnc.c                                 |   2 +-
util/main-loop.c                         |   4 +-
util/qemu-config.c                       |  25 +--
util/qemu-option.c                       | 258 ++++++++++++-----------
scripts/qapi/commands.py                 |  22 +-
scripts/qapi/visit.py                    | 107 ++++------
274 files changed, 2349 insertions(+), 3524 deletions(-)
[PATCH v2 00/44] Less clumsy error checking
Posted by Markus Armbruster 3 years, 9 months ago
When the Error API was created, we adopted the (unwritten) rule to
return void when the function returns no useful value on success,
unlike GError, which recommends to return true on success and false on
error then.

When a function returns a distinct error value, say false, a checked
call that passes the error up looks like

    if (!frobnicate(..., errp)) {
        handle the error...
    }

When it returns void, we need

    Error *err = NULL;

    frobnicate(..., &err);
    if (err) {
        handle the error...
        error_propagate(errp, err);
    }

Not only is this more verbose, it also creates an Error object even
when @errp is null, &error_abort or &error_fatal.

People got tired of the additional boilerplate, and started to ignore
the unwritten rule.  The result is confusion among developers about
the preferred usage.

This series adopts the GError rule (in writing), and updates a
substantial amount of code to honor the rule.  Cuts the number of
error_propagate() calls nearly by half.  The diffstat speaks for
itself.

Based on my "[PULL 00/28] Error reporting patches patches for
2020-07-02".  Also available from my public repository
https://repo.or.cz/qemu/armbru.git on branch error-smooth.

Based-on: Message-Id: <20200702110931.2953148-1-armbru@redhat.com>

v2:
* Rebased
* Coccinelle scripts reworked, patches sliced and diced for
  reviewability:
  Old PATCH 03+17+23-24+35+38-39+42 split into "Use returned bool to
  check for failure" parts [PATCH 03+13+17-18+25+28-29+42], and
  "Eliminate error_propagate()" parts.  The latter combined with old
  PATCH 06-07+18-19+29+43 are now [PATCH 33-37].  The end result is
  almost identical.  Some R-bys dropped; sorry!
* Drop variables as they become unused [Vladimir]
* PATCH 01: Comment typos fixed [Greg]
* PATCH 09: Simplify further by cutting out variables [Eric]
* PATCH 11: opt_set() renamed to opt_validate(), redundant parameter
  dropped [Vladimir], R-by kept
* PATCH 16: Comment typos fixed, indentation tidied up [Eric]
* PATCH 23: Assertion dropped [Eric], incorrect hunk backed out
* PATCH 26: Regenerated after rebase; note additional Coccinelle
  hiccup in the commit message
* PATCH 27: Indentation tiedied up [Eric]
* Left for later: followup to fix nearby typos and such [Eric]

Markus Armbruster (44):
  error: Improve examples in error.h's big comment
  error: Document Error API usage rules
  qdev: Use returned bool to check for qdev_realize() etc. failure
  macio: Tidy up error handling in macio_newworld_realize()
  virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()
  qemu-option: Check return value instead of @err where convenient
  qemu-option: Make uses of find_desc_by_name() more similar
  qemu-option: Factor out helper find_default_by_name()
  qemu-option: Simplify around find_default_by_name()
  qemu-option: Factor out helper opt_create()
  qemu-option: Replace opt_set() by cleaner opt_validate()
  qemu-option: Make functions taking Error ** return bool, not void
  qemu-option: Use returned bool to check for failure
  block: Avoid error accumulation in bdrv_img_create()
  hmp: Eliminate a variable in hmp_migrate_set_parameter()
  qapi: Make visitor functions taking Error ** return bool, not void
  qapi: Use returned bool to check for failure, Coccinelle part
  qapi: Use returned bool to check for failure, manual part
  block/parallels: Simplify parallels_open() after previous commit
  s390x/pci: Fix harmless mistake in zpci's property fid's setter
  qom: Use error_reportf_err() instead of g_printerr() in examples
  qom: Rename qdev_get_type() to object_get_type()
  qom: Crash more nicely on object_property_get_link() failure
  qom: Don't handle impossible object_property_get_link() failure
  qom: Use return values to check for error where that's simpler
  qom: Put name parameter before value / visitor parameter
  qom: Make functions taking Error ** return bool, not void
  qom: Use returned bool to check for failure, Coccinelle part
  qom: Use returned bool to check for failure, manual part
  qom: Make functions taking Error ** return bool, not 0/-1
  qdev: Make functions taking Error ** return bool, not void
  qdev: Use returned bool to check for failure, Coccinelle part
  error: Avoid unnecessary error_propagate() after error_setg()
  error: Eliminate error_propagate() with Coccinelle, part 1
  error: Eliminate error_propagate() with Coccinelle, part 2
  error: Eliminate error_propagate() manually
  error: Reduce unnecessary error propagation
  qapi: Smooth another visitor error checking pattern
  qapi: Smooth visitor error checking in generated code
  qapi: Purge error_propagate() from QAPI core
  error: Avoid error_propagate() after migrate_add_blocker()
  qemu-img: Ignore Error objects where the return value suffices
  qdev: Ignore Error objects where the return value suffices
  hmp: Ignore Error objects where the return value suffices

 docs/devel/qapi-code-gen.txt             | 103 ++++-----
 include/hw/audio/pcspk.h                 |   2 +-
 include/hw/qdev-properties.h             |   4 +-
 include/qapi/clone-visitor.h             |   8 +-
 include/qapi/error.h                     |  45 +++-
 include/qapi/visitor-impl.h              |  26 +--
 include/qapi/visitor.h                   | 102 +++++----
 include/qemu/option.h                    |  16 +-
 include/qom/object.h                     | 105 +++++----
 include/qom/object_interfaces.h          |  12 +-
 include/qom/qom-qobject.h                |   9 +-
 accel/kvm/kvm-all.c                      |  55 +++--
 accel/tcg/tcg-all.c                      |   5 +-
 audio/audio_legacy.c                     |  15 +-
 backends/cryptodev-vhost-user.c          |   3 +-
 backends/cryptodev.c                     |  16 +-
 backends/hostmem-file.c                  |  22 +-
 backends/hostmem-memfd.c                 |  18 +-
 backends/hostmem.c                       |  33 ++-
 backends/rng.c                           |   2 +-
 backends/tpm/tpm_util.c                  |   5 +-
 block.c                                  |  21 +-
 block/blkdebug.c                         |   9 +-
 block/blklogwrites.c                     |   4 +-
 block/blkverify.c                        |   4 +-
 block/crypto.c                           |   5 +-
 block/curl.c                             |   5 +-
 block/file-posix.c                       |  16 +-
 block/file-win32.c                       |   8 +-
 block/gluster.c                          |  17 +-
 block/iscsi.c                            |   4 +-
 block/nbd.c                              |  10 +-
 block/nfs.c                              |   7 +-
 block/parallels.c                        |  29 +--
 block/qcow.c                             |  16 +-
 block/qcow2.c                            |  21 +-
 block/qed.c                              |  10 +-
 block/quorum.c                           |  19 +-
 block/raw-format.c                       |   5 +-
 block/rbd.c                              |   7 +-
 block/replication.c                      |  19 +-
 block/sheepdog.c                         |  16 +-
 block/ssh.c                              |  11 +-
 block/throttle-groups.c                  |  31 +--
 block/throttle.c                         |   5 +-
 block/vdi.c                              |  13 +-
 block/vhdx.c                             |  15 +-
 block/vmdk.c                             |  13 +-
 block/vpc.c                              |  19 +-
 block/vvfat.c                            |  10 +-
 block/vxhs.c                             |  15 +-
 blockdev.c                               |  40 ++--
 bootdevice.c                             |  13 +-
 chardev/char.c                           |   6 +-
 contrib/ivshmem-server/main.c            |   4 +-
 crypto/secret.c                          |   2 +-
 crypto/secret_keyring.c                  |   2 +-
 crypto/tlscredsanon.c                    |   2 +-
 crypto/tlscredspsk.c                     |   2 +-
 crypto/tlscredsx509.c                    |   2 +-
 dump/dump.c                              |   7 +-
 hw/acpi/core.c                           |  19 +-
 hw/acpi/cpu_hotplug.c                    |   4 +-
 hw/acpi/ich9.c                           |   2 +-
 hw/acpi/piix4.c                          |   2 +-
 hw/arm/allwinner-a10.c                   |  27 +--
 hw/arm/armsse.c                          | 208 ++++++------------
 hw/arm/armv7m.c                          |  47 ++---
 hw/arm/aspeed.c                          |  24 +--
 hw/arm/aspeed_ast2600.c                  | 124 ++++-------
 hw/arm/aspeed_soc.c                      |  85 +++-----
 hw/arm/bcm2835_peripherals.c             |  81 ++-----
 hw/arm/bcm2836.c                         |  35 +--
 hw/arm/cubieboard.c                      |  14 +-
 hw/arm/digic.c                           |  18 +-
 hw/arm/digic_boards.c                    |   3 +-
 hw/arm/exynos4210.c                      |  13 +-
 hw/arm/fsl-imx25.c                       |  58 ++---
 hw/arm/fsl-imx31.c                       |  34 +--
 hw/arm/fsl-imx6.c                        |  85 +++-----
 hw/arm/fsl-imx6ul.c                      |  24 +--
 hw/arm/fsl-imx7.c                        |  31 ++-
 hw/arm/highbank.c                        |  12 +-
 hw/arm/integratorcp.c                    |   2 +-
 hw/arm/microbit.c                        |   4 +-
 hw/arm/mps2-tz.c                         |  31 ++-
 hw/arm/mps2.c                            |  12 +-
 hw/arm/msf2-soc.c                        |  29 +--
 hw/arm/musca.c                           |  18 +-
 hw/arm/musicpal.c                        |   4 +-
 hw/arm/nrf51_soc.c                       |  36 +---
 hw/arm/orangepi.c                        |  13 +-
 hw/arm/raspi.c                           |   2 +-
 hw/arm/realview.c                        |   6 +-
 hw/arm/sbsa-ref.c                        |  16 +-
 hw/arm/stellaris.c                       |   4 +-
 hw/arm/stm32f205_soc.c                   |  37 +---
 hw/arm/stm32f405_soc.c                   |  48 ++---
 hw/arm/versatilepb.c                     |   4 +-
 hw/arm/vexpress.c                        |   8 +-
 hw/arm/virt.c                            |  44 ++--
 hw/arm/xilinx_zynq.c                     |   6 +-
 hw/arm/xlnx-versal-virt.c                |   8 +-
 hw/arm/xlnx-versal.c                     |  30 ++-
 hw/arm/xlnx-zcu102.c                     |   8 +-
 hw/arm/xlnx-zynqmp.c                     | 117 ++++------
 hw/block/fdc.c                           |  12 +-
 hw/block/xen-block.c                     |  30 +--
 hw/char/serial-pci-multi.c               |   5 +-
 hw/char/serial-pci.c                     |   5 +-
 hw/char/serial.c                         |  10 +-
 hw/core/bus.c                            |  12 +-
 hw/core/cpu.c                            |   3 +-
 hw/core/machine.c                        |   5 +-
 hw/core/numa.c                           |  55 ++---
 hw/core/platform-bus.c                   |   6 +-
 hw/core/qdev-properties-system.c         |  32 +--
 hw/core/qdev-properties.c                |  93 +++-----
 hw/core/qdev.c                           |  16 +-
 hw/cpu/a15mpcore.c                       |   5 +-
 hw/cpu/a9mpcore.c                        |  21 +-
 hw/cpu/arm11mpcore.c                     |  17 +-
 hw/cpu/core.c                            |  10 +-
 hw/cpu/realview_mpcore.c                 |   9 +-
 hw/display/bcm2835_fb.c                  |   8 +-
 hw/display/virtio-gpu-base.c             |   5 +-
 hw/display/virtio-gpu-pci.c              |  11 +-
 hw/display/virtio-vga.c                  |  10 +-
 hw/dma/bcm2835_dma.c                     |   9 +-
 hw/dma/sparc32_dma.c                     |   6 +-
 hw/dma/xilinx_axidma.c                   |   4 +-
 hw/gpio/aspeed_gpio.c                    |   5 +-
 hw/gpio/bcm2835_gpio.c                   |  15 +-
 hw/hyperv/vmbus.c                        |   5 +-
 hw/i386/pc.c                             |  48 ++---
 hw/i386/pc_piix.c                        |   4 +-
 hw/i386/pc_q35.c                         |  28 +--
 hw/i386/x86.c                            |   7 +-
 hw/ide/qdev.c                            |   7 +-
 hw/intc/apic_common.c                    |   5 +-
 hw/intc/arm_gic_kvm.c                    |   4 +-
 hw/intc/arm_gicv3_its_kvm.c              |   5 +-
 hw/intc/arm_gicv3_kvm.c                  |   4 +-
 hw/intc/armv7m_nvic.c                    |   9 +-
 hw/intc/nios2_iic.c                      |   8 +-
 hw/intc/pnv_xive.c                       |  17 +-
 hw/intc/realview_gic.c                   |   5 +-
 hw/intc/spapr_xive.c                     |  17 +-
 hw/intc/xics.c                           |   9 +-
 hw/intc/xics_kvm.c                       |   4 +-
 hw/intc/xive.c                           |  17 +-
 hw/isa/piix4.c                           |   5 +-
 hw/m68k/q800.c                           |   4 +-
 hw/mem/nvdimm.c                          |  30 +--
 hw/mem/pc-dimm.c                         |  18 +-
 hw/microblaze/petalogix_ml605_mmu.c      |  24 +--
 hw/microblaze/petalogix_s3adsp1800_mmu.c |   2 +-
 hw/microblaze/xlnx-zynqmp-pmu.c          |  39 ++--
 hw/mips/boston.c                         |   4 +-
 hw/mips/cps.c                            |  41 ++--
 hw/mips/jazz.c                           |   4 +-
 hw/mips/malta.c                          |   4 +-
 hw/misc/aspeed_sdmc.c                    |   8 +-
 hw/misc/bcm2835_mbox.c                   |   9 +-
 hw/misc/bcm2835_property.c               |  17 +-
 hw/misc/iotkit-sysctl.c                  |   2 +-
 hw/misc/ivshmem.c                        |   4 +-
 hw/misc/macio/cuda.c                     |   5 +-
 hw/misc/macio/macio.c                    |  35 ++-
 hw/misc/macio/pmu.c                      |   5 +-
 hw/misc/pca9552.c                        |   5 +-
 hw/misc/tmp105.c                         |   5 +-
 hw/misc/tmp421.c                         |   5 +-
 hw/net/ne2000-isa.c                      |   7 +-
 hw/net/virtio-net.c                      |   7 +-
 hw/net/xilinx_axienet.c                  |   4 +-
 hw/pci-host/pnv_phb3.c                   |  33 ++-
 hw/pci-host/pnv_phb4.c                   |   9 +-
 hw/pci-host/pnv_phb4_pec.c               |   9 +-
 hw/pci-host/prep.c                       |   4 +-
 hw/ppc/e500.c                            |   5 +-
 hw/ppc/mac_newworld.c                    |  10 +-
 hw/ppc/mac_oldworld.c                    |   4 +-
 hw/ppc/pnv.c                             | 171 +++++++--------
 hw/ppc/pnv_core.c                        |   4 +-
 hw/ppc/pnv_psi.c                         |  22 +-
 hw/ppc/rs6000_mc.c                       |   9 +-
 hw/ppc/spapr.c                           |  77 +++----
 hw/ppc/spapr_caps.c                      |  15 +-
 hw/ppc/spapr_cpu_core.c                  |  15 +-
 hw/ppc/spapr_drc.c                       |  16 +-
 hw/ppc/spapr_hcall.c                     |   3 +-
 hw/ppc/spapr_irq.c                       |  11 +-
 hw/ppc/spapr_pci.c                       |  16 +-
 hw/ppc/spapr_pci_nvlink2.c               |   3 +-
 hw/riscv/opentitan.c                     |  13 +-
 hw/riscv/sifive_e.c                      |  10 +-
 hw/riscv/sifive_u.c                      |  11 +-
 hw/riscv/spike.c                         |   4 +-
 hw/riscv/virt.c                          |   4 +-
 hw/rx/rx-gdbsim.c                        |  12 +-
 hw/s390x/css.c                           |   5 +-
 hw/s390x/event-facility.c                |  13 +-
 hw/s390x/ipl.c                           |  27 ++-
 hw/s390x/s390-pci-bus.c                  |  14 +-
 hw/s390x/s390-skeys.c                    |   2 +-
 hw/s390x/s390-stattrib.c                 |   2 +-
 hw/s390x/s390-virtio-ccw.c               |  20 +-
 hw/s390x/sclp.c                          |  13 +-
 hw/s390x/virtio-ccw-crypto.c             |  10 +-
 hw/s390x/virtio-ccw-rng.c                |   8 +-
 hw/scsi/scsi-bus.c                       |  15 +-
 hw/scsi/vhost-scsi.c                     |   4 +-
 hw/sd/aspeed_sdhci.c                     |  15 +-
 hw/sd/sd.c                               |   3 +-
 hw/sd/ssi-sd.c                           |  11 +-
 hw/smbios/smbios.c                       |  33 +--
 hw/sparc/sun4m.c                         |   2 +-
 hw/sparc64/sun4u.c                       |   2 +-
 hw/usb/bus.c                             |   7 +-
 hw/usb/dev-storage.c                     |   9 +-
 hw/usb/hcd-dwc2.c                        |   9 +-
 hw/vfio/pci-quirks.c                     |   5 +-
 hw/vfio/pci.c                            |  10 +-
 hw/virtio/virtio-balloon.c               |  17 +-
 hw/virtio/virtio-crypto-pci.c            |   9 +-
 hw/virtio/virtio-iommu-pci.c             |   4 +-
 hw/virtio/virtio-pmem-pci.c              |   2 +-
 hw/virtio/virtio-rng-pci.c               |   8 +-
 hw/virtio/virtio-rng.c                   |  10 +-
 hw/xen/xen_pt_config_init.c              |   3 +-
 iothread.c                               |  18 +-
 linux-user/syscall.c                     |   2 +-
 monitor/hmp-cmds.c                       |  11 +-
 monitor/monitor.c                        |  21 +-
 net/colo-compare.c                       |  26 +--
 net/dump.c                               |  13 +-
 net/filter-buffer.c                      |  13 +-
 net/filter.c                             |   2 +-
 net/net.c                                |  10 +-
 net/tap.c                                |   6 +-
 qapi/opts-visitor.c                      |  58 ++---
 qapi/qapi-clone-visitor.c                |  67 +++---
 qapi/qapi-dealloc-visitor.c              |  27 ++-
 qapi/qapi-visit-core.c                   | 197 ++++++++---------
 qapi/qobject-input-visitor.c             | 109 ++++++----
 qapi/qobject-output-visitor.c            |  27 ++-
 qapi/string-input-visitor.c              |  67 +++---
 qapi/string-output-visitor.c             |  32 +--
 qdev-monitor.c                           |  38 ++--
 qemu-img.c                               |  23 +-
 qga/commands-posix.c                     |   4 +-
 qga/commands-win32.c                     |  22 +-
 qom/object.c                             | 235 ++++++++++-----------
 qom/object_interfaces.c                  |  30 +--
 qom/qom-hmp-cmds.c                       |   2 +-
 qom/qom-qmp-cmds.c                       |   2 +-
 qom/qom-qobject.c                        |  14 +-
 softmmu/vl.c                             |  17 +-
 target/arm/cpu64.c                       |  15 +-
 target/arm/monitor.c                     |   7 +-
 target/i386/cpu.c                        |  98 +++------
 target/ppc/compat.c                      |   5 +-
 target/ppc/translate_init.inc.c          |   2 +-
 target/s390x/cpu_models.c                |  17 +-
 target/sparc/cpu.c                       |   5 +-
 tpm.c                                    |   5 +-
 ui/console.c                             |   4 +-
 ui/vnc.c                                 |   2 +-
 util/main-loop.c                         |   4 +-
 util/qemu-config.c                       |  25 +--
 util/qemu-option.c                       | 258 ++++++++++++-----------
 scripts/qapi/commands.py                 |  22 +-
 scripts/qapi/visit.py                    | 107 ++++------
 274 files changed, 2349 insertions(+), 3524 deletions(-)

-- 
2.26.2


Re: [PATCH v2 00/44] Less clumsy error checking
Posted by no-reply@patchew.org 3 years, 9 months ago
Patchew URL: https://patchew.org/QEMU/20200702155000.3455325-1-armbru@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH v2 00/44] Less clumsy error checking
Type: series
Message-id: 20200702155000.3455325-1-armbru@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
581316d hmp: Ignore Error objects where the return value suffices
382f9cc qdev: Ignore Error objects where the return value suffices
2d54031 qemu-img: Ignore Error objects where the return value suffices
c1da551 error: Avoid error_propagate() after migrate_add_blocker()
584033a qapi: Purge error_propagate() from QAPI core
d5c18e7 qapi: Smooth visitor error checking in generated code
a0b2eb7 qapi: Smooth another visitor error checking pattern
59fbe03 error: Reduce unnecessary error propagation
d5401ed error: Eliminate error_propagate() manually
28da452 error: Eliminate error_propagate() with Coccinelle, part 2
249518d error: Eliminate error_propagate() with Coccinelle, part 1
79d26b3 error: Avoid unnecessary error_propagate() after error_setg()
69f21ee qdev: Use returned bool to check for failure, Coccinelle part
cc10b4f qdev: Make functions taking Error ** return bool, not void
937e007 qom: Make functions taking Error ** return bool, not 0/-1
c13008d qom: Use returned bool to check for failure, manual part
a76e6b8a qom: Use returned bool to check for failure, Coccinelle part
5831b19 qom: Make functions taking Error ** return bool, not void
ee89136 qom: Put name parameter before value / visitor parameter
cca92e7 qom: Use return values to check for error where that's simpler
b3e4fbd qom: Don't handle impossible object_property_get_link() failure
64c3868 qom: Crash more nicely on object_property_get_link() failure
1045bbb qom: Rename qdev_get_type() to object_get_type()
a90aa52 qom: Use error_reportf_err() instead of g_printerr() in examples
042c119 s390x/pci: Fix harmless mistake in zpci's property fid's setter
7556520 block/parallels: Simplify parallels_open() after previous commit
67c3627 qapi: Use returned bool to check for failure, manual part
d461f88 qapi: Use returned bool to check for failure, Coccinelle part
61c3c84 qapi: Make visitor functions taking Error ** return bool, not void
e11841d hmp: Eliminate a variable in hmp_migrate_set_parameter()
b11147d block: Avoid error accumulation in bdrv_img_create()
5ddfdab qemu-option: Use returned bool to check for failure
132ed75 qemu-option: Make functions taking Error ** return bool, not void
48a09ea qemu-option: Replace opt_set() by cleaner opt_validate()
7ea945d qemu-option: Factor out helper opt_create()
378230d qemu-option: Simplify around find_default_by_name()
419b8e9 qemu-option: Factor out helper find_default_by_name()
066fe51 qemu-option: Make uses of find_desc_by_name() more similar
5ce56fe qemu-option: Check return value instead of @err where convenient
367ec25 virtio-crypto-pci: Tidy up virtio_crypto_pci_realize()
8df3b8f macio: Tidy up error handling in macio_newworld_realize()
0e00e46 qdev: Use returned bool to check for qdev_realize() etc. failure
15a41a5 error: Document Error API usage rules
6cc06a1 error: Improve examples in error.h's big comment

=== OUTPUT BEGIN ===
1/44 Checking commit 6cc06a1b48e4 (error: Improve examples in error.h's big comment)
ERROR: Error messages should not contain newlines
#37: FILE: include/qapi/error.h:27:
+ *     error_setg(errp, "invalid quark\n" // WRONG!

total: 1 errors, 0 warnings, 42 lines checked

Patch 1/44 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

2/44 Checking commit 15a41a5ba273 (error: Document Error API usage rules)
3/44 Checking commit 0e00e463e690 (qdev: Use returned bool to check for qdev_realize() etc. failure)
4/44 Checking commit 8df3b8f872d3 (macio: Tidy up error handling in macio_newworld_realize())
5/44 Checking commit 367ec250efbc (virtio-crypto-pci: Tidy up virtio_crypto_pci_realize())
6/44 Checking commit 5ce56fec2a32 (qemu-option: Check return value instead of @err where convenient)
7/44 Checking commit 066fe5182eff (qemu-option: Make uses of find_desc_by_name() more similar)
8/44 Checking commit 419b8e946ee0 (qemu-option: Factor out helper find_default_by_name())
9/44 Checking commit 378230df0dc2 (qemu-option: Simplify around find_default_by_name())
10/44 Checking commit 7ea945df03f9 (qemu-option: Factor out helper opt_create())
11/44 Checking commit 48a09ea2ba72 (qemu-option: Replace opt_set() by cleaner opt_validate())
12/44 Checking commit 132ed750d145 (qemu-option: Make functions taking Error ** return bool, not void)
13/44 Checking commit 5ddfdab3ea45 (qemu-option: Use returned bool to check for failure)
14/44 Checking commit b11147d3bdb9 (block: Avoid error accumulation in bdrv_img_create())
15/44 Checking commit e11841d3030d (hmp: Eliminate a variable in hmp_migrate_set_parameter())
16/44 Checking commit 61c3c848b6f0 (qapi: Make visitor functions taking Error ** return bool, not void)
WARNING: line over 80 characters
#2444: FILE: scripts/qapi/visit.py:26:
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error **errp);

WARNING: line over 80 characters
#2512: FILE: scripts/qapi/visit.py:124:
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)

WARNING: line over 80 characters
#2541: FILE: scripts/qapi/visit.py:160:
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error **errp)

WARNING: line over 80 characters
#2556: FILE: scripts/qapi/visit.py:174:
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)

WARNING: line over 80 characters
#2585: FILE: scripts/qapi/visit.py:251:
+bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)

total: 0 errors, 5 warnings, 2403 lines checked

Patch 16/44 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
17/44 Checking commit d461f8867781 (qapi: Use returned bool to check for failure, Coccinelle part)
18/44 Checking commit 67c362706f2c (qapi: Use returned bool to check for failure, manual part)
WARNING: Block comments use a leading /* on a separate line
#75: FILE: accel/kvm/kvm-all.c:3154:
+        /* The value was checked in visit_type_OnOffSplit() above. If

total: 0 errors, 1 warnings, 187 lines checked

Patch 18/44 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
19/44 Checking commit 75565203b812 (block/parallels: Simplify parallels_open() after previous commit)
20/44 Checking commit 042c119aa19e (s390x/pci: Fix harmless mistake in zpci's property fid's setter)
21/44 Checking commit a90aa524a204 (qom: Use error_reportf_err() instead of g_printerr() in examples)
22/44 Checking commit 1045bbbb2d70 (qom: Rename qdev_get_type() to object_get_type())
23/44 Checking commit 64c3868a955b (qom: Crash more nicely on object_property_get_link() failure)
24/44 Checking commit b3e4fbdfec68 (qom: Don't handle impossible object_property_get_link() failure)
25/44 Checking commit cca92e793452 (qom: Use return values to check for error where that's simpler)
26/44 Checking commit ee891363b634 (qom: Put name parameter before value / visitor parameter)
27/44 Checking commit 5831b192b1dd (qom: Make functions taking Error ** return bool, not void)
28/44 Checking commit a76e6b8a15e6 (qom: Use returned bool to check for failure, Coccinelle part)
29/44 Checking commit c13008d7bb4c (qom: Use returned bool to check for failure, manual part)
30/44 Checking commit 937e00767b62 (qom: Make functions taking Error ** return bool, not 0/-1)
31/44 Checking commit cc10b4f41f1a (qdev: Make functions taking Error ** return bool, not void)
32/44 Checking commit 69f21ee97c11 (qdev: Use returned bool to check for failure, Coccinelle part)
33/44 Checking commit 79d26b3ac25a (error: Avoid unnecessary error_propagate() after error_setg())
34/44 Checking commit 249518ddad5c (error: Eliminate error_propagate() with Coccinelle, part 1)
35/44 Checking commit 28da452ec5a2 (error: Eliminate error_propagate() with Coccinelle, part 2)
36/44 Checking commit d5401ede69e8 (error: Eliminate error_propagate() manually)
37/44 Checking commit 59fbe0365f51 (error: Reduce unnecessary error propagation)
38/44 Checking commit a0b2eb7cd24c (qapi: Smooth another visitor error checking pattern)
39/44 Checking commit d5c18e763db3 (qapi: Smooth visitor error checking in generated code)
40/44 Checking commit 584033a37ab4 (qapi: Purge error_propagate() from QAPI core)
41/44 Checking commit c1da55153c47 (error: Avoid error_propagate() after migrate_add_blocker())
42/44 Checking commit 2d5403100bb7 (qemu-img: Ignore Error objects where the return value suffices)
43/44 Checking commit 382f9cc1af9d (qdev: Ignore Error objects where the return value suffices)
44/44 Checking commit 581316d1a224 (hmp: Ignore Error objects where the return value suffices)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20200702155000.3455325-1-armbru@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [PATCH v2 00/44] Less clumsy error checking
Posted by Markus Armbruster 3 years, 9 months ago
diff -w between v1 rebased and v2, with:

diff --git a/include/qapi/error.h b/include/qapi/error.h
index c3d84d610a..5ceb3ace06 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -145,10 +145,10 @@
  * Likewise, do *not*
  *     Error *err = NULL;
  *     if (cond1) {
- *         error_setg(err, ...);
+ *         error_setg(&err, ...);
  *     }
  *     if (cond2) {
- *         error_setg(err, ...); // WRONG!
+ *         error_setg(&err, ...); // WRONG!
  *     }
  * because this may pass a non-null err to error_setg().
  */
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 7d1b8d579c..ebc19ede7f 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -284,7 +284,7 @@ void visit_free(Visitor *v);
  * On failure, set *@obj to NULL and store an error through @errp.
  * Can happen only when @v is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * After visit_start_struct() succeeds, the caller may visit its
  * members one after the other, passing the member's name and address
@@ -304,7 +304,7 @@ bool visit_start_struct(Visitor *v, const char *name, void **obj,
  * On failure, store an error through @errp.  Can happen only when @v
  * is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * Should be called prior to visit_end_struct() if all other
  * intermediate visit steps were successful, to allow the visitor one
@@ -343,7 +343,7 @@ void visit_end_struct(Visitor *v, void **obj);
  * On failure, set *@list to NULL and store an error through @errp.
  * Can happen only when @v is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * After visit_start_list() succeeds, the caller may visit its members
  * one after the other.  A real visit (where @list is non-NULL) uses
@@ -380,7 +380,7 @@ GenericList *visit_next_list(Visitor *v, GenericList *tail, size_t size);
  * On failure, store an error through @errp.  Can happen only when @v
  * is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * Should be called prior to visit_end_list() if all other
  * intermediate visit steps were successful, to allow the visitor one
@@ -418,7 +418,7 @@ void visit_end_list(Visitor *v, void **list);
  * On failure, set *@obj to NULL and store an error through @errp.
  * Can happen only when @v is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * If successful, this must be paired with visit_end_alternate() with
  * the same @obj to clean up, even if visiting the contents of the
@@ -476,7 +476,7 @@ bool visit_optional(Visitor *v, const char *name, bool *present);
  * On failure, store an error through @errp.  Can happen only when @v
  * is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * May call visit_type_str() under the hood, and the enum visit may
  * fail even if the corresponding string visit succeeded; this implies
@@ -510,7 +510,7 @@ bool visit_is_dealloc(Visitor *v);
  * On failure, store an error through @errp.  Can happen only when @v
  * is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  */
 bool visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp);
 
@@ -591,7 +591,7 @@ bool visit_type_size(Visitor *v, const char *name, uint64_t *obj,
  * On failure, store an error through @errp.  Can happen only when @v
  * is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  */
 bool visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp);
 
@@ -612,7 +612,7 @@ bool visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp);
  * On failure, set *@obj to NULL and store an error through @errp.
  * Can happen only when @v is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * FIXME: Callers that try to output NULL *obj should not be allowed.
  */
@@ -631,7 +631,7 @@ bool visit_type_str(Visitor *v, const char *name, char **obj, Error **errp);
  * On failure, store an error through @errp.  Can happen only when @v
  * is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  */
 bool visit_type_number(Visitor *v, const char *name, double *obj,
                        Error **errp);
@@ -649,7 +649,7 @@ bool visit_type_number(Visitor *v, const char *name, double *obj,
  * On failure, set *@obj to NULL and store an error through @errp.
  * Can happen only when @v is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  *
  * Note that some kinds of input can't express arbitrary QObject.
  * E.g. the visitor returned by qobject_input_visitor_new_keyval()
@@ -669,7 +669,7 @@ bool visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp);
  * On failure, set *@obj to NULL and store an error through @errp.
  * Can happen only when @v is an input visitor.
  *
- * Return true on succes, false on failure.
+ * Return true on success, false on failure.
  */
 bool visit_type_null(Visitor *v, const char *name, QNull **obj,
                      Error **errp);
diff --git a/block/vxhs.c b/block/vxhs.c
index ef2848fb60..dc0e254730 100644
--- a/block/vxhs.c
+++ b/block/vxhs.c
@@ -300,6 +300,7 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
     QemuOpts *opts = NULL;
     QemuOpts *tcp_opts = NULL;
     char *of_vsa_addr = NULL;
+    Error *local_err = NULL;
     const char *vdisk_id_opt;
     const char *server_host_opt;
     int ret = 0;
diff --git a/bootdevice.c b/bootdevice.c
index 8185402a5a..add4e3d2d1 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -303,15 +303,13 @@ static void device_set_bootindex(Object *obj, Visitor *v, const char *name,
     /* check whether bootindex is present in fw_boot_order list  */
     check_boot_index(boot_index, &local_err);
     if (local_err) {
-        goto out;
+        error_propagate(errp, local_err);
+        return;
     }
     /* change bootindex to a new one */
     *prop->bootindex = boot_index;
 
     add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix);
-
-out:
-    error_propagate(errp, local_err);
 }
 
 static void property_release_bootindex(Object *obj, const char *name,
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index b700ff45fe..5037ca265e 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -66,7 +66,6 @@ hwaddr platform_bus_get_mmio_addr(PlatformBusDevice *pbus, SysBusDevice *sbdev,
 
     parent_mr = object_property_get_link(OBJECT(sbdev_mr), "container",
                                          &error_abort);
-    assert(parent_mr);
     if (parent_mr != pbus_mr_obj) {
         /* MMIO region is not mapped on platform bus */
         return -1;
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 81903d2711..67bee1bcb8 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -118,17 +118,15 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms,
 
 void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
 {
-    Error *local_err = NULL;
     Object *cpu = object_new(MACHINE(x86ms)->cpu_type);
 
-    if (!object_property_set_uint(cpu, "apic-id", apic_id, &local_err)) {
+    if (!object_property_set_uint(cpu, "apic-id", apic_id, errp)) {
         goto out;
     }
     qdev_realize(DEVICE(cpu), NULL, errp);
 
 out:
     object_unref(cpu);
-    error_propagate(errp, local_err);
 }
 
 void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version)
diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
index 87bc4aeca1..46835ed085 100644
--- a/hw/intc/arm_gicv3_its_kvm.c
+++ b/hw/intc/arm_gicv3_its_kvm.c
@@ -91,7 +91,6 @@ static void vm_change_state_handler(void *opaque, int running,
 static void kvm_arm_its_realize(DeviceState *dev, Error **errp)
 {
     GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
-    Error *local_err = NULL;
 
     s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_ITS, false);
     if (s->dev_fd < 0) {
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 6705220380..68bb1914b9 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -309,7 +309,6 @@ int ics_set_kvm_state(ICSState *ics, Error **errp)
     }
 
     for (i = 0; i < ics->nr_irqs; i++) {
-        Error *local_err = NULL;
         int ret;
 
         if (ics_irq_free(ics, i)) {
diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c
index e4e09a93e6..dd8cd6db96 100644
--- a/hw/ppc/spapr_pci_nvlink2.c
+++ b/hw/ppc/spapr_pci_nvlink2.c
@@ -141,10 +141,9 @@ static void spapr_phb_pci_collect_nvgpu(PCIBus *bus, PCIDevice *pdev,
     if (tgt) {
         Error *local_err = NULL;
         SpaprPhbPciNvGpuConfig *nvgpus = opaque;
-        Object *mr_gpu = object_property_get_link(po, "nvlink2-mr[0]",
-                                                  &error_abort);
+        Object *mr_gpu = object_property_get_link(po, "nvlink2-mr[0]", NULL);
         Object *mr_npu = object_property_get_link(po, "nvlink2-atsd-mr[0]",
-                                                  &error_abort);
+                                                  NULL);
 
         g_assert(mr_gpu || mr_npu);
         if (mr_gpu) {
diff --git a/net/tap.c b/net/tap.c
index ca48f2a285..f9dcc2ef51 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -790,9 +790,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
             return -1;
         }
 
-        fd = monitor_fd_param(cur_mon, tap->fd, &err);
+        fd = monitor_fd_param(cur_mon, tap->fd, errp);
         if (fd == -1) {
-            error_propagate(errp, err);
             return -1;
         }
 
@@ -837,9 +836,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
         }
 
         for (i = 0; i < nfds; i++) {
-            fd = monitor_fd_param(cur_mon, fds[i], &err);
+            fd = monitor_fd_param(cur_mon, fds[i], errp);
             if (fd == -1) {
-                error_propagate(errp, err);
                 ret = -1;
                 goto free_fail;
             }
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index b186ddb4aa..aaa71f147b 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -278,8 +278,6 @@ out:
 static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
                           Error **errp)
 {
-    Error *local_err = NULL;
-
     HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL);
     if (!thread) {
         error_setg(errp, QERR_QGA_COMMAND_FAILED,
@@ -1269,7 +1267,6 @@ typedef enum {
 static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
 {
     SYSTEM_POWER_CAPABILITIES sys_pwr_caps;
-    Error *local_err = NULL;
 
     ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
     if (!GetPwrCapabilities(&sys_pwr_caps)) {
diff --git a/qom/object.c b/qom/object.c
index 9b479621e4..8d698abf4d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -528,7 +528,8 @@ void object_initialize(void *data, size_t size, const char *typename)
 
 bool object_initialize_child_with_props(Object *parentobj,
                                         const char *propname,
-                             void *childobj, size_t size, const char *type,
+                                        void *childobj, size_t size,
+                                        const char *type,
                                         Error **errp, ...)
 {
     va_list vargs;
@@ -544,7 +545,8 @@ bool object_initialize_child_with_props(Object *parentobj,
 
 bool object_initialize_child_with_propsv(Object *parentobj,
                                          const char *propname,
-                              void *childobj, size_t size, const char *type,
+                                         void *childobj, size_t size,
+                                         const char *type,
                                          Error **errp, va_list vargs)
 {
     bool ok = false;
diff --git a/util/qemu-option.c b/util/qemu-option.c
index da74a239e9..c5a9d49b46 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -281,7 +281,6 @@ static void qemu_opt_del_all(QemuOpts *opts, const char *name)
 const char *qemu_opt_get(QemuOpts *opts, const char *name)
 {
     QemuOpt *opt;
-    const char *def_val;
 
     if (opts == NULL) {
         return NULL;
@@ -289,9 +288,9 @@ const char *qemu_opt_get(QemuOpts *opts, const char *name)
 
     opt = qemu_opt_find(opts, name);
     if (!opt) {
-        def_val = find_default_by_name(opts, name);
-        return def_val;
+        return find_default_by_name(opts, name);
     }
+
     return opt->str;
 }
 
@@ -321,7 +320,6 @@ const char *qemu_opt_iter_next(QemuOptsIter *iter)
 char *qemu_opt_get_del(QemuOpts *opts, const char *name)
 {
     QemuOpt *opt;
-    const char *def_val;
     char *str;
 
     if (opts == NULL) {
@@ -330,8 +328,7 @@ char *qemu_opt_get_del(QemuOpts *opts, const char *name)
 
     opt = qemu_opt_find(opts, name);
     if (!opt) {
-        def_val = find_default_by_name(opts, name);
-        return g_strdup(def_val);
+        return g_strdup(find_default_by_name(opts, name));
     }
     str = opt->str;
     opt->str = NULL;
@@ -523,13 +520,13 @@ static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value,
     return opt;
 }
 
-static bool opt_set(QemuOpts *opts, QemuOpt *opt, bool *help_wanted,
+static bool opt_validate(QemuOpt *opt, bool *help_wanted,
                          Error **errp)
 {
     const QemuOptDesc *desc;
 
-    desc = find_desc_by_name(opts->list->desc, opt->name);
-    if (!desc && !opts_accepts_any(opts)) {
+    desc = find_desc_by_name(opt->opts->list->desc, opt->name);
+    if (!desc && !opts_accepts_any(opt->opts)) {
         error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
         if (help_wanted && is_help_option(opt->name)) {
             *help_wanted = true;
@@ -550,7 +547,7 @@ bool qemu_opt_set(QemuOpts *opts, const char *name, const char *value,
 {
     QemuOpt *opt = opt_create(opts, name, g_strdup(value), false);
 
-    if (!opt_set(opts, opt, NULL, errp)) {
+    if (!opt_validate(opt, NULL, errp)) {
         qemu_opt_del(opt);
         return false;
     }
@@ -844,7 +841,7 @@ static bool opts_do_parse(QemuOpts *opts, const char *params,
 
         opt = opt_create(opts, option, value, prepend);
         g_free(option);
-        if (!opt_set(opts, opt, help_wanted, errp)) {
+        if (!opt_validate(opt, help_wanted, errp)) {
             qemu_opt_del(opt);
             return false;
         }


Re: [PATCH v2 00/44] Less clumsy error checking
Posted by no-reply@patchew.org 3 years, 9 months ago
Patchew URL: https://patchew.org/QEMU/20200702155000.3455325-1-armbru@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20200702155000.3455325-1-armbru@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com