From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 10/14] qapi: Use returned bool to check for failure (again)
Date: Wed, 14 Dec 2022 17:46:25 +0100 [thread overview]
Message-ID: <20221214164629.919880-11-armbru@redhat.com> (raw)
In-Reply-To: <20221214164629.919880-1-armbru@redhat.com>
Commit 012d4c96e2 changed the visitor functions taking Error ** to
return bool instead of void, and the commits following it used the new
return value to simplify error checking. Since then a few more uses
in need of the same treatment crept in. Do that. All pretty
mechanical except for
* balloon_stats_get_all()
This is basically the same transformation commit 012d4c96e2 applied
to the virtual walk example in include/qapi/visitor.h.
* set_max_queue_size()
Additionally replace "goto end of function" by return.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221121085054.683122-10-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/kvm/kvm-all.c | 5 +----
hw/core/qdev-properties-system.c | 5 +----
hw/i386/pc.c | 5 +----
hw/virtio/virtio-balloon.c | 20 +++++++++-----------
hw/virtio/virtio-mem.c | 10 ++--------
net/colo-compare.c | 13 ++++---------
target/i386/kvm/kvm.c | 5 +----
util/thread-context.c | 10 ++--------
8 files changed, 21 insertions(+), 52 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index f99b0becd8..e86c33e0e6 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3586,7 +3586,6 @@ static void kvm_set_dirty_ring_size(Object *obj, Visitor *v,
Error **errp)
{
KVMState *s = KVM_STATE(obj);
- Error *error = NULL;
uint32_t value;
if (s->fd != -1) {
@@ -3594,9 +3593,7 @@ static void kvm_set_dirty_ring_size(Object *obj, Visitor *v,
return;
}
- visit_type_uint32(v, name, &value, &error);
- if (error) {
- error_propagate(errp, error);
+ if (!visit_type_uint32(v, name, &value, errp)) {
return;
}
if (value & (value - 1)) {
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index a91f60567a..97a968f477 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -679,14 +679,11 @@ static void set_reserved_region(Object *obj, Visitor *v, const char *name,
{
Property *prop = opaque;
ReservedRegion *rr = object_field_prop_ptr(obj, prop);
- Error *local_err = NULL;
const char *endptr;
char *str;
int ret;
- 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/i386/pc.c b/hw/i386/pc.c
index 546b703cb4..fa69b6f43e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1782,12 +1782,9 @@ static void pc_machine_set_max_fw_size(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;
}
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 73ac5eb675..746f07c4d2 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -241,36 +241,34 @@ static void balloon_stats_poll_cb(void *opaque)
static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- Error *err = NULL;
VirtIOBalloon *s = VIRTIO_BALLOON(obj);
+ bool ok = false;
int i;
- if (!visit_start_struct(v, name, NULL, 0, &err)) {
- goto out;
+ if (!visit_start_struct(v, name, NULL, 0, errp)) {
+ return;
}
- if (!visit_type_int(v, "last-update", &s->stats_last_update, &err)) {
+ if (!visit_type_int(v, "last-update", &s->stats_last_update, errp)) {
goto out_end;
}
- if (!visit_start_struct(v, "stats", NULL, 0, &err)) {
+ if (!visit_start_struct(v, "stats", NULL, 0, errp)) {
goto out_end;
}
for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
- if (!visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err)) {
+ if (!visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], errp)) {
goto out_nested;
}
}
- visit_check_struct(v, &err);
+ ok = visit_check_struct(v, errp);
out_nested:
visit_end_struct(v, NULL);
- if (!err) {
- visit_check_struct(v, &err);
+ if (ok) {
+ visit_check_struct(v, errp);
}
out_end:
visit_end_struct(v, NULL);
-out:
- error_propagate(errp, err);
}
static void balloon_stats_get_poll_interval(Object *obj, Visitor *v,
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ed170def48..d96bde1fab 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -1094,12 +1094,9 @@ static void virtio_mem_set_requested_size(Object *obj, Visitor *v,
Error **errp)
{
VirtIOMEM *vmem = VIRTIO_MEM(obj);
- Error *err = NULL;
uint64_t value;
- visit_type_size(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_size(v, name, &value, errp)) {
return;
}
@@ -1159,7 +1156,6 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
VirtIOMEM *vmem = VIRTIO_MEM(obj);
- Error *err = NULL;
uint64_t value;
if (DEVICE(obj)->realized) {
@@ -1167,9 +1163,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_size(v, name, &value, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_size(v, name, &value, errp)) {
return;
}
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 787c740f14..7f9e6f89ce 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -1135,22 +1135,17 @@ static void set_max_queue_size(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
- Error *local_err = NULL;
uint64_t value;
- visit_type_uint64(v, name, &value, &local_err);
- if (local_err) {
- goto out;
+ if (!visit_type_uint64(v, name, &value, errp)) {
+ return;
}
if (!value) {
- error_setg(&local_err, "Property '%s.%s' requires a positive value",
+ error_setg(errp, "Property '%s.%s' requires a positive value",
object_get_typename(obj), name);
- goto out;
+ return;
}
max_queue_size = value;
-
-out:
- error_propagate(errp, local_err);
}
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index a213209379..0ab4e0734a 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -5689,7 +5689,6 @@ static void kvm_arch_set_notify_window(Object *obj, Visitor *v,
Error **errp)
{
KVMState *s = KVM_STATE(obj);
- Error *error = NULL;
uint32_t value;
if (s->fd != -1) {
@@ -5697,9 +5696,7 @@ static void kvm_arch_set_notify_window(Object *obj, Visitor *v,
return;
}
- 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/util/thread-context.c b/util/thread-context.c
index 4138245332..2bc7883b9e 100644
--- a/util/thread-context.c
+++ b/util/thread-context.c
@@ -90,16 +90,13 @@ static void thread_context_set_cpu_affinity(Object *obj, Visitor *v,
uint16List *l, *host_cpus = NULL;
unsigned long *bitmap = NULL;
int nbits = 0, ret;
- Error *err = NULL;
if (tc->init_cpu_bitmap) {
error_setg(errp, "Mixing CPU and node affinity not supported");
return;
}
- visit_type_uint16List(v, name, &host_cpus, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_uint16List(v, name, &host_cpus, errp)) {
return;
}
@@ -178,7 +175,6 @@ static void thread_context_set_node_affinity(Object *obj, Visitor *v,
uint16List *l, *host_nodes = NULL;
unsigned long *bitmap = NULL;
struct bitmask *tmp_cpus;
- Error *err = NULL;
int ret, i;
if (tc->init_cpu_bitmap) {
@@ -186,9 +182,7 @@ static void thread_context_set_node_affinity(Object *obj, Visitor *v,
return;
}
- visit_type_uint16List(v, name, &host_nodes, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!visit_type_uint16List(v, name, &host_nodes, errp)) {
return;
}
--
2.37.3
next prev parent reply other threads:[~2022-12-14 16:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 16:46 [PULL 00/14] Miscellaneous patches for 2022-12-14 Markus Armbruster
2022-12-14 16:46 ` [PULL 01/14] Drop more useless casts from void * to pointer Markus Armbruster
2022-12-14 16:46 ` [PULL 02/14] error: Drop some obviously superfluous error_propagate() Markus Armbruster
2022-12-14 16:46 ` [PULL 03/14] error: Drop a few superfluous ERRP_GUARD() Markus Armbruster
2022-12-14 16:46 ` [PULL 04/14] error: Move ERRP_GUARD() to the beginning of the function Markus Armbruster
2022-12-14 16:46 ` [PULL 05/14] monitor: Simplify monitor_fd_param()'s error handling Markus Armbruster
2022-12-14 16:46 ` [PULL 06/14] monitor: Use ERRP_GUARD() in monitor_init() Markus Armbruster
2022-12-14 16:46 ` [PULL 07/14] qemu-config: Make config_parse_qdict() return bool Markus Armbruster
2022-12-14 16:46 ` [PULL 08/14] qemu-config: Use ERRP_GUARD() where obviously appropriate Markus Armbruster
2022-12-14 16:46 ` [PULL 09/14] sockets: " Markus Armbruster
2022-12-14 16:46 ` Markus Armbruster [this message]
2022-12-14 16:46 ` [PULL 11/14] io: Tidy up fat-fingered parameter name Markus Armbruster
2022-12-14 16:46 ` [PULL 12/14] cleanup: Tweak and re-run return_directly.cocci Markus Armbruster
2022-12-14 16:46 ` [PULL 13/14] block/vmdk: Simplify vmdk_co_create() to return directly Markus Armbruster
2022-12-14 16:46 ` [PULL 14/14] ppc4xx_sdram: Simplify sdram_ddr_size() to return Markus Armbruster
2022-12-15 13:06 ` [PULL 00/14] Miscellaneous patches for 2022-12-14 Peter Maydell
2022-12-15 13:10 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221214164629.919880-11-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).