Skip to content

Commit 26606ce

Browse files
JoePerchesJonathan Corbet
authored andcommitted
coding-style.rst: Avoid comma statements
Commas are not how statements are terminated. Always use semicolons and braces if necessary. Signed-off-by: Joe Perches <[email protected]> Link: https://lore.kernel.org/r/2a97b738bba335434461a5a918053a49c1fb6af4.1598331148.git.joe@perches.com Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 4ba1d72 commit 26606ce

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Documentation/process/coding-style.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,26 @@ something to hide:
6969
if (condition) do_this;
7070
do_something_everytime;
7171
72+
Don't use commas to avoid using braces:
73+
74+
.. code-block:: c
75+
76+
if (condition)
77+
do_this(), do_that();
78+
79+
Always uses braces for multiple statements:
80+
81+
.. code-block:: c
82+
83+
if (condition) {
84+
do_this();
85+
do_that();
86+
}
87+
7288
Don't put multiple assignments on a single line either. Kernel coding style
7389
is super simple. Avoid tricky expressions.
7490

91+
7592
Outside of comments, documentation and except in Kconfig, spaces are never
7693
used for indentation, and the above example is deliberately broken.
7794

0 commit comments

Comments
 (0)