aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi-visit.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-03-01 08:40:37 +0100
committerLuiz Capitulino <lcapitulino@redhat.com>2014-03-03 11:17:20 -0500
commit949ceeb31b84dce43e4619b6d7f02cac0e62e1e1 (patch)
treefbd613c5373975792434e31a02e760f78bd6031d /scripts/qapi-visit.py
parent56bed4135f139721d42992da3924786282bb0286 (diff)
qapi: Clean up null checking in generated visitors
Visitors get passed a pointer to the visited object. The generated visitors try to cope with this pointer being null in some places, for instance like this: visit_start_optional(m, obj ? &(*obj)->has_name : NULL, "name", &err); visit_start_optional() passes its second argument to Visitor method start_optional. Three out of three methods dereference it unconditionally. I fail to see how this pointer could legitimately be null. All this useless null checking is highly redundant, which Coverity duly reports. About 200 times. Remove the useless null checks. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'scripts/qapi-visit.py')
-rw-r--r--scripts/qapi-visit.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 97e9b113d9..c6de9aeed4 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -47,9 +47,9 @@ static void visit_type_%(full_name)s_fields(Visitor *m, %(name)s ** obj, Error *
if base:
ret += mcgen('''
-visit_start_implicit_struct(m, obj ? (void**) &(*obj)->%(c_name)s : NULL, sizeof(%(type)s), &err);
+visit_start_implicit_struct(m, (void**) &(*obj)->%(c_name)s, sizeof(%(type)s), &err);
if (!err) {
- visit_type_%(type)s_fields(m, obj ? &(*obj)->%(c_prefix)s%(c_name)s : NULL, &err);
+ visit_type_%(type)s_fields(m, &(*obj)->%(c_prefix)s%(c_name)s, &err);
error_propagate(errp, err);
err = NULL;
visit_end_implicit_struct(m, &err);
@@ -61,8 +61,8 @@ if (!err) {
for argname, argentry, optional, structured in parse_args(members):
if optional:
ret += mcgen('''
-visit_start_optional(m, obj ? &(*obj)->%(c_prefix)shas_%(c_name)s : NULL, "%(name)s", &err);
-if (obj && (*obj)->%(prefix)shas_%(c_name)s) {
+visit_start_optional(m, &(*obj)->%(c_prefix)shas_%(c_name)s, "%(name)s", &err);
+if ((*obj)->%(prefix)shas_%(c_name)s) {
''',
c_prefix=c_var(field_prefix), prefix=field_prefix,
c_name=c_var(argname), name=argname)
@@ -72,7 +72,7 @@ if (obj && (*obj)->%(prefix)shas_%(c_name)s) {
ret += generate_visit_struct_body(full_name, argname, argentry)
else:
ret += mcgen('''
-visit_type_%(type)s(m, obj ? &(*obj)->%(c_prefix)s%(c_name)s : NULL, "%(name)s", &err);
+visit_type_%(type)s(m, &(*obj)->%(c_prefix)s%(c_name)s, "%(name)s", &err);
''',
c_prefix=c_var(field_prefix), prefix=field_prefix,
type=type_name(argentry), c_name=c_var(argname),
@@ -121,7 +121,7 @@ visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
ret += mcgen('''
if (!err) {
- if (!obj || *obj) {
+ if (*obj) {
visit_type_%(name)s_fields(m, obj, &err);
error_propagate(errp, err);
err = NULL;
@@ -273,7 +273,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
if (!error_is_set(errp)) {
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
if (!err) {
- if (obj && *obj) {
+ if (*obj) {
''',
name=name)