aboutsummaryrefslogtreecommitdiff
path: root/block
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 /block
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 'block')
-rw-r--r--block/blkdebug.c3
-rw-r--r--block/nbd.c3
-rw-r--r--block/sheepdog.c3
-rw-r--r--block/throttle-groups.c6
4 files changed, 5 insertions, 10 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index d473dcf8c7..3c0a9d45cc 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -375,8 +375,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) {
+ if (!visit_type_BlockPermissionList(v, NULL, &perm_list, &local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
diff --git a/block/nbd.c b/block/nbd.c
index 1b30d96a4f..1331307ffb 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1739,8 +1739,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
goto done;
}
- visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
- if (local_err) {
+ if (!visit_type_SocketAddress(iv, NULL, &saddr, &local_err)) {
error_propagate(errp, local_err);
goto done;
}
diff --git a/block/sheepdog.c b/block/sheepdog.c
index a8d396dcdf..e3bcb05f60 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -541,8 +541,7 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp)
goto done;
}
- visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
- if (local_err) {
+ if (!visit_type_SocketAddress(iv, NULL, &saddr, &local_err)) {
error_propagate(errp, local_err);
goto done;
}
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index 784fa4a16c..bb242fde1a 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -823,8 +823,7 @@ static void throttle_group_set(Object *obj, Visitor *v, const char * name,
goto ret;
}
- visit_type_int64(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_int64(v, name, &value, &local_err)) {
goto ret;
}
if (value < 0) {
@@ -896,8 +895,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);