lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251114233150.396974-5-ynaffit@google.com>
Date: Fri, 14 Nov 2025 15:31:52 -0800
From: Tiffany Yang <ynaffit@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: kernel-team@...roid.com, Andy Whitcroft <apw@...onical.com>, 
	Joe Perches <joe@...ches.com>, Dwaipayan Ray <dwaipayanray1@...il.com>, 
	Lukas Bulwahn <lukas.bulwahn@...il.com>
Subject: [PATCH 2/3] checkpatch: check indentation on case without space

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@...gle.com>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ