[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/3] qapi-visit: Clean up code generated around visi
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 2/3] qapi-visit: Clean up code generated around visit_end_union() |
Date: |
Wed, 27 Jan 2016 14:54:47 +0100 |
The generated code can call visit_end_union() without having called
visit_start_union(). Example:
if (!*obj) {
goto out_obj;
}
visit_type_BlockdevOptions_fields(v, obj, &err);
if (err) {
goto out_obj; // if we go from here...
}
if (!visit_start_union(v, !!(*obj)->u.data, &err) || err) {
goto out_obj;
}
switch ((*obj)->driver) {
[...]
}
out_obj:
// ... then *obj is true, and ...
error_propagate(errp, err);
err = NULL;
if (*obj) {
// we end up here
visit_end_union(v, !!(*obj)->u.data, &err);
}
error_propagate(errp, err);
Harmless only because no visitor implements end_union(). Clean it up
anyway.
Messed up since we have visit_end_union (commit cee2ded).
Signed-off-by: Markus Armbruster <address@hidden>
---
scripts/qapi-visit.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 5c0d4d2..8dcc6dc 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -299,12 +299,10 @@ void visit_type_%(c_name)s(Visitor *v, const char *name,
%(c_name)s **obj, Error
default:
abort();
}
-out_obj:
error_propagate(errp, err);
err = NULL;
- if (*obj) {
- visit_end_union(v, !!(*obj)->u.data, &err);
- }
+ visit_end_union(v, !!(*obj)->u.data, &err);
+out_obj:
error_propagate(errp, err);
err = NULL;
visit_end_struct(v, &err);
--
2.4.3
- Re: [Qemu-devel] [PATCH v9 21/37] qapi: Document visitor interfaces, add assertions, (continued)
[Qemu-devel] [PATCH v9 26/37] qapi: Simplify excess input reporting in input visitors, Eric Blake, 2016/01/19
[Qemu-devel] [PATCH 0/3] qapi-visit: Unify struct and union visit, Markus Armbruster, 2016/01/27
[Qemu-devel] [PATCH v9 18/37] qapi: Drop unused error argument for list and implicit struct, Eric Blake, 2016/01/19
[Qemu-devel] [PATCH v9 17/37] qapi: Drop unused 'kind' for struct/enum visit, Eric Blake, 2016/01/19
[Qemu-devel] [PATCH v9 29/37] qapi: Eliminate empty visit_type_FOO_fields, Eric Blake, 2016/01/19