From a37254140b0b4964fab97571470140ff6df96323 Mon Sep 17 00:00:00 2001 From: Christopher Friedt Date: Fri, 19 Jan 2024 07:37:33 -0500 Subject: [PATCH] scripts: checkpatch.pl: fix constant comparison false positives Comparisons that have constants on both side of the operator were getting flagged incorrectly. Adjust the check so that pure constant comparisons are not flagged, reducing false positives. WARNING:CONSTANT_COMPARISON: \ Comparisons should place the constant on the right side of \ the test +BUILD_ASSERT(CONFIG_MAX_PTHREAD_COUNT == \ CONFIG_MAX_PTHREAD_MUTEX_COUNT - 1); Signed-off-by: Christopher Friedt --- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 110eed8ec56..b3bfd180cca 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5004,6 +5004,7 @@ sub process { # only fix matches surrounded by parentheses to avoid incorrect # conversions like "FOO < baz() + 5" being "misfixed" to "baz() > FOO + 5" if ($perl_version_ok && + !($line =~ /^\+(.*)($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*(.*)($Constant|[A-Z_][A-Z0-9_]*)(.*)/) && $line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) { my $lead = $1; my $const = $2;