aboutsummaryrefslogtreecommitdiff
path: root/qom/object.c
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 /qom/object.c
parent012d4c96e260f99d5ca95cd033274af4fb73b825 (diff)
downloadqemu-62a35aaa310807fa161ca041ddb0f308faeb582b.zip
qemu-62a35aaa310807fa161ca041ddb0f308faeb582b.tar.gz
qemu-62a35aaa310807fa161ca041ddb0f308faeb582b.tar.bz2
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 'qom/object.c')
-rw-r--r--qom/object.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/qom/object.c b/qom/object.c
index 34daaf1..0213e87 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2094,8 +2094,7 @@ static void property_set_str(Object *obj, Visitor *v, const char *name,
char *value;
Error *local_err = NULL;
- visit_type_str(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_str(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -2175,8 +2174,7 @@ static void property_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;
}
@@ -2248,8 +2246,7 @@ static void property_set_enum(Object *obj, Visitor *v, const char *name,
int value;
Error *err = NULL;
- visit_type_enum(v, name, &value, prop->lookup, &err);
- if (err) {
+ if (!visit_type_enum(v, name, &value, prop->lookup, &err)) {
error_propagate(errp, err);
return;
}
@@ -2319,32 +2316,25 @@ static void property_get_tm(Object *obj, Visitor *v, const char *name,
goto out;
}
- visit_start_struct(v, name, NULL, 0, &err);
- if (err) {
+ if (!visit_start_struct(v, name, NULL, 0, &err)) {
goto out;
}
- visit_type_int32(v, "tm_year", &value.tm_year, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_year", &value.tm_year, &err)) {
goto out_end;
}
- visit_type_int32(v, "tm_mon", &value.tm_mon, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_mon", &value.tm_mon, &err)) {
goto out_end;
}
- visit_type_int32(v, "tm_mday", &value.tm_mday, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_mday", &value.tm_mday, &err)) {
goto out_end;
}
- visit_type_int32(v, "tm_hour", &value.tm_hour, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_hour", &value.tm_hour, &err)) {
goto out_end;
}
- visit_type_int32(v, "tm_min", &value.tm_min, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_min", &value.tm_min, &err)) {
goto out_end;
}
- visit_type_int32(v, "tm_sec", &value.tm_sec, &err);
- if (err) {
+ if (!visit_type_int32(v, "tm_sec", &value.tm_sec, &err)) {
goto out_end;
}
visit_check_struct(v, &err);
@@ -2408,8 +2398,7 @@ static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *name,
uint8_t value;
Error *local_err = NULL;
- 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;
}
@@ -2431,8 +2420,7 @@ static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *name,
uint16_t value;
Error *local_err = NULL;
- visit_type_uint16(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_uint16(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}
@@ -2454,8 +2442,7 @@ static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *name,
uint32_t value;
Error *local_err = NULL;
- 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;
}
@@ -2477,8 +2464,7 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
uint64_t value;
Error *local_err = NULL;
- visit_type_uint64(v, name, &value, &local_err);
- if (local_err) {
+ if (!visit_type_uint64(v, name, &value, &local_err)) {
error_propagate(errp, local_err);
return;
}