[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <47a9f8c7819039f10c01ec238622b4a64bd5217f.camel@perches.com>
Date: Mon, 06 Aug 2018 08:09:17 -0700
From: Joe Perches <joe@...ches.com>
To: Michal Zylowski <michal.zylowski@...el.com>, apw@...onical.com,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] checkpatch: Check for space after "else" keyword
On Mon, 2018-08-06 at 10:55 +0200, Michal Zylowski wrote:
> Current checkpatch implementation permits notation like:
> } else{
> in kernel code.
> It looks like oversight and inconsistency in checkpatch rules (e.g.
> instruction like 'do' is tested).
>
> Add regex for checking space after 'else' keyword and trigger error if
> space is not present.
>
> Signed-off-by: Michal Zylowski <michal.zylowski@...el.com>
Acked-by: Joe Perches <joe@...ches.com>
> ---
> scripts/checkpatch.pl | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 447857f..f7e135a 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -4483,11 +4483,11 @@ sub process {
>
> #need space before brace following if, while, etc
> if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
> - $line =~ /do\{/) {
> + $line =~ /\b(?:else|do)\{/) {
> if (ERROR("SPACING",
> "space required before the open brace '{'\n" . $herecurr) &&
> $fix) {
> - $fixed[$fixlinenr] =~ s/^(\+.*(?:do|\)))\{/$1 {/;
> + $fixed[$fixlinenr] =~ s/^(\+.*(?:do|else|\)))\{/$1 {/;
> }
> }
>
Powered by blists - more mailing lists