From patchwork Tue Jul 4 12:12:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106960 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp929072qge; Tue, 4 Jul 2017 05:14:29 -0700 (PDT) X-Received: by 10.36.141.6 with SMTP id w6mr14749109itd.23.1499170469646; Tue, 04 Jul 2017 05:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499170469; cv=none; d=google.com; s=arc-20160816; b=k5E42qZ6mxgFDZAadPCUnpJedUCds8XJf4BkLvsFeBs9k/+gK/lTDdYzZJ21oLGLlD 21WPGtg578pvzI42r3vW1ZOCZu9zc5SN1rG3xHHQxBJ/hJlvGRI8Dosbo7H41HkZ8YjI EsKp34t/7l9rPxWgU47GBf40Lbn3hf4mtjtXmmpCXOs7jKr1nvK9kJZP24TH8+710D5O IgNy5zVw2nHmCduo0Ig3yovoRKLb/O8xgZLpHE2RCr3+2RFTav8mMW++SXcCkvv64UA5 BsXCduR//IzarhN55SPln4B4cHvcoJXNDVmQlr8GUM2fptYtxEwqoqhl0QEsvECUu5MS Xi6w== 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:message-id:date:to:from :arc-authentication-results; bh=OBQgUVyCsyZxq2ec5s+79nOI2s0QirG5FphpQvoISXo=; b=QV2r4cbCKuedAx3EqrqYcAdairXneFje/bOEalw4PkYYDvC3nl7vpPk6NWNEV2DViA IL5Y9loa8oec11fgS89VrWLsJHXalfuQgrdQ1xI4vw/LR3SqUTBbepmPsNFodQ6wGjFu s6rlTJFMZZtCT3QIx/KCh55pH8cWdc7dwnOXXZH30XDXWHIX+ShFIfZMQBdzjvIJhs78 Uzr8prWVtlZYhlx0WyJ1DPLIgFlXPZ8Qktm1GZluxUQU0k+a+jxmRUDUrrA52DXcNMdB tx7jTAJR1Nx1HMjtiX7l4+pN75I3Ze5wiosEqVRg+RwYicgeSwndag2ULMZkwOYpRiey Rckg== 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 i41si11671548ioo.203.2017.07.04.05.14.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 05:14:29 -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 1dSMgr-0003dk-Ho; Tue, 04 Jul 2017 12:12:25 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSMgq-0003dd-Hs for xen-devel@lists.xen.org; Tue, 04 Jul 2017 12:12:24 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id E2/3E-03582-7268B595; Tue, 04 Jul 2017 12:12:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRWlGSWpSXmKPExsVysyfVTVe9LTr S4Ggvt8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnFnxQSmgsnsFUt6N7M0MH5k7WLk4hAS2Mgo 8eL1EzYI5zSjxN1jM5m6GDk52AQ0Je58/gRmiwhIS1z7fJkRpIhZ4DmjxKSWGawgCWEBB4k9G 3YxgtgsAqoSF8+3sYPYvAKWElMermYGsSUE5CV2tV1kncDIuYCRYRWjenFqUVlqka6xXlJRZn pGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGoMcYgGAHY8c/p0OMkhxMSqK8sWbRkUJ8Sfk plRmJxRnxRaU5qcWHGGU4OJQkeG1bgXKCRanpqRVpmTnA0IFJS3DwKInwFsYBpXmLCxJzizPT IVKnGI05mj5s+cLE8WrC/29MQix5+XmpUuK8GiCTBEBKM0rz4AbBQvoSo6yUMC8j0GlCPAWpR bmZJajyrxjFORiVhHmjQabwZOaVwO17BXQKE9ApDT0RIKeUJCKkpBoYne89O2Rz83DYjqTCZ4 +FqwLusD7a4TCxUTZ3I0cK890vNtfE1ZOMBH5PuBG/9rnlme6fjiHnTmp6+L+a5bfj3dq9Ds3 CerJS17fumvRn65KWmOcv5gfu//Xyz+0VCW/TV9h/DdbgYvlyz/PhKpvZG/8GHnk/v7IyaMXJ kxXPpbN9H7C6Lr1XUKPEUpyRaKjFXFScCACy3EYJZAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1499170342!71517109!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 9963 invoked from network); 4 Jul 2017 12:12:23 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-21.messagelabs.com with SMTP; 4 Jul 2017 12:12:23 -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 1F6A62B; Tue, 4 Jul 2017 05:12:22 -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 86B273F581; Tue, 4 Jul 2017 05:12:20 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 4 Jul 2017 13:12:13 +0100 Message-Id: <20170704121214.32145-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 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 1/2] CODING_STYLE: removing trailing whitespaces 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" Signed-off-by: Julien Grall --- CODING_STYLE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CODING_STYLE b/CODING_STYLE index 4c3b53a754..6cc5b774cf 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -4,11 +4,11 @@ Coding Style for the Xen Hypervisor The Xen coding style described below is the coding style used by the Xen hypervisor itself (xen/*) as well as various associated low-level libraries (e.g. tools/libxc/*). - + An exception is made for files which are imported from an external source. In these cases the prevailing coding style of the upstream source is generally used (commonly the Linux coding style). - + Other parts of the code base may use other coding styles, sometimes explicitly (e.g. tools/libxl/CODING_STYLE) but often implicitly (Linux coding style is fairly common). In general you should copy the style 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 --------