aboutsummaryrefslogtreecommitdiff
path: root/block/nbd.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:06:03 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:18:08 +0200
commitaf175e85f92c870386ad74f466e29537b79611d3 (patch)
treea2b62ef63640b200b969ff3eb7c0a4c1fd0be013 /block/nbd.c
parent668f62ec621e4e2919fb7d4caa5d805764c5852d (diff)
downloadqemu-af175e85f92c870386ad74f466e29537b79611d3.zip
qemu-af175e85f92c870386ad74f466e29537b79611d3.tar.gz
qemu-af175e85f92c870386ad74f466e29537b79611d3.tar.bz2
error: Eliminate error_propagate() with Coccinelle, part 2
When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. The previous commit did that with a Coccinelle script I consider fairly trustworthy. This commit uses the same script with the matching of return taken out, i.e. we convert if (!foo(..., &err)) { ... error_propagate(errp, err); ... } to if (!foo(..., errp)) { ... ... } This is unsound: @err could still be read between afterwards. I don't know how to express "no read of @err without an intervening write" in Coccinelle. Instead, I manually double-checked for uses of @err. Suboptimal line breaks tweaked manually. qdev_realize() simplified further to placate scripts/checkpatch.pl. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200707160613.848843-36-armbru@redhat.com>
Diffstat (limited to 'block/nbd.c')
-rw-r--r--block/nbd.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/block/nbd.c b/block/nbd.c
index 1331307..6876da0 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,8 +1738,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
goto done;
}
- if (!visit_type_SocketAddress(iv, NULL, &saddr, &local_err)) {
- error_propagate(errp, local_err);
+ if (!visit_type_SocketAddress(iv, NULL, &saddr, errp)) {
goto done;
}
@@ -1835,12 +1833,10 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options,
{
BDRVNBDState *s = bs->opaque;
QemuOpts *opts;
- Error *local_err = NULL;
int ret = -EINVAL;
opts = qemu_opts_create(&nbd_runtime_opts, NULL, 0, &error_abort);
- if (!qemu_opts_absorb_qdict(opts, options, &local_err)) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(opts, options, errp)) {
goto error;
}