LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] Documentation/CodingStyle: Add an example for braces
@ 2018-03-15 20:04 Gary R Hook
  2018-03-21 15:17 ` Jonathan Corbet
  0 siblings, 1 reply; 6+ messages in thread
From: Gary R Hook @ 2018-03-15 20:04 UTC (permalink / raw)
  To: linux-doc; +Cc: linux-kernel, corbet

Add another example of required braces when using a compound statements.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---

Changes since v1:
- Move the new example up, and make it more generic

 Documentation/process/coding-style.rst |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
index a20b44a40ec4..fcef0b4b59d0 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -188,6 +188,15 @@ and
 	else
 		do_that();
 
+Do use braces when a body is more complex than a single simple statement:
+
+.. code-block:: c
+
+	if (condition) {
+		if (another_condition)
+			do_something();
+	}
+
 This does not apply if only one branch of a conditional statement is a single
 statement; in the latter case use braces in both branches:
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-26 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15 20:04 [PATCH v2] Documentation/CodingStyle: Add an example for braces Gary R Hook
2018-03-21 15:17 ` Jonathan Corbet
2018-03-22  9:12   ` Jani Nikula
2018-03-26 16:28     ` Gary R Hook
2018-03-26 16:32       ` Jonathan Corbet
2018-03-26 16:49         ` Gary R Hook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).