aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:05:46 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:18:08 +0200
commit62a35aaa310807fa161ca041ddb0f308faeb582b (patch)
treeedd58456e5462b42facf9f7317ac253df19fe369 /hw
parent012d4c96e260f99d5ca95cd033274af4fb73b825 (diff)
qapi: Use returned bool to check for failure, Coccinelle part
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; typedef Error; Error *err; @@ - fun(args, &err); - if (err) + if (!fun(args, &err)) { ... } A few line breaks tidied up manually. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-19-armbru@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/block/xen-block.c3
-rw-r--r--hw/core/machine.c3
-rw-r--r--hw/core/qdev-properties-system.c12
-rw-r--r--hw/core/qdev-properties.c38
-rw-r--r--hw/cpu/core.c6
-rw-r--r--hw/gpio/aspeed_gpio.c3
-rw-r--r--hw/i386/pc.c3
-rw-r--r--hw/ide/qdev.c3
-rw-r--r--hw/intc/apic_common.c3
-rw-r--r--hw/mem/nvdimm.c6
-rw-r--r--hw/misc/aspeed_sdmc.c3
-rw-r--r--hw/misc/pca9552.c3
-rw-r--r--hw/misc/tmp105.c3
-rw-r--r--hw/misc/tmp421.c3
-rw-r--r--hw/net/ne2000-isa.c3
-rw-r--r--hw/ppc/spapr_caps.c9
-rw-r--r--hw/ppc/spapr_drc.c10
-rw-r--r--hw/s390x/css.c3
-rw-r--r--hw/usb/dev-storage.c3
-rw-r--r--hw/vfio/pci-quirks.c3
-rw-r--r--hw/virtio/virtio-balloon.c15
21 files changed, 48 insertions, 90 deletions
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 10c44dfda2..48890536a4 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -412,8 +412,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) {
+ if (!visit_type_str(v, name, &str, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 211b4e077a..7ff0af93ef 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -293,8 +293,7 @@ static void machine_set_phandle_start(Object *obj, Visitor *v,
Error *error = NULL;
int64_t value;
- visit_type_int(v, name, &value, &error);
- if (error) {
+ if (!visit_type_int(v, name, &value, &error)) {
error_propagate(errp, error);
return;
}
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 38b0c9f09b..383a54578f 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -92,8 +92,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) {
+ if (!visit_type_str(v, name, &str, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -238,8 +237,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) {
+ if (!visit_type_str(v, name, &str, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -316,8 +314,7 @@ static void set_netdev(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_propagate(errp, local_err);
return;
}
@@ -398,8 +395,7 @@ static void set_audiodev(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_propagate(errp, local_err);
return;
}
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ca7771f307..3cb6faa12b 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -125,8 +125,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) {
+ if (!visit_type_bool(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -189,8 +188,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) {
+ if (!visit_type_bool(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -486,8 +484,7 @@ static void set_string(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_propagate(errp, local_err);
return;
}
@@ -540,8 +537,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) {
+ if (!visit_type_str(v, name, &str, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -762,8 +758,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);
@@ -844,8 +839,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque,
return;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_size(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -894,8 +888,7 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_size(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -976,8 +969,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) {
+ if (!visit_type_str(v, name, &str, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -1076,8 +1068,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) {
+ if (!visit_type_str(v, name, &str, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -1158,8 +1149,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) {
+ if (!visit_type_uint32(v, name, alenptr, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -1490,8 +1480,8 @@ static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_enum(v, prop->name, &speed, prop->info->enum_table, &local_err);
- if (local_err) {
+ if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table,
+ &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -1578,8 +1568,8 @@ static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_enum(v, prop->name, &width, prop->info->enum_table, &local_err);
- if (local_err) {
+ if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table,
+ &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/cpu/core.c b/hw/cpu/core.c
index a92ac597ca..d9857031ca 100644
--- a/hw/cpu/core.c
+++ b/hw/cpu/core.c
@@ -31,8 +31,7 @@ static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_int(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -61,8 +60,7 @@ static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name,
Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_int(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
index dfa9db3d33..3310fe62fe 100644
--- a/hw/gpio/aspeed_gpio.c
+++ b/hw/gpio/aspeed_gpio.c
@@ -762,8 +762,7 @@ static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name,
AspeedGPIOState *s = ASPEED_GPIO(obj);
int set_idx, group_idx = 0;
- visit_type_bool(v, name, &level, &local_err);
- if (local_err) {
+ if (!visit_type_bool(v, name, &level, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index d7f27bc16b..cb15261420 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1862,8 +1862,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
Error *error = NULL;
uint64_t value;
- visit_type_size(v, name, &value, &error);
- if (error) {
+ if (!visit_type_size(v, name, &value, &error)) {
error_propagate(errp, error);
return;
}
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..76c3f78e11 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -428,8 +428,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) {
+ if (!visit_type_uint32(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 76f66e0b19..ec92ffd415 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -53,8 +53,7 @@ static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name,
goto out;
}
- visit_type_size(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_size(v, name, &value, &local_err)) {
goto out;
}
if (value < MIN_NAMESPACE_LABEL_SIZE) {
@@ -89,8 +88,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 25e1e58356..28874445c3 100644
--- a/hw/misc/aspeed_sdmc.c
+++ b/hw/misc/aspeed_sdmc.c
@@ -227,8 +227,7 @@ static void aspeed_sdmc_set_ram_size(Object *obj, Visitor *v, const char *name,
AspeedSDMCState *s = ASPEED_SDMC(obj);
AspeedSDMCClass *asc = ASPEED_SDMC_GET_CLASS(s);
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_int(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
index 68b574d084..d2b99fc706 100644
--- a/hw/misc/pca9552.c
+++ b/hw/misc/pca9552.c
@@ -296,8 +296,7 @@ static void pca955x_set_led(Object *obj, Visitor *v, const char *name,
uint8_t state;
char *state_str;
- visit_type_str(v, name, &state_str, &local_err);
- if (local_err) {
+ if (!visit_type_str(v, name, &state_str, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
index 58dbebca90..2ae0b899be 100644
--- a/hw/misc/tmp105.c
+++ b/hw/misc/tmp105.c
@@ -75,8 +75,7 @@ static void tmp105_set_temperature(Object *obj, Visitor *v, const char *name,
Error *local_err = NULL;
int64_t temp;
- visit_type_int(v, name, &temp, &local_err);
- if (local_err) {
+ if (!visit_type_int(v, name, &temp, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index 74864cd93d..9473382bd5 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -147,8 +147,7 @@ static void tmp421_set_temperature(Object *obj, Visitor *v, const char *name,
int offset = ext_range * 64 * 256;
int tempid;
- visit_type_int(v, name, &temp, &local_err);
- if (local_err) {
+ if (!visit_type_int(v, name, &temp, &local_err)) {
error_propagate(errp, local_err);
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 0c2bc8e06e..52be86e49c 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -88,8 +88,7 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
bool value;
Error *local_err = NULL;
- visit_type_bool(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_bool(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -127,8 +126,7 @@ static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
uint8_t i;
char *val;
- visit_type_str(v, name, &val, &local_err);
- if (local_err) {
+ if (!visit_type_str(v, name, &val, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -171,8 +169,7 @@ static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name,
uint8_t val;
Error *local_err = NULL;
- visit_type_size(v, name, &pagesize, &local_err);
- if (local_err) {
+ if (!visit_type_size(v, name, &pagesize, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 951bcdf2c0..d10193f39e 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -327,8 +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) {
+ if (!visit_start_struct(v, name, NULL, 0, &err)) {
error_propagate(errp, err);
return;
}
@@ -348,14 +347,13 @@ 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) {
+ if (!visit_start_list(v, name, NULL, 0, &err)) {
error_propagate(errp, err);
return;
}
for (i = 0; i < prop_len; i++) {
- visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err);
- if (err) {
+ if (!visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i],
+ &err)) {
error_propagate(errp, err);
return;
}
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index d1e365e3e6..ab28b2fb30 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -2387,8 +2387,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) {
+ if (!visit_type_str(v, name, &str, &local_err)) {
error_propagate(errp, local_err);
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..1467b8034e 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1509,8 +1509,7 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v,
return;
}
- visit_type_uint8(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_uint8(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index ae31f0817a..277747f4f1 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -239,22 +239,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;
}
}
@@ -287,8 +283,7 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v,
Error *local_err = NULL;
int64_t value;
- visit_type_int(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_int(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}