Skip to content

Commit

Permalink
Documentation/CodingStyle: allow multiple return statements per function
Browse files Browse the repository at this point in the history
A surprising number of newbies interpret this section to mean that only
one return statement is allowed per function.  Part of the problem is that
the "one return statement per function" rule is an actual style guideline
that people are used to from other projects.

Signed-off-by: Dan Carpenter <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Rob Landley <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dan Carpenter authored and torvalds committed Jul 3, 2013
1 parent e68e96d commit b57a050
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Documentation/CodingStyle
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ Albeit deprecated by some people, the equivalent of the goto statement is
used frequently by compilers in form of the unconditional jump instruction.

The goto statement comes in handy when a function exits from multiple
locations and some common work such as cleanup has to be done.
locations and some common work such as cleanup has to be done. If there is no
cleanup needed then just return directly.

The rationale is:

Expand Down

0 comments on commit b57a050

Please sign in to comment.