lkml.org 
[lkml]   [2019]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 01/12] checkpatch: Add GENMASK tests
Date
This macro is easy to misuse as it's odd argument order.

If specified with simple decimal values, make sure the arguments are
ordered high then low.

Also check if any argument is > 32 where instead of GENMASK,
GENMASK_ULL should be used.

Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6cb99ec62000..d37bbe33524b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6368,6 +6368,21 @@ sub process {
"switch default: should use break\n" . $herectx);
}

+# check for misuses of GENMASK
+ if ($line =~ /\b(GENMASK(?:_ULL)?)\s*\(\s*(\d+)\s*,\s*(\d+)\s*\)/) {
+ my $type = $1;
+ my $high = $2;
+ my $low = $3;
+ if ($high < $low) {
+ ERROR("GENMASK",
+ "$type argument order is high then low\n" . $herecurr);
+ }
+ if ($type eq "GENMASK" && ($high >= 32 || $low >= 32)) {
+ ERROR("GENMASK",
+ "$type with arguments >= 32 should use GENMASK_ULL\n" . $herecurr);
+ }
+ }
+
# check for gcc specific __FUNCTION__
if ($line =~ /\b__FUNCTION__\b/) {
if (WARN("USE_FUNC",
--
2.15.0
\
 
 \ /
  Last update: 2019-07-10 07:06    [W:0.131 / U:5.988 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site