All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Check for space after "else" keyword
@ 2018-08-02 21:20 Michal Zylowski
  2018-08-04  1:38 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Zylowski @ 2018-08-02 21:20 UTC (permalink / raw)
  To: joe, apw; +Cc: michal.zylowski, linux-kernel

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@intel.com>
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e16d671..2e3f41e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4479,6 +4479,7 @@ sub process {
 
 #need space before brace following if, while, etc
 		if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
+		    $line =~ /else\{/ ||
 		    $line =~ /do\{/) {
 			if (ERROR("SPACING",
 				  "space required before the open brace '{'\n" . $herecurr) &&
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] checkpatch: Check for space after "else" keyword
  2018-08-02 21:20 [PATCH] checkpatch: Check for space after "else" keyword Michal Zylowski
@ 2018-08-04  1:38 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2018-08-04  1:38 UTC (permalink / raw)
  To: Michal Zylowski, apw, Andrew Morton; +Cc: linux-kernel

On Thu, 2018-08-02 at 23:20 +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@intel.com>

Acked-by: Joe Perches <joe@perches.com

though it might be better if the do and else
was written on a single line like:

	$line =~ /\b(?:else|do)\{/

> ---
>  scripts/checkpatch.pl | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index e16d671..2e3f41e 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -4479,6 +4479,7 @@ sub process {
>  
>  #need space before brace following if, while, etc
>  		if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
> +		    $line =~ /else\{/ ||
>  		    $line =~ /do\{/) {
>  			if (ERROR("SPACING",
>  				  "space required before the open brace '{'\n" . $herecurr) &&

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-04  1:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-02 21:20 [PATCH] checkpatch: Check for space after "else" keyword Michal Zylowski
2018-08-04  1:38 ` Joe Perches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.