diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-07-07 18:05:42 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-07-10 15:17:35 +0200 |
commit | 235e59cf03ed75d0ce96c97343194ed11c146231 (patch) | |
tree | c2de9b6a66355d038fe4ccb4d79de13905101b52 /block | |
parent | c75d7f71918b8497a710f3f2b646567c09db3770 (diff) |
qemu-option: Use returned bool to check for failure
The previous commit enables conversion of
foo(..., &err);
if (err) {
...
}
to
if (!foo(..., &err)) {
...
}
for QemuOpts functions that now return true / false on success /
error. Coccinelle script:
@@
identifier fun = {
opts_do_parse, parse_option_bool, parse_option_number,
parse_option_size, qemu_opt_parse, qemu_opt_rename, qemu_opt_set,
qemu_opt_set_bool, qemu_opt_set_number, qemu_opts_absorb_qdict,
qemu_opts_do_parse, qemu_opts_from_qdict_entry, qemu_opts_set,
qemu_opts_validate
};
expression list args, args2;
typedef Error;
Error *err;
@@
- fun(args, &err, args2);
- if (err)
+ if (!fun(args, &err, args2))
{
...
}
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-15-armbru@redhat.com>
[Conflict with commit 0b6786a9c1 "block/amend: refactor qcow2 amend
options" resolved by rerunning Coccinelle on master's version]
Diffstat (limited to 'block')
-rw-r--r-- | block/blkdebug.c | 3 | ||||
-rw-r--r-- | block/blklogwrites.c | 3 | ||||
-rw-r--r-- | block/blkverify.c | 3 | ||||
-rw-r--r-- | block/crypto.c | 3 | ||||
-rw-r--r-- | block/curl.c | 3 | ||||
-rw-r--r-- | block/file-posix.c | 6 | ||||
-rw-r--r-- | block/file-win32.c | 6 | ||||
-rw-r--r-- | block/gluster.c | 15 | ||||
-rw-r--r-- | block/iscsi.c | 3 | ||||
-rw-r--r-- | block/nbd.c | 3 | ||||
-rw-r--r-- | block/parallels.c | 3 | ||||
-rw-r--r-- | block/qcow2.c | 3 | ||||
-rw-r--r-- | block/quorum.c | 3 | ||||
-rw-r--r-- | block/raw-format.c | 3 | ||||
-rw-r--r-- | block/replication.c | 3 | ||||
-rw-r--r-- | block/sheepdog.c | 3 | ||||
-rw-r--r-- | block/ssh.c | 3 | ||||
-rw-r--r-- | block/throttle.c | 3 | ||||
-rw-r--r-- | block/vpc.c | 3 | ||||
-rw-r--r-- | block/vvfat.c | 3 | ||||
-rw-r--r-- | block/vxhs.c | 6 |
21 files changed, 28 insertions, 56 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c index 7194bc7f06..d473dcf8c7 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -472,8 +472,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, uint64_t align; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto out; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 6753bd9a3e..0c93e926b1 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -149,8 +149,7 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, bool log_append; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { ret = -EINVAL; error_propagate(errp, local_err); goto fail; diff --git a/block/blkverify.c b/block/blkverify.c index 2f261de24b..666d626c57 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -116,8 +116,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, int ret; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; diff --git a/block/crypto.c b/block/crypto.c index 2636e959ae..35aa5947d4 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -276,8 +276,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format, bs->file->bs->supported_write_flags; opts = qemu_opts_create(opts_spec, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); goto cleanup; } diff --git a/block/curl.c b/block/curl.c index 6e325901dc..d9552efe52 100644 --- a/block/curl.c +++ b/block/curl.c @@ -695,8 +695,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, qemu_mutex_init(&s->mutex); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); goto out_noclean; } diff --git a/block/file-posix.c b/block/file-posix.c index d86ea57769..36acf7b911 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -490,8 +490,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, OnOffAuto locking; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; @@ -1000,8 +999,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, /* Handle options changes */ opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, state->options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, state->options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto out; diff --git a/block/file-win32.c b/block/file-win32.c index 221aaf713e..5f8015319a 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -338,8 +338,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, s->type = FTYPE_FILE; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; @@ -739,8 +738,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, QemuOpts *opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto done; diff --git a/block/gluster.c b/block/gluster.c index 31233cac69..b68bd32d47 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -523,8 +523,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, /* create opts info from runtime_json_opts list */ opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { goto out; } @@ -555,8 +554,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, /* create opts info from runtime_type_opts list */ opts = qemu_opts_create(&runtime_type_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, backing_options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, backing_options, &local_err)) { goto out; } @@ -586,8 +584,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, if (gsconf->type == SOCKET_ADDRESS_TYPE_INET) { /* create opts info from runtime_inet_opts list */ opts = qemu_opts_create(&runtime_inet_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, backing_options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, backing_options, &local_err)) { goto out; } @@ -635,8 +632,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, } else { /* create opts info from runtime_unix_opts list */ opts = qemu_opts_create(&runtime_unix_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, backing_options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, backing_options, &local_err)) { goto out; } @@ -819,8 +815,7 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options, const char *filename, *logfile; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto out; diff --git a/block/iscsi.c b/block/iscsi.c index 767e3e75fd..d4dfa9914b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1792,8 +1792,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, int i, ret = 0, timeout = 0, lun; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto out; diff --git a/block/nbd.c b/block/nbd.c index eed160c5cd..1b30d96a4f 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1840,8 +1840,7 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options, int ret = -EINVAL; opts = qemu_opts_create(&nbd_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); goto error; } diff --git a/block/parallels.c b/block/parallels.c index f26f03c926..32d0ecd398 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -829,8 +829,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, goto fail_options; } - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err != NULL) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { goto fail_options; } diff --git a/block/qcow2.c b/block/qcow2.c index 38198b4e75..ce6333fd1e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -990,8 +990,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, encryptfmt = qdict_get_try_str(encryptopts, "format"); opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; diff --git a/block/quorum.c b/block/quorum.c index 7cf7ab1546..beb3b6dbcc 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -922,8 +922,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, } opts = qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { ret = -EINVAL; goto exit; } diff --git a/block/raw-format.c b/block/raw-format.c index 233d019ca3..a66fbe77c7 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -79,8 +79,7 @@ static int raw_read_options(QDict *options, uint64_t *offset, bool *has_size, int ret; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto end; diff --git a/block/replication.c b/block/replication.c index ccf7b78160..5701eeb9e8 100644 --- a/block/replication.c +++ b/block/replication.c @@ -99,8 +99,7 @@ static int replication_open(BlockDriverState *bs, QDict *options, ret = -EINVAL; opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { goto fail; } diff --git a/block/sheepdog.c b/block/sheepdog.c index 27a30d17f4..a8d396dcdf 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1556,8 +1556,7 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags, s->aio_context = bdrv_get_aio_context(bs); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto err_no_fd; diff --git a/block/ssh.c b/block/ssh.c index 098dbe03c1..13a2964621 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -622,8 +622,7 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp) /* Translate legacy options */ opts = qemu_opts_create(&ssh_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); goto fail; } diff --git a/block/throttle.c b/block/throttle.c index 0ebbad0743..c0802addbb 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -49,8 +49,7 @@ static int throttle_parse_options(QDict *options, char **group, Error **errp) Error *local_err = NULL; QemuOpts *opts = qemu_opts_create(&throttle_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fin; diff --git a/block/vpc.c b/block/vpc.c index 01fcd37e3c..119350d495 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -235,8 +235,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, } opts = qemu_opts_create(&vpc_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; diff --git a/block/vvfat.c b/block/vvfat.c index 2eb8cbb19f..e3e27e0d6c 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1149,8 +1149,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, #endif opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; diff --git a/block/vxhs.c b/block/vxhs.c index d79fc97df6..237df4f185 100644 --- a/block/vxhs.c +++ b/block/vxhs.c @@ -318,8 +318,7 @@ static int vxhs_open(BlockDriverState *bs, QDict *options, opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + if (!qemu_opts_absorb_qdict(opts, options, &local_err)) { ret = -EINVAL; goto out; } @@ -346,8 +345,7 @@ static int vxhs_open(BlockDriverState *bs, QDict *options, /* get the 'server.' arguments */ qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER"."); - qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err); - if (local_err != NULL) { + if (!qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err)) { ret = -EINVAL; goto out; } |