From patchwork Mon Sep 7 09:53:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 515050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E00DD1401CD for ; Mon, 7 Sep 2015 19:53:46 +1000 (AEST) Received: from localhost ([::1]:55214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYt7R-0008D8-14 for incoming@patchwork.ozlabs.org; Mon, 07 Sep 2015 05:53:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYt6y-0007UF-7I for qemu-devel@nongnu.org; Mon, 07 Sep 2015 05:53:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYt6x-0006Ji-By for qemu-devel@nongnu.org; Mon, 07 Sep 2015 05:53:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYt6x-0006Je-6I for qemu-devel@nongnu.org; Mon, 07 Sep 2015 05:53:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C33DA80091; Mon, 7 Sep 2015 09:53:14 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t879r5qQ013436; Mon, 7 Sep 2015 05:53:12 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 7 Sep 2015 11:53:01 +0200 Message-Id: <1441619584-17992-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1441619584-17992-1-git-send-email-pbonzini@redhat.com> References: <1441619584-17992-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Andreas Faerber , Eduardo Habkost , Markus Armbruster Subject: [Qemu-devel] [PATCH 1/4] CODING_STYLE: update mixed declaration rules X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Stefan Hajnoczi Reviewed-by: Alex Bennée --- 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