[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 3/3] qapi: Suppress unwanted space between ty
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v5 3/3] qapi: Suppress unwanted space between type and identifier |
Date: |
Thu, 12 Jun 2014 08:55:48 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Amos Kong <address@hidden> writes:
> On Mon, Jun 02, 2014 at 05:43:58PM +0200, Markus Armbruster wrote:
>> Amos Kong <address@hidden> writes:
>>
>> > We always generate a space between type and identifier in parameter
>> > and variable declarations, even when idiomatic C style doesn't have
>> > a space there. Suppress it.
>> >
>> > Signed-off-by: Amos Kong <address@hidden>
>> > ---
>> > scripts/qapi-commands.py | 2 +-
>> > scripts/qapi.py | 19 +++++++++++++------
>> > 2 files changed, 14 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
>> > index 34f200a..4b49735 100644
>> > --- a/scripts/qapi-commands.py
>> > +++ b/scripts/qapi-commands.py
>> > @@ -102,7 +102,7 @@ def gen_visitor_input_vars_decl(args):
>> > bool has_%(argname)s = false;
>> > ''',
>> > argname=c_var(argname))
>> > - if c_type(argtype).endswith("*"):
>> > + if c_type(argtype).endswith("*" + eatspace):
>> > ret += mcgen('''
>> > %(argtype)s %(argname)s = NULL;
>> > ''',
>>
>> Ugly. A function is_c_ptr(argtype) would be cleaner.
>
> def is_c_ptr(argtype):
> suffix = "*" + eatspace
> return c_type(argtype).endswith(suffix)
Either that, or a suitable conditional matching (relevant parts of)
c_type(). Your choice.
>> There's similar code in gen_marshal_input():
>>
>> if ret_type:
>> if c_type(ret_type).endswith("*"):
>> retval = " %s retval = NULL;" % c_type(ret_type)
>> else:
>> retval = " %s retval;" % c_type(ret_type)
>> ret += mcgen('''
>> %(retval)s
>> ''',
>> retval=retval)
>
> Thanks, I searched by grep in the past, but I still lost one :(
That's why we do reviews :)
[...]