* [patch] Documentation: allow multiple return statements per function
@ 2013-05-15 17:20 Dan Carpenter
2013-05-15 23:00 ` Rob Landley
2013-05-16 14:52 ` Eduardo Valentin
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-05-15 17:20 UTC (permalink / raw)
To: Rob Landley; +Cc: linux-doc, linux-kernel, Andrew Morton, Eduardo Valentin
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 <dan.carpenter@oracle.com>
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index e00b8f0..7fe0546 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -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:
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] Documentation: allow multiple return statements per function
2013-05-15 17:20 [patch] Documentation: allow multiple return statements per function Dan Carpenter
@ 2013-05-15 23:00 ` Rob Landley
2013-05-16 14:52 ` Eduardo Valentin
1 sibling, 0 replies; 3+ messages in thread
From: Rob Landley @ 2013-05-15 23:00 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-doc, linux-kernel, Andrew Morton, Eduardo Valentin
On 05/15/2013 12:20:21 PM, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
Ack, please forward to trivial tree.
Rob
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Documentation: allow multiple return statements per function
2013-05-15 17:20 [patch] Documentation: allow multiple return statements per function Dan Carpenter
2013-05-15 23:00 ` Rob Landley
@ 2013-05-16 14:52 ` Eduardo Valentin
1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Valentin @ 2013-05-16 14:52 UTC (permalink / raw)
To: Dan Carpenter
Cc: Rob Landley, linux-doc, linux-kernel, Andrew Morton,
Eduardo Valentin
[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]
On 15-05-2013 13:20, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
>
> diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
> index e00b8f0..7fe0546 100644
> --- a/Documentation/CodingStyle
> +++ b/Documentation/CodingStyle
> @@ -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.
Agreed with this rephrasing.
>
> The rationale is:
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 295 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-16 21:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-15 17:20 [patch] Documentation: allow multiple return statements per function Dan Carpenter
2013-05-15 23:00 ` Rob Landley
2013-05-16 14:52 ` Eduardo Valentin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox