Re: [PATCH] checkpatch: Warn on unnecessary void function return statements

From: Joe Perches
Date: Mon Jun 16 2014 - 20:28:28 EST


On Mon, 2014-06-16 at 16:28 -0700, Anish Bhatt wrote:
> This seems to ignore the ability to exit from void
> return functions via a `return;` in case of an error
> or similar. Any attempt to bail out generates warnings
> with checkpathch.pl Perhaps it should check for returns
> only at the end of the function ? If not, is there a
> suggested way to do this ? goto labels can't be directly
> used in place either

The only time checkpatch should bleat any message
is when there is a return; statement indented with
a single tab.

This form should be fine and not generate any
checkpatch warning.

void function(void)
{
...

if (err)
return;

...

}


If you want to use exit labels, I suggest you
use this form:

void function(void)
{

...

if (err)
goto exit;

...

exit:
;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/