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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210626034016.170306-4-jim.cromie@gmail.com>
Date:   Fri, 25 Jun 2021 21:40:16 -0600
From:   Jim Cromie <jim.cromie@...il.com>
To:     joe@...ches.com, linux-kernel@...r.kernel.org
Cc:     Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH 3/3] checkpatch: suppress BUG_ON warn when it is named in commitmsg

allow mention of BUG_ON in the preamble/commitmsg/intro to silence the
warning normally issued when one is added.  This presumes the commit
message will adequately explain the reason "BUG_ON" is appropriate.

Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
 scripts/checkpatch.pl | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a8dfba53b593..32612f39d742 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2560,6 +2560,18 @@ sub exclude_global_initialisers {
 		$realfile =~ m@...f/.*\.bpf\.c$@;
 }
 
+sub commitmsg_refers_to {	# see if $srch is in commit message
+	my ($srch, $lines) = @_;
+	#print "ok checking for $srch in $lines lines\n";
+	for my $i (0..$lines) {
+		if ($rawlines[$i] =~ /$srch/) {
+			print "\thmm: $srch mentioned in preamble, presuming it is explained\n";
+			return 1;
+		}
+	}
+	return 0;
+}
+
 sub process {
 	my $filename = shift;
 
@@ -2586,6 +2598,7 @@ sub process {
 	my $has_patch_separator = 0;	#Found a --- line
 	my $has_commit_log = 0;		#Encountered lines before patch
 	my $commit_log_lines = 0;	#Number of commit log lines
+	my $eopreamble = 0;		# above truncates at =~ /^\. \w+/
 	my $commit_log_possible_stack_dump = 0;
 	my $commit_log_long_line = 0;
 	my $commit_log_has_diff = 0;
@@ -2731,6 +2744,7 @@ sub process {
 		    ($line =~ /^rename (?:from|to) \S+\s*$/ ||
 		     $line =~ /^diff --git a\/[\w\/\.\_\-]+ b\/\S+\s*$/))) {
 			$is_patch = 1;
+			$eopreamble = $linenr;
 		}
 
 #extract the line range in the file after the patch is applied
@@ -4654,7 +4668,7 @@ sub process {
 		}
 
 # avoid BUG() or BUG_ON()
-		if ($line =~ /\b(?:BUG|BUG_ON)\b/) {
+		if ($line =~ /\b(BUG|BUG_ON)\b/ && !commitmsg_refers_to($1, $eopreamble)) {
 			my $msg_level = \&WARN;
 			$msg_level = \&CHK if ($file);
 			&{$msg_level}("AVOID_BUG",
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ