Commit 0d14eeb2 authored by Amos Kong's avatar Amos Kong Committed by Luiz Capitulino

qapi: add const prefix to 'char *' insider c_type()

It's ugly to add const prefix for parameter type by an if statement
outside c_type(). This patch adds a parameter to do it.
Signed-off-by: default avatarAmos Kong <>
Suggested-by: default avatarMarkus Armbruster <>
Reviewed-by: default avatarEric Blake <>
Reviewed-by: default avatarPaolo Bonzini <>
Reviewed-by: default avatarMarkus Armbruster <>
Signed-off-by: default avatarLuiz Capitulino <>
parent 638ca8ad
......@@ -29,9 +29,7 @@ def type_visitor(name):
def generate_command_decl(name, args, ret_type):
for argname, argtype, optional, structured in parse_args(args):
argtype = c_type(argtype)
if argtype == "char *":
argtype = "const char *"
argtype = c_type(argtype, is_param=True)
if optional:
arglist += "bool has_%s, " % c_var(argname)
arglist += "%s %s, " % (argtype, c_var(argname))
......@@ -470,8 +470,10 @@ def find_enum(name):
def is_enum(name):
return find_enum(name) != None
def c_type(name):
def c_type(name, is_param=False):
if name == 'str':
if is_param:
return 'const char *'
return 'char *'
elif name == 'int':
return 'int64_t'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment