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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251109160036.643864-1-cmllamas@google.com>
Date: Sun,  9 Nov 2025 16:00:35 +0000
From: Carlos Llamas <cmllamas@...gle.com>
To: Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>, 
	Dwaipayan Ray <dwaipayanray1@...il.com>, Lukas Bulwahn <lukas.bulwahn@...il.com>
Cc: kernel-team@...roid.com, linux-kernel@...r.kernel.org, 
	Carlos Llamas <cmllamas@...gle.com>
Subject: [PATCH] checkpatch: ignore removed lines in comment detection

The comment detection logic in ctx_locate_comment() can be confused by
removed lines in a patch. When a removed line is encountered, any
previously detected comments are ignored.

For example, in the following change checkpatch fails to detect the
existing comment and reports: "WARNING: data_race without comment".

         /* explanation */
 -       if (data_race(priv->init))
 +       if (data_race(priv->init) && bytes)
                 break;

Fix this by explicitly ignoring any removed lines when looking at the
context. This ensures that comments are correctly associated to the
added lines.

Signed-off-by: Carlos Llamas <cmllamas@...gle.com>
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 92669904eecc..c4432f88c58f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1990,6 +1990,7 @@ sub ctx_locate_comment {
 	for (my $linenr = $first_line; $linenr < $end_line; $linenr++) {
 		my $line = $rawlines[$linenr - 1];
 		#warn "           $line\n";
+		next if ($line =~ m@^-@); # skip removed lines
 		if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
 			$in_comment = 1;
 		}
-- 
2.51.2.1041.gc1ab5b90ca-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ