[PATCH 2/3] checkpatch: check indentation on case without space

From: Tiffany Yang

Date: Fri Nov 14 2025 - 18:32:12 EST


The script was not catching switch statement indentation errors when
'case' isn't followed by a space.

For example, checkpatch is silent for this change:

+switch (foo) {
+case(1):
+ break;
+ case(2):
+ break;
+}

But reports an error for the following:

+switch (foo) {
+case 1:
+ break;
+ case 2:
+ break;
+}

ERROR: switch and case should be at the same indent
#39: FILE: kernel/checkpatch_case_fix/test_cases.c:21:
+switch (foo) {
[...]
+ case 2:

Update the check so that the error is reported for both.
Signed-off-by: Tiffany Yang <ynaffit@xxxxxxxxxx>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b026b1235079..f9d14115c416 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4311,7 +4311,7 @@ sub process {
shift(@ctx);
for my $ctx (@ctx) {
my ($clen, $cindent) = line_stats($ctx);
- if ($ctx =~ /^\+\s*(case\s+|default:)/ &&
+ if ($ctx =~ /^\+\s*(case\b\s*|default:)/ &&
$indent != $cindent) {
$err .= "$sep$ctx\n";
$sep = '';
--
2.52.0.rc1.455.g30608eb744-goog