Skip to content

Commit

Permalink
Documentation/CodingStyle: flesh out if-else examples
Browse files Browse the repository at this point in the history
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: Harry Wei <[email protected]>
Cc: Randy Dunlap <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jiaweiwei authored and torvalds committed Mar 23, 2011
1 parent 0bc825d commit 38829dc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Documentation/CodingStyle
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ Do not unnecessarily use braces where a single statement will do.
if (condition)
action();

and

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

This does not apply if one branch of a conditional statement is a single
statement. Use braces in both branches.

Expand Down

0 comments on commit 38829dc

Please sign in to comment.