mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi: Replace dirty is_c_ptr() by method c_null()
is_c_ptr() looks whether the end of the C text for the type looks like a pointer. Works, but is fragile. We now have a better tool: use QAPISchemaType method c_null(). The initializers for non-pointers become prettier: 0, false or the enumeration constant with the value 0 instead of {0}. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1442401589-24189-13-git-send-email-armbru@redhat.com>
This commit is contained in:
parent
05f43a9608
commit
5710153e73
2 changed files with 5 additions and 14 deletions
|
@ -91,18 +91,12 @@ def gen_visitor_input_vars_decl(args):
|
|||
bool has_%(argname)s = false;
|
||||
''',
|
||||
argname=c_name(memb.name))
|
||||
if is_c_ptr(memb.type.c_type()):
|
||||
ret += mcgen('''
|
||||
%(argtype)s %(argname)s = NULL;
|
||||
ret += mcgen('''
|
||||
%(c_type)s %(c_name)s = %(c_null)s;
|
||||
''',
|
||||
argname=c_name(memb.name),
|
||||
argtype=memb.type.c_type())
|
||||
else:
|
||||
ret += mcgen('''
|
||||
%(argtype)s %(argname)s = {0};
|
||||
''',
|
||||
argname=c_name(memb.name),
|
||||
argtype=memb.type.c_type())
|
||||
c_name=c_name(memb.name),
|
||||
c_type=memb.type.c_type(),
|
||||
c_null=memb.type.c_null())
|
||||
|
||||
pop_indent()
|
||||
return ret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue