Received: from eggs.gnu.org ([2001:4830:134:3::10]:53273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfmA-0006Kx-7c for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:51:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZfm9-0003Uy-9U for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:51:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfm9-0003Ue-4G for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:51:01 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C9A18C0AA279 for ; Wed, 9 Sep 2015 13:51:00 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-83.ams2.redhat.com [10.36.112.83]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89DoEiD030571 for ; Wed, 9 Sep 2015 09:50:59 -0400 From: Paolo Bonzini Date: Wed, 9 Sep 2015 15:49:58 +0200 Message-Id: <1441806613-13775-29-git-send-email-pbonzini@redhat.com> In-Reply-To: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> References: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 28/43] CODING_STYLE: update mixed declaration rules List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Mixed declarations do come in handy at the top of #ifdef blocks. Reluctantly allow this particular usage and suggest an alternative. Reviewed-by: Stefan Hajnoczi 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 -- 2.4.3