From: Arshad Hussain Date: Mon, 29 Aug 2022 10:51:45 +0000 (+0530) Subject: LU-16123 checkpatch: Suppress false warning X-Git-Tag: 2.15.53~202 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=3201740760d241dee935e4a66935b1bc81ac6380;p=fs%2Flustre-release.git LU-16123 checkpatch: Suppress false warning checkpatch throws a warning if it finds an "UPPERCASE" on the left and side. According to the script/code it is to avoid cases like "foo + BAR < baz". Warnings example: (style) Comparisons should place the constant on \ the right side of the test However for our case which throws a warning as false positive. "#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0) ... "#endif This patch suppresses the warning thrown by above code only. This is not a generic "left hand" upper-case warning suppressor which can be a genuine error. This only handles the case where the left side is LUSTRE_VERSION_CODE upper-case macro. Test-Parameters: trivial Signed-off-by: Arshad Hussain Change-Id: Ic8d8fccae035ba6e2ea28099bea6f163ceb0da0a Reviewed-on: https://review.whamcloud.com/48375 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index b4a20d6..e91aeb3 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -4556,6 +4556,8 @@ sub process { # avoid cases like "foo + BAR < baz" # only fix matches surrounded by parentheses to avoid incorrect # conversions like "FOO < baz() + 5" being "misfixed" to "baz() > FOO + 5" +# Exceptions: +# 01. LUSTRE_VERSION_CODE upper-case constant on left side. if ($^V && $^V ge 5.10.0 && $line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) { my $lead = $1; @@ -4565,6 +4567,7 @@ sub process { my $newcomp = $comp; if ($lead !~ /(?:$Operators|\.)\s*$/ && $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ && + $const !~ /LUSTRE_VERSION_CODE/ && WARN("CONSTANT_COMPARISON", "Comparisons should place the constant on the right side of the test\n" . $herecurr) && $fix) {