Commit 38829dc9 authored by Harry Wei's avatar Harry Wei Committed by Linus Torvalds

Documentation/CodingStyle: flesh out if-else examples

There is a missing case for "Chapter 3: Placing Braces and Spaces".  We
often know we should not use braces where a single statement.  The first
case is:

	if (condition)
		action();

Another case is:

	if (condition)
		do_this();
	else
		do_that();

However, I can not find a description of the second case.
Signed-off-by: default avatarHarry Wei <harryxiyou@gmail.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0bc825d2
...@@ -168,6 +168,13 @@ Do not unnecessarily use braces where a single statement will do. ...@@ -168,6 +168,13 @@ Do not unnecessarily use braces where a single statement will do.
if (condition) if (condition)
action(); action();
and
if (condition)
do_this();
else
do_that();
This does not apply if one branch of a conditional statement is a single This does not apply if one branch of a conditional statement is a single
statement. Use braces in both branches. statement. Use braces in both branches.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment