aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2016-03-15 14:58:06 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-15 16:55:16 -0700
commit207a8e8465f91dc5ab12151ee36db3d509a4928a (patch)
tree9914f5a1ab10e67c978fe2323b3cab815d5dc198 /scripts
parentcheckpatch: warn on bare unsigned or signed declarations without int (diff)
downloadlinux-dev-207a8e8465f91dc5ab12151ee36db3d509a4928a.tar.xz
linux-dev-207a8e8465f91dc5ab12151ee36db3d509a4928a.zip
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@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl12
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4b314bd15a0d..b7f44b2c4334 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3240,10 +3240,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;
@@ -3253,8 +3254,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@$decl$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@$decl$var@;
}
}
}