summaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-02-13 17:38:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:39 -0500
commitacd9362c248e33187629c950badb834b73e20e41 (patch)
tree906c5686169c07b1849fe49426b72a57c01f26c9 /scripts/checkpatch.pl
parent0d7835fcaa67bb21e5ffd50afaa65c81c53f8856 (diff)
checkpatch: add likely/unlikely comparison misuse test
Add a test for probably likely/unlikely misuses where the comparison is likely misplaced if (likely(foo) > 0) vs if (likely(foo > 0)) Signed-off-by: Joe Perches <joe@perches.com> Cc: Christoph Jaeger <cj@linux.com> Cc: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 786017d4d057..41223c946808 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5239,6 +5239,13 @@ sub process {
5239 "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr); 5239 "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
5240 } 5240 }
5241 5241
5242# likely/unlikely comparisons similar to "(likely(foo) > 0)"
5243 if ($^V && $^V ge 5.10.0 &&
5244 $line =~ /\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) {
5245 WARN("LIKELY_MISUSE",
5246 "Using $1 should generally have parentheses around the comparison\n" . $herecurr);
5247 }
5248
5242# whine mightly about in_atomic 5249# whine mightly about in_atomic
5243 if ($line =~ /\bin_atomic\s*\(/) { 5250 if ($line =~ /\bin_atomic\s*\(/) {
5244 if ($realfile =~ m@^drivers/@) { 5251 if ($realfile =~ m@^drivers/@) {