lkml.org 
[lkml]   [2015]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] checkpatch.pl: Add warning for harmful goto labels
From
On Sat, Mar 21, 2015 at 10:16 PM, L. Alberto Giménez
<agimenez@sysvalve.es> wrote:
> Issue a warning for too broad goto labels that may make the code to
> follow the wrong exit path, thus causing hard to debug bugs.
>
> Signed-off-by: L. Alberto Giménez <agimenez@sysvalve.es>
> ---
> scripts/checkpatch.pl | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d124359..e8ce220 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -444,6 +444,11 @@ our $allowed_asm_includes = qr{(?x:
> )};
> # memory.h: ARM has a custom one
>
> +our @goto_harmful_labels = qw(
> + out
> + fail
> + );
> +
> # Load common spelling mistakes and build regular expression list.
> my $misspellings;
> my %spelling_fix;
> @@ -2702,6 +2707,14 @@ sub process {
> }
> }
>
> + if ($sline =~ /goto (.*);/) {
> + my $label = $1;
> + if (grep { /^$label$/ } @goto_harmful_labels) {
> + WARN("HARMFUL_GOTO_LABEL",
> + "Goto label '$label' is considered harmful\n" . $herecurr);

Huh? Since when?

rw@azrael:~/linux (for-v4.1/uml_misc $)> git grep -e "goto out;" | wc -l
26667
rw@azrael:~/linux (for-v4.1/uml_misc $)> git grep -e "goto fail;" | wc -l
3733

What is next? Variable name "i" considered harmful?
Can we please stop this nonsense.

--
Thanks,
//richard


\
 
 \ /
  Last update: 2015-03-21 23:01    [W:0.146 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site