diff options
| author | Joe Perches <joe@perches.com> | 2017-05-08 18:55:48 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-08 20:15:11 -0400 |
| commit | e795556a581a849bf33b22521bf8ebc97ab899ea (patch) | |
| tree | 95d899c64140b8046d4dc6ffcec806e77533655d /scripts | |
| parent | d9190e4e1a057ad55027cbefd1d21f6eae93fe0e (diff) | |
checkpatch: improve MULTISTATEMENT_MACRO_USE_DO_WHILE test
The logic currrently misses macros that start with an if statement.
e.g.: #define foo(bar) if (bar) baz;
Add a test for macro content that starts with if
Link: http://lkml.kernel.org/r/a9d41aafe1673889caf1a9850208fb7fd74107a0.1491783914.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Andreas Mohr <andi@lisas.de>
Original-patch-by: Alfonso Lima <alfonsolimaastor@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3a1cb9d7474e..feb9e856f11d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -4849,8 +4849,10 @@ sub process { | |||
| 4849 | $dstat !~ /^\(\{/ && # ({... | 4849 | $dstat !~ /^\(\{/ && # ({... |
| 4850 | $ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/) | 4850 | $ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/) |
| 4851 | { | 4851 | { |
| 4852 | 4852 | if ($dstat =~ /^\s*if\b/) { | |
| 4853 | if ($dstat =~ /;/) { | 4853 | ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", |
| 4854 | "Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects\n" . "$herectx"); | ||
| 4855 | } elsif ($dstat =~ /;/) { | ||
| 4854 | ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", | 4856 | ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", |
| 4855 | "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx"); | 4857 | "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx"); |
| 4856 | } else { | 4858 | } else { |
