[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/2] CODING_STYLE: Forbid nested block in the hypervisor code



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@xxxxxxx>

---
    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@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.