From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
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 <julien.grall@arm.com>,
jbeulich@suse.com
Subject: [PATCH 2/2] CODING_STYLE: Forbid nested block in the hypervisor code
Date: Tue, 4 Jul 2017 13:12:14 +0100 [thread overview]
Message-ID: <20170704121214.32145-2-julien.grall@arm.com> (raw)
In-Reply-To: <20170704121214.32145-1-julien.grall@arm.com>
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 <julien.grall@arm.com>
---
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
--------
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-07-04 12:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-04 12:12 [PATCH 1/2] CODING_STYLE: removing trailing whitespaces Julien Grall
2017-07-04 12:12 ` Julien Grall [this message]
2017-07-04 12:20 ` [PATCH 2/2] CODING_STYLE: Forbid nested block in the hypervisor code Jan Beulich
2017-07-04 14:17 ` Andrew Cooper
2017-07-04 17:16 ` Julien Grall
2017-07-04 14:13 ` [PATCH 1/2] CODING_STYLE: removing trailing whitespaces Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170704121214.32145-2-julien.grall@arm.com \
--to=julien.grall@arm.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).