From patchwork Tue Jul 4 12:12:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9824737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4F5E602F0 for ; Tue, 4 Jul 2017 12:14:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D655827F88 for ; Tue, 4 Jul 2017 12:14:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA93327FB7; Tue, 4 Jul 2017 12:14:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5891927F88 for ; Tue, 4 Jul 2017 12:14:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSMgt-0003e0-On; Tue, 04 Jul 2017 12:12:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSMgr-0003dj-SB for xen-devel@lists.xen.org; Tue, 04 Jul 2017 12:12:25 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 3F/59-20252-9268B595; Tue, 04 Jul 2017 12:12:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTVejLTr S4NIjDYslHxezODB6HN39mymAMYo1My8pvyKBNePH+ZmsBb+4KuZN2M7awPiRo4uRk0NIYDOj ROtz7S5GLiD7NKPEvYbLzCAJNgFNiTufPzGB2CIC0hLXPl9mBCliFnjOKDGpZQYrSEJYwFfi7 +RGFhCbRUBVYu+5A2ANvAKWEneXvgMbJCEgL7Gr7SJYPaeAlcTZK8vZITZbSszd/Yp5AiP3Ak aGVYwaxalFZalFusYGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgR5mAIIdjH/ XBh5ilORgUhLljTWLjhTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwbuvBSgnWJSanlqRlpkDDDWY tAQHj5IIb2EcUJq3uCAxtzgzHSJ1itGYY8Pq9V+YOF5N+P+NSYglLz8vVUqctxtkkgBIaUZpH twgWAxcYpSVEuZlBDpNiKcgtSg3swRV/hWjOAejkjBvFsgUnsy8Erh9r4BOYQI6paEnAuSUkk SElFQDo5CVC3PVtENKr7cLV32JvuchES23O8PimULJ2Xc7mOasiKudf8z9F8fCgzMYZ/glzit SLzO787lTf5eih/7L2353D/Klqi7atKm/w2jGmboDd25IzO530DdhNNulyNF06t4Gj0nTp/Ta T3AJLbqR1cP/L1FFpMfe2SXr58afDa5nWD483pBwTomlOCPRUIu5qDgRABggnQd8AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1499170344!104052225!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54544 invoked from network); 4 Jul 2017 12:12:24 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-27.messagelabs.com with SMTP; 4 Jul 2017 12:12:24 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E9F131596; Tue, 4 Jul 2017 05:12:23 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5A78F3F581; Tue, 4 Jul 2017 05:12:22 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 4 Jul 2017 13:12:14 +0100 Message-Id: <20170704121214.32145-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170704121214.32145-1-julien.grall@arm.com> References: <20170704121214.32145-1-julien.grall@arm.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, Julien Grall , jbeulich@suse.com Subject: [Xen-devel] [PATCH 2/2] CODING_STYLE: Forbid nested block in the hypervisor code X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When removing if/for/while statements, the code should be reworked to remove the { } and the extra indentation. This is improving code maintainability and code readability. Signed-off-by: Julien Grall --- This patch was triggered whilst reviewing a patch [1] on ARM that remove the if statement but keep the braces around. I personally dislike such changes as it make the code less and readable maintenable in the future. Stefano asked to send a patch against CODING_STYLE to apply the rule to all the hypervisor code. I am not entirely sure about the name of those type of block and the wording. I would appreciate any advice here. [1] https://lists.xen.org/archives/html/xen-devel/2017-07/msg00060.html --- CODING_STYLE | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CODING_STYLE b/CODING_STYLE index 6cc5b774cf..d1575a7068 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -88,6 +88,21 @@ Braces should be omitted for blocks with a single statement. e.g., if ( condition ) single_statement(); +Nested blocks +------------- + +Nested blocks should be avoided e.g: + +int a; +{ + int b; + /* Do stuff */ +} +/* Do stuff */ + +More importantly, if a patch requires to remove an if/while/for statements, the +code should be reworked rather than introducing a nested block. + Comments --------