Received: from eggs.gnu.org ([2001:4830:134:3::10]:55421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuyvU-00018a-A6 for qemu-devel@nongnu.org; Thu, 12 Jun 2014 02:56:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuyvO-0001Wq-FL for qemu-devel@nongnu.org; Thu, 12 Jun 2014 02:55:56 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:201:233:1::3]:39037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuyvO-0001WP-8s for qemu-devel@nongnu.org; Thu, 12 Jun 2014 02:55:50 -0400 From: Markus Armbruster References: <1400762504-22751-1-git-send-email-akong@redhat.com> <1400762504-22751-4-git-send-email-akong@redhat.com> <87tx832u69.fsf@blackfin.pond.sub.org> <20140610055635.GD2614@z.redhat.com> Date: Thu, 12 Jun 2014 08:55:48 +0200 In-Reply-To: <20140610055635.GD2614@z.redhat.com> (Amos Kong's message of "Tue, 10 Jun 2014 13:56:35 +0800") Message-ID: <87mwdizkej.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v5 3/3] qapi: Suppress unwanted space between type and identifier List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: pbonzini@redhat.com, lcapitulino@redhat.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org Amos Kong writes: > On Mon, Jun 02, 2014 at 05:43:58PM +0200, Markus Armbruster wrote: >> Amos Kong 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 >> > --- >> > 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 :) [...]