浏览代码

Documentation/CodingStyle: Add an example for braces

Add another example of required braces when using a compound statement in
a loop.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Gary R Hook 7 年之前
父节点
当前提交
1dbba2cf30
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      Documentation/process/coding-style.rst

+ 9 - 0
Documentation/process/coding-style.rst

@@ -200,6 +200,15 @@ statement; in the latter case use braces in both branches:
 		otherwise();
 		otherwise();
 	}
 	}
 
 
+Also, use braces when a loop contains more than a single simple statement:
+
+.. code-block:: c
+
+	while (condition) {
+		if (test)
+			do_something();
+	}
+
 3.1) Spaces
 3.1) Spaces
 ***********
 ***********