mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Improve macros with flow control test
@ 2015-11-10 19:06 Joe Perches
  0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2015-11-10 19:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Andy Whitcroft, LKML

The current test excludes any macro with ## concatenation
from being
reported with hidden flow control.

Some macros are used with return or goto statements
along with ##args or ##__VA_ARGS__.  A somewhat common
case is a logging macro like pr_info(fmt, ...) then a
return or goto statement.

Check the concatenated variable for args or __VA_ARGS__
and allow those macros to also be reported when they
contain a return or goto.

Signed-off-by: Joe Perches <joe@perches.com>
---
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b3c228..76e4b33 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4517,7 +4517,7 @@ sub process {
 			#print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
 
 			$has_flow_statement = 1 if ($ctx =~ /\b(goto|return)\b/);
-			$has_arg_concat = 1 if ($ctx =~ /\#\#/);
+			$has_arg_concat = 1 if ($ctx =~ /\#\#/ && $ctx !~ /\#\#\s*(?:__VA_ARGS__|args)\b/);
 
 			$dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//;
 			$dstat =~ s/$;//g;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-10 19:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10 19:06 [PATCH] checkpatch: Improve macros with flow control test Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome