mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Infinite loop in checkpatch.pl
@ 2023-03-03 14:28 Alexander Potapenko
  2023-03-03 16:52 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Potapenko @ 2023-03-03 14:28 UTC (permalink / raw)
  To: apw, Joe Perches, dwaipayanray1, Lukas Bulwahn; +Cc: LKML

[-- Attachment #1: Type: text/plain, Size: 1706 bytes --]

Hi folks,

I've noticed that checkpatch.pl chokes on the following file (also attached):

==================================
$ cat test-checkpatch.txt
diff --git a/mm/kmsan/kmsan_test.c b/mm/kmsan/kmsan_test.c
@@ -504,6 +504,25 @@ static void
test_memcpy_aligned_to_unaligned2(struct kunit *test)
+ EXPECTATION_NO_REPORT(expect);                              \
+ volatile uint##size##_t uninit;                             \
==================================


, getting into an infinite loop in annotate_values().
The following patch helps it to proceed:

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 78cc595b98ce1..01d998b416a51 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2240,8 +2240,13 @@ sub annotate_values {
                        print "C($1)\n" if ($dbg_values > 1);
                }
                if (defined $1) {
-                       $cur = substr($cur, length($1));
-                       $res .= $type x length($1);
+                       if (length($1)) {
+                               $cur = substr($cur, length($1));
+                               $res .= $type x length($1);
+                       } else {
+                               $res .= $cur;
+                               $cur = "";
+                       }
                }
        }

, but I have no idea how to test it properly.

Could you please take a look?


Thanks,
Alex

-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

[-- Attachment #2: test-checkpatch.txt --]
[-- Type: text/plain, Size: 276 bytes --]

diff --git a/mm/kmsan/kmsan_test.c b/mm/kmsan/kmsan_test.c
@@ -504,6 +504,25 @@ static void test_memcpy_aligned_to_unaligned2(struct kunit *test)
+		EXPECTATION_NO_REPORT(expect);                              \
+		volatile uint##size##_t uninit;                             \

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-06  0:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 14:28 Infinite loop in checkpatch.pl Alexander Potapenko
2023-03-03 16:52 ` Joe Perches
2023-03-03 20:53   ` Alexander Potapenko
2023-03-06  0:05     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®