[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191011015225.GA27495@jagdpanzerIV>
Date: Fri, 11 Oct 2019 10:52:25 +0900
From: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To: Joe Perches <joe@...ches.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
linux-kernel@...r.kernel.org
Subject: checkpatch: comparisons with a constant on the left
Hi Joe,
I noticed that this code
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
triggers checkpatch's warning:
"WARNING: Comparisons should place the constant on
the right side of the test"
Both LINUX_VERSION_CODE and KERNEL_VERSION are constants, so
I'm wondering if it's worth it to improve that check a tiny
bit.
E.g. something utterly trivial:
---
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index cf7543a9d1b2..8a1964c3d9a5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4855,6 +4855,7 @@ sub process {
my $to = $4;
my $newcomp = $comp;
if ($lead !~ /(?:$Operators|\.)\s*$/ &&
+ $to !~ /^KERNEL_VERSION.*/ &&
$to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
WARN("CONSTANT_COMPARISON",
"Comparisons should place the constant on the right side of the test\n" . $herecurr) &&
---
I'm sure you'll have a better idea.
-ss
Powered by blists - more mailing lists