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: <ede1f816fbe469442c6df8b6cb4976eb9e2e6749.1457667314.git.joe@perches.com>
Date:	Thu, 10 Mar 2016 19:35:53 -0800
From:	Joe Perches <joe@...ches.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Andy Whitcroft <apw@...onical.com>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] checkpatch: Improve UNSPECIFIED_INT test for bare signed/unsigned uses

Improve the test to allow casts to (unsigned) or (signed) to be
found and fixed if desired.

Signed-off-by: Joe Perches <joe@...ches.com>
---
 scripts/checkpatch.pl | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 75ce6d0..f59203c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3241,10 +3241,11 @@ sub process {
 		next if ($line =~ /^[^\+]/);
 
 # check for declarations of signed or unsigned without int
-		while ($line =~ m{($Declare++)\s*($Ident)\s*[=,;\[\)]}g) {
+		while ($line =~ m{($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
 			my $type = $1;
 			my $var = $2;
-			if ($type =~ /^((?:un)?signed)((?:\s*\*)*)\s*$/) {
+			$var = "" if (!defined $var);
+			if ($type =~ /^(?:(?:$Storage|$Inline|$Attribute)\s+)*((?:un)?signed)((?:\s*\*)*)\s*$/) {
 				my $sign = $1;
 				my $pointer = $2;
 
@@ -3254,8 +3255,11 @@ sub process {
 					 "Prefer '" . trim($sign) . " int" . rtrim($pointer) . "' to bare use of '$sign" . rtrim($pointer) . "'\n" . $herecurr) &&
 				    $fix) {
 					my $decl = trim($sign) . " int ";
-					$decl .= trim($pointer) if (rtrim($pointer) ne "");
-					$fixed[$fixlinenr] =~ s@\b\Q$type\E\s*$var\b@...cl$var@;
+					my $comp_pointer = $pointer;
+					$comp_pointer =~ s/\s//g;
+					$decl .= $comp_pointer;
+					$decl = rtrim($decl) if ($var eq "");
+					$fixed[$fixlinenr] =~ s@\b$sign\s*\Q$pointer\E\s*$var\b@...cl$var@;
 				}
 			}
 		}
-- 
2.6.3.368.gf34be46

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ