OSDN Git Service

Documentation/CodingStyle: Add an example for braces
authorGary R Hook <gary.hook@amd.com>
Wed, 14 Mar 2018 22:21:38 +0000 (17:21 -0500)
committerJonathan Corbet <corbet@lwn.net>
Wed, 21 Mar 2018 15:17:09 +0000 (09:17 -0600)
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>
Documentation/process/coding-style.rst

index a20b44a..d98deb6 100644 (file)
@@ -200,6 +200,15 @@ statement; in the latter case use braces in both branches:
                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
 ***********