[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/17] qapi-visit: Move error check into gen_visit_f
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH 13/17] qapi-visit: Move error check into gen_visit_fields_call() |
Date: |
Fri, 19 Feb 2016 17:19:43 -0700 |
When first introduced, neither branch of gen_visit_fields_call()
would output a goto. But now that the implicit struct visit
always ends with a goto, we should do the same for regular
struct visits, so that callers don't have to worry about whether
they are creating two identical goto's in a row.
Generated code gets slightly larger; if desired, we could patch
qapi.py:gen_visit_fields() to have a mode where it skips the
final goto and leave it up to the callers when to use that mode,
but that adds more maintenance burden when the compiler should
be smart enough to not bloat the .o file just because the .c
file got larger.
Signed-off-by: Eric Blake <address@hidden>
---
scripts/qapi-visit.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 3aca6a7..5d861ba 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -55,6 +55,7 @@ def gen_visit_fields_call(typ, direct_name,
implicit_name=None):
visit_type_%(c_type)s_fields(v, %(c_name)s, &err);
''',
c_type=typ.c_name(), c_name=direct_name)
+ ret += gen_err_check()
return ret
@@ -79,7 +80,6 @@ static void visit_type_%(c_name)s_fields(Visitor *v,
%(c_name)s *obj, Error **er
if base:
ret += gen_visit_fields_call(base, '(%s *)obj' % base.c_name())
- ret += gen_err_check()
ret += gen_visit_fields(members, prefix='obj->')
@@ -111,9 +111,9 @@ static void visit_type_%(c_name)s_fields(Visitor *v,
%(c_name)s *obj, Error **er
}
''')
- # 'goto out' produced for base, by gen_visit_fields() for each member,
- # and if variants were present
- if base or members or variants:
+ # 'goto out' produced for non-empty base, by gen_visit_fields() for
+ # each member, and if variants were present
+ if (base and not base.is_empty()) or members or variants:
ret += mcgen('''
out:
--
2.5.0
- [Qemu-devel] [PATCH 06/17] chardev: Drop useless ChardevDummy type, (continued)
- [Qemu-devel] [PATCH 06/17] chardev: Drop useless ChardevDummy type, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 07/17] qapi: Drop useless 'data' member of unions, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 02/17] chardev: Shorten references into ChardevBackend, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 08/17] qapi-visit: Factor out gen_visit_fields_call(), Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 10/17] qapi: Fix command with named empty argument type, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 09/17] qapi: Add type.is_empty() helper, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 15/17] qapi: Use anonymous base in SchemaInfo, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 13/17] qapi-visit: Move error check into gen_visit_fields_call(),
Eric Blake <=
- [Qemu-devel] [PATCH 16/17] qapi: Use anonymous base in CpuInfo, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 01/17] chardev: Properly initialize ChardevCommon components, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 11/17] qapi-visit: Simplify visit of empty branch in union, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 04/17] ui: Shorten references into InputEvent, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 05/17] qapi: Avoid use of 'data' member of qapi unions, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 03/17] util: Shorten references into SocketAddress, Eric Blake, 2016/02/19