The previous commit enables conversion of visit_foo(..., &err); if (err) { ... }
to if (!visit_foo(..., errp)) { ... } for visitor functions that now return true / false on success / error. Coccinelle script: @@ identifier fun =~ "check_list|input_type_enum|lv_start_struct|lv_type_bool|lv_type_int64|lv_type_str|lv_type_uint64|output_type_enum|parse_type_bool|parse_type_int64|parse_type_null|parse_type_number|parse_type_size|parse_type_str|parse_type_uint64|print_type_bool|print_type_int64|print_type_null|print_type_number|print_type_size|print_type_str|print_type_uint64|qapi_clone_start_alternate|qapi_clone_start_list|qapi_clone_start_struct|qapi_clone_type_bool|qapi_clone_type_int64|qapi_clone_type_null|qapi_clone_type_number|qapi_clone_type_str|qapi_clone_type_uint64|qapi_dealloc_start_list|qapi_dealloc_start_struct|qapi_dealloc_type_anything|qapi_dealloc_type_bool|qapi_dealloc_type_int64|qapi_dealloc_type_null|qapi_dealloc_type_number|qapi_dealloc_type_str|qapi_dealloc_type_uint64|qobject_input_check_list|qobject_input_check_struct|qobject_input_start_alternate|qobject_input_start_list|qobject_input_start_struct|qobject_input_type_any|qobject_input_type_bool|qobject_input_type_bool_keyval|qobject_input_type_int64|qobject_input_type_int64_keyval|qobject_input_type_null|qobject_input_type_number|qobject_input_type_number_keyval|qobject_input_type_size_keyval|qobject_input_type_str|qobject_input_type_str_keyval|qobject_input_type_uint64|qobject_input_type_uint64_keyval|qobject_output_start_list|qobject_output_start_struct|qobject_output_type_any|qobject_output_type_bool|qobject_output_type_int64|qobject_output_type_null|qobject_output_type_number|qobject_output_type_str|qobject_output_type_uint64|start_list|visit_check_list|visit_check_struct|visit_start_alternate|visit_start_list|visit_start_struct|visit_type_.*"; expression list args, args2; typedef Error; Error *err; identifier errp; @@ - fun(args, &err, args2); - if (err) { + if (!fun(args, errp, args2)) { ... when != err - error_propagate(errp, err); ... } @@ identifier fun =~ "check_list|input_type_enum|lv_start_struct|lv_type_bool|lv_type_int64|lv_type_str|lv_type_uint64|output_type_enum|parse_type_bool|parse_type_int64|parse_type_null|parse_type_number|parse_type_size|parse_type_str|parse_type_uint64|print_type_bool|print_type_int64|print_type_null|print_type_number|print_type_size|print_type_str|print_type_uint64|qapi_clone_start_alternate|qapi_clone_start_list|qapi_clone_start_struct|qapi_clone_type_bool|qapi_clone_type_int64|qapi_clone_type_null|qapi_clone_type_number|qapi_clone_type_str|qapi_clone_type_uint64|qapi_dealloc_start_list|qapi_dealloc_start_struct|qapi_dealloc_type_anything|qapi_dealloc_type_bool|qapi_dealloc_type_int64|qapi_dealloc_type_null|qapi_dealloc_type_number|qapi_dealloc_type_str|qapi_dealloc_type_uint64|qobject_input_check_list|qobject_input_check_struct|qobject_input_start_alternate|qobject_input_start_list|qobject_input_start_struct|qobject_input_type_any|qobject_input_type_bool|qobject_input_type_bool_keyval|qobject_input_type_int64|qobject_input_type_int64_keyval|qobject_input_type_null|qobject_input_type_number|qobject_input_type_number_keyval|qobject_input_type_size_keyval|qobject_input_type_str|qobject_input_type_str_keyval|qobject_input_type_uint64|qobject_input_type_uint64_keyval|qobject_output_start_list|qobject_output_start_struct|qobject_output_type_any|qobject_output_type_bool|qobject_output_type_int64|qobject_output_type_null|qobject_output_type_number|qobject_output_type_str|qobject_output_type_uint64|start_list|visit_check_list|visit_check_struct|visit_start_alternate|visit_start_list|visit_start_struct|visit_type_.*"; expression list args, args2; typedef Error; Error *err; @@ - fun(args, &err, args2); - if (err) { + if (!fun(args, &err, args2)) { ... } Eliminate error_propagate() that are now unnecessary. Delete @err that are now unused. Tidy up line breaks and whitespace. Signed-off-by: Markus Armbruster <arm...@redhat.com> --- accel/kvm/kvm-all.c | 5 +-- accel/tcg/tcg-all.c | 5 +-- backends/cryptodev.c | 5 +-- backends/hostmem-file.c | 5 +-- backends/hostmem-memfd.c | 5 +-- backends/hostmem.c | 10 ++---- block/blkdebug.c | 5 +-- block/nbd.c | 5 +-- block/sheepdog.c | 5 +-- block/throttle-groups.c | 8 ++--- bootdevice.c | 3 +- hw/block/xen-block.c | 5 +-- hw/core/machine.c | 5 +-- hw/core/qdev-properties-system.c | 20 +++-------- hw/core/qdev-properties.c | 58 +++++++------------------------- hw/cpu/core.c | 10 ++---- hw/gpio/aspeed_gpio.c | 5 +-- hw/i386/pc.c | 5 +-- hw/ide/qdev.c | 3 +- hw/intc/apic_common.c | 5 +-- hw/mem/nvdimm.c | 8 ++--- hw/misc/aspeed_sdmc.c | 5 +-- hw/misc/pca9552.c | 5 +-- hw/misc/tmp105.c | 5 +-- hw/misc/tmp421.c | 5 +-- hw/net/ne2000-isa.c | 3 +- hw/ppc/spapr_caps.c | 15 ++------- hw/ppc/spapr_drc.c | 13 +++---- hw/s390x/css.c | 5 +-- hw/tpm/tpm_util.c | 5 +-- hw/usb/dev-storage.c | 3 +- hw/vfio/pci-quirks.c | 5 +-- hw/virtio/virtio-balloon.c | 17 +++------- iothread.c | 5 +-- monitor/hmp-cmds.c | 3 +- net/colo-compare.c | 10 ++---- net/dump.c | 5 +-- net/filter-buffer.c | 5 +-- qom/object.c | 56 ++++++++---------------------- qom/object_interfaces.c | 3 +- target/arm/cpu64.c | 15 ++------- target/arm/monitor.c | 4 +-- target/i386/cpu.c | 25 +++----------- target/ppc/compat.c | 5 +-- target/s390x/cpu_models.c | 14 ++------ target/sparc/cpu.c | 5 +-- 46 files changed, 95 insertions(+), 331 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f24d7da783..be02b8e07a 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3106,12 +3106,9 @@ static void kvm_set_kvm_shadow_mem(Object *obj, Visitor *v, Error **errp) { KVMState *s = KVM_STATE(obj); - Error *error = NULL; int64_t value; - visit_type_int(v, name, &value, &error); - if (error) { - error_propagate(errp, error); + if (!visit_type_int(v, name, &value, errp)) { return; } diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 3b4fda5640..eace2c113b 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -182,12 +182,9 @@ static void tcg_set_tb_size(Object *obj, Visitor *v, Error **errp) { TCGState *s = TCG_STATE(obj); - Error *error = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &error); - if (error) { - error_propagate(errp, error); + if (!visit_type_uint32(v, name, &value, errp)) { return; } diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 8645f297e3..17ee76a61e 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -154,12 +154,9 @@ 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) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } if (!value) { diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 098c8e6e64..5b819020b4 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -110,7 +110,6 @@ 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)) { @@ -119,9 +118,7 @@ static void file_memory_backend_set_align(Object *o, Visitor *v, return; } - visit_type_size(v, name, &val, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_size(v, name, &val, errp)) { return; } fb->align = val; diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 9582c7f8fc..4c040a7541 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -77,7 +77,6 @@ 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))) { @@ -85,9 +84,7 @@ memfd_backend_set_hugetlbsize(Object *obj, Visitor *v, const char *name, return; } - visit_type_size(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_size(v, name, &value, errp)) { return; } if (!value) { diff --git a/backends/hostmem.c b/backends/hostmem.c index 2a0c92d458..c614f1bdc1 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -54,7 +54,6 @@ 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)) { @@ -63,9 +62,7 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name, return; } - visit_type_size(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_size(v, name, &value, errp)) { return; } if (!value) { @@ -253,12 +250,9 @@ static void host_memory_backend_set_prealloc_threads(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); - Error *local_err = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } if (value <= 0) { diff --git a/block/blkdebug.c b/block/blkdebug.c index fa4b4fefdc..9c08d8a005 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -359,7 +359,6 @@ static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options, QObject *crumpled_subqdict = NULL; Visitor *v = NULL; BlockPermissionList *perm_list = NULL, *element; - Error *local_err = NULL; *dest = 0; @@ -375,9 +374,7 @@ static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options, } v = qobject_input_visitor_new(crumpled_subqdict); - visit_type_BlockPermissionList(v, NULL, &perm_list, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_BlockPermissionList(v, NULL, &perm_list, errp)) { ret = -EINVAL; goto out; } diff --git a/block/nbd.c b/block/nbd.c index 9789c56476..6876da04a7 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1726,7 +1726,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, SocketAddress *saddr = NULL; QDict *addr = NULL; Visitor *iv = NULL; - Error *local_err = NULL; qdict_extract_subqdict(options, &addr, "server."); if (!qdict_size(addr)) { @@ -1739,9 +1738,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, goto done; } - visit_type_SocketAddress(iv, NULL, &saddr, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_SocketAddress(iv, NULL, &saddr, errp)) { goto done; } diff --git a/block/sheepdog.c b/block/sheepdog.c index 9cb5ae5fc6..a6a91442c9 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -532,7 +532,6 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp) QDict *server = NULL; Visitor *iv = NULL; SocketAddress *saddr = NULL; - Error *local_err = NULL; qdict_extract_subqdict(options, &server, "server."); @@ -541,9 +540,7 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp) goto done; } - visit_type_SocketAddress(iv, NULL, &saddr, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_SocketAddress(iv, NULL, &saddr, errp)) { goto done; } diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 60a2aad75a..dba2bb6451 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -811,7 +811,6 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name, ThrottleGroup *tg = THROTTLE_GROUP(obj); ThrottleConfig *cfg; ThrottleParamInfo *info = opaque; - Error *local_err = NULL; int64_t value; /* If we have finished initialization, don't accept individual property @@ -823,9 +822,7 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name, return; } - visit_type_int64(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int64(v, name, &value, errp)) { return; } if (value < 0) { @@ -892,8 +889,7 @@ static void throttle_group_set_limits(Object *obj, Visitor *v, ThrottleLimits *argp; Error *local_err = NULL; - visit_type_ThrottleLimits(v, name, &argp, &local_err); - if (local_err) { + if (!visit_type_ThrottleLimits(v, name, &argp, &local_err)) { goto ret; } qemu_mutex_lock(&tg->lock); diff --git a/bootdevice.c b/bootdevice.c index 0ff55e2b79..fb09d3c668 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -297,8 +297,7 @@ static void device_set_bootindex(Object *obj, Visitor *v, const char *name, int32_t boot_index; Error *local_err = NULL; - visit_type_int32(v, name, &boot_index, &local_err); - if (local_err) { + if (!visit_type_int32(v, name, &boot_index, &local_err)) { goto out; } /* check whether bootindex is present in fw_boot_order list */ diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 10c44dfda2..6ca6f18c7b 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -403,7 +403,6 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, DeviceState *dev = DEVICE(obj); Property *prop = opaque; XenBlockVdev *vdev = qdev_get_prop_ptr(dev, prop); - Error *local_err = NULL; char *str, *p; const char *end; @@ -412,9 +411,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } diff --git a/hw/core/machine.c b/hw/core/machine.c index 1d80ab0e1d..109eb3bb24 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -290,12 +290,9 @@ static void machine_set_phandle_start(Object *obj, Visitor *v, Error **errp) { MachineState *ms = MACHINE(obj); - Error *error = NULL; int64_t value; - visit_type_int(v, name, &value, &error); - if (error) { - error_propagate(errp, error); + if (!visit_type_int(v, name, &value, errp)) { return; } diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 38b0c9f09b..f69e2858d1 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -80,7 +80,6 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name, { DeviceState *dev = DEVICE(obj); Property *prop = opaque; - Error *local_err = NULL; void **ptr = qdev_get_prop_ptr(dev, prop); char *str; BlockBackend *blk; @@ -92,9 +91,7 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } @@ -227,7 +224,6 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { DeviceState *dev = DEVICE(obj); - Error *local_err = NULL; Property *prop = opaque; CharBackend *be = qdev_get_prop_ptr(dev, prop); Chardev *s; @@ -238,9 +234,7 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } @@ -307,7 +301,6 @@ static void set_netdev(Object *obj, Visitor *v, const char *name, NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop); NetClientState **ncs = peers_ptr->ncs; NetClientState *peers[MAX_QUEUE_NUM]; - Error *local_err = NULL; int queues, err = 0, i = 0; char *str; @@ -316,9 +309,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } @@ -389,7 +380,6 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, Property *prop = opaque; QEMUSoundCard *card = qdev_get_prop_ptr(dev, prop); AudioState *state; - Error *local_err = NULL; int err = 0; char *str; @@ -398,9 +388,7 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 71f8aca7c6..fa88a8885c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -116,7 +116,6 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name, { DeviceState *dev = DEVICE(obj); Property *prop = opaque; - Error *local_err = NULL; bool value; if (dev->realized) { @@ -124,9 +123,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name, return; } - visit_type_bool(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_bool(v, name, &value, errp)) { return; } bit_prop_set(dev, prop, value); @@ -180,7 +177,6 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name, { DeviceState *dev = DEVICE(obj); Property *prop = opaque; - Error *local_err = NULL; bool value; if (dev->realized) { @@ -188,9 +184,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name, return; } - visit_type_bool(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_bool(v, name, &value, errp)) { return; } bit64_prop_set(dev, prop, value); @@ -477,7 +471,6 @@ static void set_string(Object *obj, Visitor *v, const char *name, DeviceState *dev = DEVICE(obj); Property *prop = opaque; char **ptr = qdev_get_prop_ptr(dev, prop); - Error *local_err = NULL; char *str; if (dev->realized) { @@ -485,9 +478,7 @@ static void set_string(Object *obj, Visitor *v, const char *name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } g_free(*ptr); @@ -530,7 +521,6 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque, DeviceState *dev = DEVICE(obj); Property *prop = opaque; MACAddr *mac = qdev_get_prop_ptr(dev, prop); - Error *local_err = NULL; int i, pos; char *str, *p; @@ -539,9 +529,7 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } @@ -673,8 +661,7 @@ static void set_pci_devfn(Object *obj, Visitor *v, const char *name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { + if (!visit_type_str(v, name, &str, &local_err)) { error_free(local_err); local_err = NULL; visit_type_int32(v, name, &value, &local_err); @@ -748,16 +735,13 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, Property *prop = opaque; uint32_t *ptr = qdev_get_prop_ptr(dev, prop); uint64_t value; - Error *local_err = NULL; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } - visit_type_size(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_size(v, name, &value, errp)) { return; } @@ -798,16 +782,13 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name, Property *prop = opaque; uint32_t *ptr = qdev_get_prop_ptr(dev, prop); uint64_t value; - Error *local_err = NULL; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } - visit_type_size(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_size(v, name, &value, errp)) { return; } /* value of 0 means "unset" */ @@ -875,7 +856,6 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name, DeviceState *dev = DEVICE(obj); Property *prop = opaque; PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop); - Error *local_err = NULL; char *str, *p; char *e; unsigned long val; @@ -887,9 +867,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } @@ -979,7 +957,6 @@ static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, DeviceState *dev = DEVICE(obj); Property *prop = opaque; QemuUUID *uuid = qdev_get_prop_ptr(dev, prop); - Error *local_err = NULL; char *str; if (dev->realized) { @@ -987,9 +964,7 @@ static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } @@ -1055,7 +1030,6 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, Property *prop = opaque; uint32_t *alenptr = qdev_get_prop_ptr(dev, prop); void **arrayptr = (void *)dev + prop->arrayoffset; - Error *local_err = NULL; void *eltptr; const char *arrayname; int i; @@ -1069,9 +1043,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, name); return; } - visit_type_uint32(v, name, alenptr, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, alenptr, errp)) { return; } if (!*alenptr) { @@ -1394,16 +1366,13 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, Property *prop = opaque; PCIExpLinkSpeed *p = qdev_get_prop_ptr(dev, prop); int speed; - Error *local_err = NULL; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } - visit_type_enum(v, prop->name, &speed, prop->info->enum_table, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table, errp)) { return; } @@ -1482,16 +1451,13 @@ static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, Property *prop = opaque; PCIExpLinkWidth *p = qdev_get_prop_ptr(dev, prop); int width; - Error *local_err = NULL; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } - visit_type_enum(v, prop->name, &width, prop->info->enum_table, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table, errp)) { return; } diff --git a/hw/cpu/core.c b/hw/cpu/core.c index a92ac597ca..3a659291ea 100644 --- a/hw/cpu/core.c +++ b/hw/cpu/core.c @@ -28,12 +28,9 @@ static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { CPUCore *core = CPU_CORE(obj); - Error *local_err = NULL; int64_t value; - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } @@ -58,12 +55,9 @@ static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { CPUCore *core = CPU_CORE(obj); - Error *local_err = NULL; int64_t value; - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c index dfa9db3d33..985a259e05 100644 --- a/hw/gpio/aspeed_gpio.c +++ b/hw/gpio/aspeed_gpio.c @@ -755,16 +755,13 @@ static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name, static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - Error *local_err = NULL; bool level; int pin = 0xfff; char group[4]; AspeedGPIOState *s = ASPEED_GPIO(obj); int set_idx, group_idx = 0; - visit_type_bool(v, name, &level, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_bool(v, name, &level, errp)) { return; } if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 70d832536b..50e431346e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1864,12 +1864,9 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); - Error *error = NULL; uint64_t value; - visit_type_size(v, name, &value, &error); - if (error) { - error_propagate(errp, error); + if (!visit_type_size(v, name, &value, errp)) { return; } if (value > 4 * GiB) { diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index f68fbee93d..358f10a92e 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -245,8 +245,7 @@ static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name, int32_t boot_index; Error *local_err = NULL; - visit_type_int32(v, name, &boot_index, &local_err); - if (local_err) { + if (!visit_type_int32(v, name, &boot_index, &local_err)) { goto out; } /* check whether bootindex is present in fw_boot_order list */ diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 7da2862b3d..dc070343c0 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -420,7 +420,6 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name, { APICCommonState *s = APIC_COMMON(obj); DeviceState *dev = DEVICE(obj); - Error *local_err = NULL; uint32_t value; if (dev->realized) { @@ -428,9 +427,7 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name, return; } - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 93f7af1c58..e6fdf6ccc3 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -45,7 +45,6 @@ static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { NVDIMMDevice *nvdimm = NVDIMM(obj); - Error *local_err = NULL; uint64_t value; if (nvdimm->nvdimm_mr) { @@ -53,9 +52,7 @@ static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name, return; } - visit_type_size(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_size(v, name, &value, errp)) { return; } if (value < MIN_NAMESPACE_LABEL_SIZE) { @@ -88,8 +85,7 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name, Error *local_err = NULL; char *value; - visit_type_str(v, name, &value, &local_err); - if (local_err) { + if (!visit_type_str(v, name, &value, &local_err)) { goto out; } diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c index 6fefb05695..0737d8de81 100644 --- a/hw/misc/aspeed_sdmc.c +++ b/hw/misc/aspeed_sdmc.c @@ -223,13 +223,10 @@ static void aspeed_sdmc_set_ram_size(Object *obj, Visitor *v, const char *name, int i; char *sz; int64_t value; - Error *local_err = NULL; AspeedSDMCState *s = ASPEED_SDMC(obj); AspeedSDMCClass *asc = ASPEED_SDMC_GET_CLASS(s); - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c index cac729e35a..3e82c2838f 100644 --- a/hw/misc/pca9552.c +++ b/hw/misc/pca9552.c @@ -213,14 +213,11 @@ static void pca9552_set_led(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { PCA9552State *s = PCA9552(obj); - Error *local_err = NULL; int led, rc, reg, val; uint8_t state; char *state_str; - visit_type_str(v, name, &state_str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &state_str, errp)) { return; } rc = sscanf(name, "led%2d", &led); diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c index 58dbebca90..b47120492a 100644 --- a/hw/misc/tmp105.c +++ b/hw/misc/tmp105.c @@ -72,12 +72,9 @@ static void tmp105_set_temperature(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { TMP105State *s = TMP105(obj); - Error *local_err = NULL; int64_t temp; - visit_type_int(v, name, &temp, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &temp, errp)) { return; } if (temp >= 128000 || temp < -128000) { diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c index 74864cd93d..49abe2d246 100644 --- a/hw/misc/tmp421.c +++ b/hw/misc/tmp421.c @@ -141,15 +141,12 @@ static void tmp421_set_temperature(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { TMP421State *s = TMP421(obj); - Error *local_err = NULL; int64_t temp; bool ext_range = (s->config[0] & TMP421_CONFIG_RANGE); int offset = ext_range * 64 * 256; int tempid; - visit_type_int(v, name, &temp, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &temp, errp)) { return; } diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c index fdf8faa0d9..765bcd1f0b 100644 --- a/hw/net/ne2000-isa.c +++ b/hw/net/ne2000-isa.c @@ -113,8 +113,7 @@ static void isa_ne2000_set_bootindex(Object *obj, Visitor *v, int32_t boot_index; Error *local_err = NULL; - visit_type_int32(v, name, &boot_index, &local_err); - if (local_err) { + if (!visit_type_int32(v, name, &boot_index, &local_err)) { goto out; } /* check whether bootindex is present in fw_boot_order list */ diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index efdc0dbbcf..416c85bfb1 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -86,11 +86,8 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name, SpaprCapabilityInfo *cap = opaque; SpaprMachineState *spapr = SPAPR_MACHINE(obj); bool value; - Error *local_err = NULL; - visit_type_bool(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_bool(v, name, &value, errp)) { return; } @@ -123,13 +120,10 @@ static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name, { SpaprCapabilityInfo *cap = opaque; SpaprMachineState *spapr = SPAPR_MACHINE(obj); - Error *local_err = NULL; uint8_t i; char *val; - visit_type_str(v, name, &val, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &val, errp)) { return; } @@ -169,11 +163,8 @@ static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name, SpaprMachineState *spapr = SPAPR_MACHINE(obj); uint64_t pagesize; uint8_t val; - Error *local_err = NULL; - visit_type_size(v, name, &pagesize, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_size(v, name, &pagesize, errp)) { return; } diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 951bcdf2c0..c8e8ba2ee8 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -327,9 +327,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name, case FDT_BEGIN_NODE: fdt_depth++; name = fdt_get_name(fdt, fdt_offset, &name_len); - visit_start_struct(v, name, NULL, 0, &err); - if (err) { - error_propagate(errp, err); + if (!visit_start_struct(v, name, NULL, 0, errp)) { return; } break; @@ -348,15 +346,12 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name, int i; prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len); name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); - visit_start_list(v, name, NULL, 0, &err); - if (err) { - error_propagate(errp, err); + if (!visit_start_list(v, name, NULL, 0, errp)) { return; } for (i = 0; i < prop_len; i++) { - visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], + errp)) { return; } } diff --git a/hw/s390x/css.c b/hw/s390x/css.c index d1e365e3e6..519dc91316 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -2377,7 +2377,6 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name, DeviceState *dev = DEVICE(obj); Property *prop = opaque; CssDevId *dev_id = qdev_get_prop_ptr(dev, prop); - Error *local_err = NULL; char *str; int num, n1, n2; unsigned int cssid, ssid, devid; @@ -2387,9 +2386,7 @@ static void set_css_devid(Object *obj, Visitor *v, const char *name, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c index c0a0f3d71f..ca3ea20bdb 100644 --- a/hw/tpm/tpm_util.c +++ b/hw/tpm/tpm_util.c @@ -48,7 +48,6 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { DeviceState *dev = DEVICE(obj); - Error *local_err = NULL; Property *prop = opaque; TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop); char *str; @@ -58,9 +57,7 @@ static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, return; } - visit_type_str(v, name, &str, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &str, errp)) { return; } diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index f5977eb72e..1c3bd2578c 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -736,8 +736,7 @@ static void usb_msd_set_bootindex(Object *obj, Visitor *v, const char *name, int32_t boot_index; Error *local_err = NULL; - visit_type_int32(v, name, &boot_index, &local_err); - if (local_err) { + if (!visit_type_int32(v, name, &boot_index, &local_err)) { goto out; } /* check whether bootindex is present in fw_boot_order list */ diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index d304c81148..3a14b7c303 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1502,16 +1502,13 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, DeviceState *dev = DEVICE(obj); Property *prop = opaque; uint8_t value, *ptr = qdev_get_prop_ptr(dev, prop); - Error *local_err = NULL; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } - visit_type_uint8(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint8(v, name, &value, errp)) { return; } diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 10507b2a43..8eb652a348 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -233,22 +233,18 @@ static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name, VirtIOBalloon *s = opaque; int i; - visit_start_struct(v, name, NULL, 0, &err); - if (err) { + if (!visit_start_struct(v, name, NULL, 0, &err)) { goto out; } - visit_type_int(v, "last-update", &s->stats_last_update, &err); - if (err) { + if (!visit_type_int(v, "last-update", &s->stats_last_update, &err)) { goto out_end; } - visit_start_struct(v, "stats", NULL, 0, &err); - if (err) { + if (!visit_start_struct(v, "stats", NULL, 0, &err)) { goto out_end; } for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) { - visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err); - if (err) { + if (!visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err)) { goto out_nested; } } @@ -278,12 +274,9 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v, Error **errp) { VirtIOBalloon *s = opaque; - Error *local_err = NULL; int64_t value; - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } diff --git a/iothread.c b/iothread.c index b465e5c25b..0598a6d20d 100644 --- a/iothread.c +++ b/iothread.c @@ -239,12 +239,9 @@ static void iothread_set_poll_param(Object *obj, Visitor *v, IOThread *iothread = IOTHREAD(obj); PollParamInfo *info = opaque; int64_t *field = (void *)iothread + info->offset; - Error *local_err = NULL; int64_t value; - visit_type_int64(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int64(v, name, &value, errp)) { return; } diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index d7810cb564..9588c2d81f 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1355,8 +1355,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size = true; - visit_type_size(v, param, &cache_size, &err); - if (err) { + if (!visit_type_size(v, param, &cache_size, &err)) { break; } if (cache_size > INT64_MAX || (size_t)cache_size != cache_size) { diff --git a/net/colo-compare.c b/net/colo-compare.c index b18b096a6e..398b7546ff 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1093,12 +1093,9 @@ static void compare_set_timeout(Object *obj, Visitor *v, Error **errp) { CompareState *s = COLO_COMPARE(obj); - Error *local_err = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } if (!value) { @@ -1124,12 +1121,9 @@ static void compare_set_expired_scan_cycle(Object *obj, Visitor *v, Error **errp) { CompareState *s = COLO_COMPARE(obj); - Error *local_err = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } if (!value) { diff --git a/net/dump.c b/net/dump.c index e8c4071d59..11a737a4bc 100644 --- a/net/dump.c +++ b/net/dump.c @@ -192,12 +192,9 @@ static void filter_dump_set_maxlen(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { NetFilterDumpState *nfds = FILTER_DUMP(obj); - Error *local_err = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } if (value == 0) { diff --git a/net/filter-buffer.c b/net/filter-buffer.c index c3892911b8..dfa211794b 100644 --- a/net/filter-buffer.c +++ b/net/filter-buffer.c @@ -170,12 +170,9 @@ static void filter_buffer_set_interval(Object *obj, Visitor *v, Error **errp) { FilterBufferState *s = FILTER_BUFFER(obj); - Error *local_err = NULL; uint32_t value; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } if (!value) { diff --git a/qom/object.c b/qom/object.c index 6ece96bc2b..780a700542 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2078,11 +2078,8 @@ static void property_set_str(Object *obj, Visitor *v, const char *name, { StringProperty *prop = opaque; char *value; - Error *local_err = NULL; - visit_type_str(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &value, errp)) { return; } @@ -2159,11 +2156,8 @@ static void property_set_bool(Object *obj, Visitor *v, const char *name, { BoolProperty *prop = opaque; bool value; - Error *local_err = NULL; - visit_type_bool(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_bool(v, name, &value, errp)) { return; } @@ -2232,11 +2226,8 @@ static void property_set_enum(Object *obj, Visitor *v, const char *name, { EnumProperty *prop = opaque; int value; - Error *err = NULL; - visit_type_enum(v, name, &value, prop->lookup, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_enum(v, name, &value, prop->lookup, errp)) { return; } prop->set(obj, value, errp); @@ -2305,32 +2296,25 @@ static void property_get_tm(Object *obj, Visitor *v, const char *name, goto out; } - visit_start_struct(v, name, NULL, 0, &err); - if (err) { + if (!visit_start_struct(v, name, NULL, 0, &err)) { goto out; } - visit_type_int32(v, "tm_year", &value.tm_year, &err); - if (err) { + if (!visit_type_int32(v, "tm_year", &value.tm_year, &err)) { goto out_end; } - visit_type_int32(v, "tm_mon", &value.tm_mon, &err); - if (err) { + if (!visit_type_int32(v, "tm_mon", &value.tm_mon, &err)) { goto out_end; } - visit_type_int32(v, "tm_mday", &value.tm_mday, &err); - if (err) { + if (!visit_type_int32(v, "tm_mday", &value.tm_mday, &err)) { goto out_end; } - visit_type_int32(v, "tm_hour", &value.tm_hour, &err); - if (err) { + if (!visit_type_int32(v, "tm_hour", &value.tm_hour, &err)) { goto out_end; } - visit_type_int32(v, "tm_min", &value.tm_min, &err); - if (err) { + if (!visit_type_int32(v, "tm_min", &value.tm_min, &err)) { goto out_end; } - visit_type_int32(v, "tm_sec", &value.tm_sec, &err); - if (err) { + if (!visit_type_int32(v, "tm_sec", &value.tm_sec, &err)) { goto out_end; } visit_check_struct(v, &err); @@ -2392,11 +2376,8 @@ static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name, { uint8_t *field = opaque; uint8_t value; - Error *local_err = NULL; - visit_type_uint8(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint8(v, name, &value, errp)) { return; } @@ -2415,11 +2396,8 @@ static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name, { uint16_t *field = opaque; uint16_t value; - Error *local_err = NULL; - visit_type_uint16(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint16(v, name, &value, errp)) { return; } @@ -2438,11 +2416,8 @@ static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name, { uint32_t *field = opaque; uint32_t value; - Error *local_err = NULL; - visit_type_uint32(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint32(v, name, &value, errp)) { return; } @@ -2461,11 +2436,8 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name, { uint64_t *field = opaque; uint64_t value; - Error *local_err = NULL; - visit_type_uint64(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_uint64(v, name, &value, errp)) { return; } diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 7e26f86fa6..3085ae0b31 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -63,8 +63,7 @@ Object *user_creatable_add_type(const char *type, const char *id, assert(qdict); obj = object_new(type); - visit_start_struct(v, NULL, NULL, 0, &local_err); - if (local_err) { + if (!visit_start_struct(v, NULL, NULL, 0, &local_err)) { goto out; } for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 778cecc2e6..fcb3eedabb 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -464,12 +464,9 @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { ARMCPU *cpu = ARM_CPU(obj); - Error *err = NULL; uint32_t max_vq; - visit_type_uint32(v, name, &max_vq, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_uint32(v, name, &max_vq, errp)) { return; } @@ -510,12 +507,9 @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, { ARMCPU *cpu = ARM_CPU(obj); uint32_t vq = atoi(&name[3]) / 128; - Error *err = NULL; bool value; - visit_type_bool(v, name, &value, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_bool(v, name, &value, errp)) { return; } @@ -546,13 +540,10 @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { ARMCPU *cpu = ARM_CPU(obj); - Error *err = NULL; bool value; uint64_t t; - visit_type_bool(v, name, &value, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_bool(v, name, &value, errp)) { return; } diff --git a/target/arm/monitor.c b/target/arm/monitor.c index ea6598c412..fdab052acd 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -174,11 +174,9 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, Error *err = NULL; visitor = qobject_input_visitor_new(model->props); - visit_start_struct(visitor, NULL, NULL, 0, &err); - if (err) { + if (!visit_start_struct(visitor, NULL, NULL, 0, errp)) { visit_free(visitor); object_unref(obj); - error_propagate(errp, err); return NULL; } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b1b311baa2..ef5cf587b6 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4408,12 +4408,9 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, CPUX86State *env = &cpu->env; const int64_t min = 0; const int64_t max = 0xff + 0xf; - Error *local_err = NULL; int64_t value; - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } if (value < min || value > max) { @@ -4451,12 +4448,9 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v, CPUX86State *env = &cpu->env; const int64_t min = 0; const int64_t max = 0xff; - Error *local_err = NULL; int64_t value; - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } if (value < min || value > max) { @@ -4489,12 +4483,9 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v, CPUX86State *env = &cpu->env; const int64_t min = 0; const int64_t max = 0xf; - Error *local_err = NULL; int64_t value; - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } if (value < min || value > max) { @@ -4594,12 +4585,9 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, const char *name, X86CPU *cpu = X86_CPU(obj); const int64_t min = 0; const int64_t max = INT64_MAX; - Error *local_err = NULL; int64_t value; - visit_type_int(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_int(v, name, &value, errp)) { return; } if (value < min || value > max) { @@ -6799,7 +6787,6 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name, DeviceState *dev = DEVICE(obj); X86CPU *cpu = X86_CPU(obj); BitProperty *fp = opaque; - Error *local_err = NULL; bool value; if (dev->realized) { @@ -6807,9 +6794,7 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name, return; } - visit_type_bool(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_bool(v, name, &value, errp)) { return; } diff --git a/target/ppc/compat.c b/target/ppc/compat.c index fda0dfe8f8..08aede88dc 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -260,13 +260,10 @@ static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name, static void ppc_compat_prop_set(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - Error *local_err = NULL; char *value; uint32_t compat_pvr; - visit_type_str(v, name, &value, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!visit_type_str(v, name, &value, errp)) { return; } diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 2fa609bffe..aadd92247f 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -510,9 +510,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, if (qdict) { visitor = qobject_input_visitor_new(info->props); - visit_start_struct(visitor, NULL, NULL, 0, &err); - if (err) { - error_propagate(errp, err); + if (!visit_start_struct(visitor, NULL, NULL, 0, errp)) { visit_free(visitor); object_unref(obj); return; @@ -1001,7 +999,6 @@ static void get_feature(Object *obj, Visitor *v, const char *name, static void set_feature(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - Error *err = NULL; S390Feat feat = (S390Feat) opaque; DeviceState *dev = DEVICE(obj); S390CPU *cpu = S390_CPU(obj); @@ -1017,9 +1014,7 @@ static void set_feature(Object *obj, Visitor *v, const char *name, return; } - visit_type_bool(v, name, &value, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_bool(v, name, &value, errp)) { return; } if (value) { @@ -1059,7 +1054,6 @@ static void get_feature_group(Object *obj, Visitor *v, const char *name, static void set_feature_group(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - Error *err = NULL; S390FeatGroup group = (S390FeatGroup) opaque; const S390FeatGroupDef *def = s390_feat_group_def(group); DeviceState *dev = DEVICE(obj); @@ -1076,9 +1070,7 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name, return; } - visit_type_bool(v, name, &value, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_bool(v, name, &value, errp)) { return; } if (value) { diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 3f05aba9d6..cf21efd85f 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -801,12 +801,9 @@ static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name, const int64_t min = MIN_NWINDOWS; const int64_t max = MAX_NWINDOWS; SPARCCPU *cpu = SPARC_CPU(obj); - Error *err = NULL; int64_t value; - visit_type_int(v, name, &value, &err); - if (err) { - error_propagate(errp, err); + if (!visit_type_int(v, name, &value, errp)) { return; } -- 2.26.2