* [merged mm-nonmm-stable] checkpatch-fix-incorrect-camelcase-detection-on-numeric-constant.patch removed from -mm tree
@ 2022-06-17 2:59 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2022-06-17 2:59 UTC (permalink / raw)
To: mm-commits, lukas.bulwahn, joe, dwaipayanray1, apw,
borneo.antonio, akpm
The quilt patch titled
Subject: checkpatch: fix incorrect camelcase detection on numeric constant
has been removed from the -mm tree. Its filename was
checkpatch-fix-incorrect-camelcase-detection-on-numeric-constant.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Antonio Borneo <borneo.antonio@gmail.com>
Subject: checkpatch: fix incorrect camelcase detection on numeric constant
Date: Mon, 13 Jun 2022 12:00:55 +0200
The code fragment below
int foo(int *array, int index)
{
return array[index & 0xFF];
}
triggers an incorrect camelcase detection by checking a substring of the
hex constant:
CHECK: Avoid CamelCase: <xFF>
#3: FILE: test.c:3:
+ return array[index & 0xFF];
This is caused by passing the whole string "array[index & 0xFF]" to the
inner loop that iterates over a "$Ident" match. The numeric constant is
not a $Ident as it doesn't start with [A-Za-z_] and should be excluded
from the match.
Similar issue can be detected with other constants like "1uL", "0xffffU".
Force the match to start at word boundary so the $Ident will be properly
checked starting from its first char and the constants will be
filtered-out.
Link: https://lkml.kernel.org/r/20220613100055.77821-1-borneo.antonio@gmail.com
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/scripts/checkpatch.pl~checkpatch-fix-incorrect-camelcase-detection-on-numeric-constant
+++ a/scripts/checkpatch.pl
@@ -5721,7 +5721,7 @@ sub process {
$var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
#Ignore some three character SI units explicitly, like MiB and KHz
$var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
- while ($var =~ m{($Ident)}g) {
+ while ($var =~ m{\b($Ident)}g) {
my $word = $1;
next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
if ($check) {
_
Patches currently in -mm which might be from borneo.antonio@gmail.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-17 2:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-17 2:59 [merged mm-nonmm-stable] checkpatch-fix-incorrect-camelcase-detection-on-numeric-constant.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.