Skip to content

Commit

Permalink
coding-style.rst: Avoid comma statements
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
JoePerches authored and Jonathan Corbet committed Feb 4, 2021
1 parent 4ba1d72 commit 26606ce
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Documentation/process/coding-style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,26 @@ something to hide:
if (condition) do_this;
do_something_everytime;
Don't use commas to avoid using braces:

.. code-block:: c
if (condition)
do_this(), do_that();
Always uses braces for multiple statements:

.. code-block:: c
if (condition) {
do_this();
do_that();
}
Don't put multiple assignments on a single line either. Kernel coding style
is super simple. Avoid tricky expressions.


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

Expand Down

0 comments on commit 26606ce

Please sign in to comment.