All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: pbonzini@redhat.com, lcapitulino@redhat.com,
	mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org
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	[thread overview]
Message-ID: <87mwdizkej.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <20140610055635.GD2614@z.redhat.com> (Amos Kong's message of "Tue, 10 Jun 2014 13:56:35 +0800")

Amos Kong <akong@redhat.com> writes:

> On Mon, Jun 02, 2014 at 05:43:58PM +0200, Markus Armbruster wrote:
>> Amos Kong <akong@redhat.com> 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 <akong@redhat.com>
>> > ---
>> >  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 :)

[...]

      reply	other threads:[~2014-06-12  6:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 12:41 [Qemu-devel] [PATCH v5 0/3] qapi: fix coding style in generated code Amos Kong
2014-05-22 12:41 ` [Qemu-devel] [PATCH v5 1/3] qapi: fix coding style in parameters list Amos Kong
2014-06-02 15:45   ` Markus Armbruster
2014-05-22 12:41 ` [Qemu-devel] [PATCH v5 2/3] qapi: add const prefix to 'char *' insider c_type() Amos Kong
2014-05-22 12:41 ` [Qemu-devel] [PATCH v5 3/3] qapi: Suppress unwanted space between type and identifier Amos Kong
2014-05-22 16:49   ` Eric Blake
2014-06-02 15:43   ` Markus Armbruster
2014-06-09 19:09     ` Luiz Capitulino
2014-06-10  5:56     ` Amos Kong
2014-06-12  6:55       ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mwdizkej.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=akong@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.