From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZcqU-0001BR-3J for qemu-devel@nongnu.org; Wed, 09 Sep 2015 06:43:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZcqR-000484-ED for qemu-devel@nongnu.org; Wed, 09 Sep 2015 06:43:18 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:38017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZcqR-00047X-91 for qemu-devel@nongnu.org; Wed, 09 Sep 2015 06:43:15 -0400 Received: by wiclk2 with SMTP id lk2so16600010wic.1 for ; Wed, 09 Sep 2015 03:43:14 -0700 (PDT) References: <1441619584-17992-1-git-send-email-pbonzini@redhat.com> <1441619584-17992-2-git-send-email-pbonzini@redhat.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1441619584-17992-2-git-send-email-pbonzini@redhat.com> Date: Wed, 09 Sep 2015 11:43:13 +0100 Message-ID: <874mj3an5q.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/4] CODING_STYLE: update mixed declaration rules List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Markus Armbruster , qemu-devel@nongnu.org, Eduardo Habkost , Andreas Faerber Paolo Bonzini writes: > Mixed declarations also do exist at the top of #ifdef blocks. > Reluctantly allow this particular usage and suggest an alternative. > > Signed-off-by: Paolo Bonzini > --- > CODING_STYLE | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/CODING_STYLE b/CODING_STYLE > index d46cfa5..3c6978f 100644 > --- a/CODING_STYLE > +++ b/CODING_STYLE > @@ -87,10 +87,15 @@ Furthermore, it is the QEMU coding style. > > 5. Declarations > > -Mixed declarations (interleaving statements and declarations within blocks) > -are not allowed; declarations should be at the beginning of blocks. In other > -words, the code should not generate warnings if using GCC's > --Wdeclaration-after-statement option. > +Mixed declarations (interleaving statements and declarations within > +blocks) are generally not allowed; declarations should be at the beginning > +of blocks. > + > +Every now and then, an exception is made for declarations inside a > +#ifdef or #ifndef block: if the code looks nicer, such declarations can > +be placed at the top of the block even if there are statements above. > +On the other hand, however, it's often best to move that #ifdef/#ifndef > +block to a separate function altogether. > > 6. Conditional statements Reviewed-by: Alex Bennée -- Alex Bennée