Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1729936 > unrolled thread

[PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break

Started byHeinrich Schuchardt <xypron.glpk@gmx.de>
First post2017-09-10 10:00 +0200
Last post2017-09-10 20:00 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break Heinrich Schuchardt <xypron.glpk@gmx.de> - 2017-09-10 10:00 +0200
    Re: [PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing  break Joe Perches <joe@perches.com> - 2017-09-10 16:20 +0200
      [PATCH v2 1/1] scripts/checkpatch.pl: avoid false warning missing break Heinrich Schuchardt <xypron.glpk@gmx.de> - 2017-09-10 17:50 +0200
        Re: [PATCH v2 1/1] scripts/checkpatch.pl: avoid false warning  missing break Joe Perches <joe@perches.com> - 2017-09-10 20:00 +0200

#1729936 — [PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break

FromHeinrich Schuchardt <xypron.glpk@gmx.de>
Date2017-09-10 10:00 +0200
Subject[PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break
Message-ID<uo5jP-Cc-5@gated-at.bofh.it>
void foo(int a)
	switch (a) {
	case 'h':
		fun1();
		exit(1);
	default:
}

creates a warning
Possible switch case/default not preceded by break
or fallthrough comment

exit( should be treated like return.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3afc870f0f..da09b2313c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4361,7 +4361,7 @@ sub process {
 				next if ($fline =~ /^.[\s$;]*$/);
 				$has_statement = 1;
 				$count++;
-				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/);
+				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\(\b|return\b|goto\b|continue\b)/);
 			}
 			if (!$has_break && $has_statement) {
 				WARN("MISSING_BREAK",
-- 
2.11.0

[toc] | [next] | [standalone]


#1729982 — Re: [PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break

FromJoe Perches <joe@perches.com>
Date2017-09-10 16:20 +0200
SubjectRe: [PATCH 1/1] scripts/checkpatch.pl: avoid false warning missing break
Message-ID<uobfz-4Wz-1@gated-at.bofh.it>
In reply to#1729936
On Sun, 2017-09-10 at 09:52 +0200, Heinrich Schuchardt wrote:
> void foo(int a)
> 	switch (a) {
> 	case 'h':
> 		fun1();
> 		exit(1);
> 	default:
> }
> 
> creates a warning
> Possible switch case/default not preceded by break
> or fallthrough comment
> 
> exit( should be treated like return.

OK, but

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -4361,7 +4361,7 @@ sub process {
>  				next if ($fline =~ /^.[\s$;]*$/);
>  				$has_statement = 1;
>  				$count++;
> -				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/);
> +				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\(\b|return\b|goto\b|continue\b)/);

exit\s*\(

Although this could have a false negative
on some code.

[toc] | [prev] | [next] | [standalone]


#1730002 — [PATCH v2 1/1] scripts/checkpatch.pl: avoid false warning missing break

FromHeinrich Schuchardt <xypron.glpk@gmx.de>
Date2017-09-10 17:50 +0200
Subject[PATCH v2 1/1] scripts/checkpatch.pl: avoid false warning missing break
Message-ID<uocEI-5Qp-67@gated-at.bofh.it>
In reply to#1729982
void foo(int a)
	switch (a) {
	case 'h':
		fun1();
		exit(1);
	default:
}

creates a warning
Possible switch case/default not preceded by break
or fallthrough comment

exit( should be treated like return.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2:
	Allow whitespace between 'exit' and '('.
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2287a0bca8..690fe07d1b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6084,7 +6084,7 @@ sub process {
 				next if ($fline =~ /^.[\s$;]*$/);
 				$has_statement = 1;
 				$count++;
-				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/);
+				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\s*\(\b|return\b|goto\b|continue\b)/);
 			}
 			if (!$has_break && $has_statement) {
 				WARN("MISSING_BREAK",
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1730027 — Re: [PATCH v2 1/1] scripts/checkpatch.pl: avoid false warning missing break

FromJoe Perches <joe@perches.com>
Date2017-09-10 20:00 +0200
SubjectRe: [PATCH v2 1/1] scripts/checkpatch.pl: avoid false warning missing break
Message-ID<uoeGt-7gG-3@gated-at.bofh.it>
In reply to#1730002
On Sun, 2017-09-10 at 17:46 +0200, Heinrich Schuchardt wrote:
> void foo(int a)
> 	switch (a) {
> 	case 'h':
> 		fun1();
> 		exit(1);
> 	default:
> }
> 
> creates a warning
> Possible switch case/default not preceded by break
> or fallthrough comment
> 
> exit( should be treated like return.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

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

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -6084,7 +6084,7 @@ sub process {
>  				next if ($fline =~ /^.[\s$;]*$/);
>  				$has_statement = 1;
>  				$count++;
> -				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/);
> +				$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\s*\(\b|return\b|goto\b|continue\b)/);
>  			}
>  			if (!$has_break && $has_statement) {
>  				WARN("MISSING_BREAK",

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web