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: 106961 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp929228qge; Tue, 4 Jul 2017 05:14:35 -0700 (PDT) X-Received: by 10.36.248.4 with SMTP id a4mr35623250ith.69.1499170475867; Tue, 04 Jul 2017 05:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499170475; cv=none; d=google.com; s=arc-20160816; b=HVdafFkfQqXTvmC6gcRpqsQkmUjPPdMd3aB7rOAYbEpjEdArK7RLIf9yOdZ4wRjfaq c7LEqZZ1bLCRXAUOxF0utsrOQ7LJ/tfwF8Rt/ATD2WCCTdzKr7EEPMPCS/zz+OQqg0w1 R5BpbpvjxIb6i7SdG/vwIGsMIDd2UApjS/gqHs9nZ+UxJPIP5OLUOOFoBxPQNSiiqbwx MyqelLGs0Q8Yqe3LsBW4wbqGbHcxzMZ6yY0ULJSG66GixO1Oet6/okmuF3Q67GG7Ok/y l2/jKknCOCK45clOB+W7htA0gW+SFTF4zbGXMuWzGXG7k2/nVZy6GOVOSuSIwEizrFaO +M7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=QsYkMSqaBa9gSmeEXeO8mWNA2BVpvlMANYnl7OUubuE=; b=JuZMWGcZ3GxQGsVn5HqmruQxUgd4d7k3uw0oeQfFgAjliEGxNxd5bLTXQLMOJx3IrM rTQB2x3a1TEtE7DANIPpfSMjupXF4eH2pv2V5S7IChjA/a6In7HS9lmJcByV2bbB6qOn N+vANfvTSKhkxqVHPjY+hJPsLmcTliJ/cQEDde6AD/Fs6ju0fxaiOD80GMWKxMgZI3vT vkHHZE0knXyhfyVJJz//LoX14lqwUQPJBR3cqMq1yrPBWNuairY2mYlT9vMgmg/HluL5 kFKkEVFpQN6oCw53zj7yqHPxmPr1cpXpCHhKq/7qrzL7fPdHL/iphxhH+9a/3hlafzqN DSHw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p136si702797ioe.254.2017.07.04.05.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 05:14:35 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org 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" 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 --------