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]
Date:   Mon,  6 Aug 2018 13:58:09 +1000
From:   Andrew Donnellan <andrew.donnellan@....ibm.com>
To:     linux-kernel@...r.kernel.org, apw@...onical.com, joe@...ches.com
Cc:     fbarrat@...ux.vnet.ibm.com
Subject: [RFC PATCH 2/2] checkpatch: Fix commit ID test when "commit" and hash on different lines

Signed-off-by: Andrew Donnellan <andrew.donnellan@....ibm.com>

---

RFC because I'm bad at Perl
---
 scripts/checkpatch.pl | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index aca4d758112a..ae7a54287db7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2662,40 +2662,46 @@ sub process {
 			my $id = '0123456789ab';
 			my $orig_desc = "commit description";
 			my $description = "";
+			my $ref_line = $line;
 
-			if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
+			if ($ref_line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
 				$init_char = $1;
 				$orig_commit = lc($2);
-			} elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) {
+			} elsif ($ref_line =~ /\b([0-9a-f]{12,40})\b/i) {
 				$orig_commit = lc($1);
+				if (defined $rawlines[$linenr - 2] &&
+					$rawlines[$linenr - 2] =~ /\bcommit$/) {
+					$ref_line = "commit " . $ref_line;
+				}
 			}
-			$short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
-			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
-			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
-			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
 
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
+			$short = 0 if ($ref_line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
+			$long = 1 if ($ref_line =~ /\bcommit\s+[0-9a-f]{41,}/i);
+			$space = 0 if ($ref_line =~ /\bcommit [0-9a-f]/i);
+			$case = 0 if ($ref_line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
+
+			if ($ref_line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
 				# Reference fits on 1 line
 				$orig_desc = $1;
 				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
+			} elsif ($ref_line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
 				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
 				# line 1: 'commit <hash>',
 				# line 2: '("description")'
 				$orig_desc = $1;
 				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+			} elsif ($ref_line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
 				 defined $rawlines[$linenr] &&
 				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
 				# line 1: 'commit <hash> ("description',
 				# line 2: 'description continued")'
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+				$ref_line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
 				$orig_desc = $1;
 				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
 				$orig_desc .= " " . $1;
 				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
+			} elsif ($ref_line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
 				 defined $rawlines[$linenr + 1] &&
 				 $rawlines[$linenr] =~ /^\s*\("[^"]+/ &&
@@ -2708,7 +2714,7 @@ sub process {
 				$rawlines[$linenr + 1] =~ /^\s*([^"]+)"\)/;
 				$orig_desc .= " " . $1;
 				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+			} elsif ($ref_line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
 				 defined $rawlines[$linenr] &&
 				 defined $rawlines[$linenr + 1] &&
 				 $rawlines[$linenr] =~ /^\s*[^"]+$/ &&
@@ -2716,7 +2722,7 @@ sub process {
 				# line 1: 'commit <hash> ("description',
 				# line 2: 'description continued'
 				# line 3: 'description continued")'
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+				$ref_line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
 				$orig_desc = $1;
 				$rawlines[$linenr] =~ /^\s*([^"]+)$/;
 				$orig_desc .= " " . $1;
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ