Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <joe@perches.com>
Link: https://lore.kernel.org/r/2a97b738bba335434461a5a918053a49c1fb6af4.1598331148.git.joe@perches.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Joe Perches and committed by
Jonathan Corbet
26606ce0 4ba1d726

+17
+17
Documentation/process/coding-style.rst
··· 69 69 if (condition) do_this; 70 70 do_something_everytime; 71 71 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 + 72 88 Don't put multiple assignments on a single line either. Kernel coding style 73 89 is super simple. Avoid tricky expressions. 90 + 74 91 75 92 Outside of comments, documentation and except in Kconfig, spaces are never 76 93 used for indentation, and the above example is deliberately broken.