aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl29
1 files changed, 28 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 874132b26d23..d574d13ba963 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3240,6 +3240,30 @@ sub process {
3240#ignore lines not being added 3240#ignore lines not being added
3241 next if ($line =~ /^[^\+]/); 3241 next if ($line =~ /^[^\+]/);
3242 3242
3243# check for declarations of signed or unsigned without int
3244 while ($line =~ m{($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
3245 my $type = $1;
3246 my $var = $2;
3247 $var = "" if (!defined $var);
3248 if ($type =~ /^(?:(?:$Storage|$Inline|$Attribute)\s+)*((?:un)?signed)((?:\s*\*)*)\s*$/) {
3249 my $sign = $1;
3250 my $pointer = $2;
3251
3252 $pointer = "" if (!defined $pointer);
3253
3254 if (WARN("UNSPECIFIED_INT",
3255 "Prefer '" . trim($sign) . " int" . rtrim($pointer) . "' to bare use of '$sign" . rtrim($pointer) . "'\n" . $herecurr) &&
3256 $fix) {
3257 my $decl = trim($sign) . " int ";
3258 my $comp_pointer = $pointer;
3259 $comp_pointer =~ s/\s//g;
3260 $decl .= $comp_pointer;
3261 $decl = rtrim($decl) if ($var eq "");
3262 $fixed[$fixlinenr] =~ s@\b$sign\s*\Q$pointer\E\s*$var\b@$decl$var@;
3263 }
3264 }
3265 }
3266
3243# TEST: allow direct testing of the type matcher. 3267# TEST: allow direct testing of the type matcher.
3244 if ($dbg_type) { 3268 if ($dbg_type) {
3245 if ($line =~ /^.\s*$Declare\s*$/) { 3269 if ($line =~ /^.\s*$Declare\s*$/) {
@@ -4109,7 +4133,7 @@ sub process {
4109## } 4133## }
4110 4134
4111#need space before brace following if, while, etc 4135#need space before brace following if, while, etc
4112 if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\){/) || 4136 if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
4113 $line =~ /do\{/) { 4137 $line =~ /do\{/) {
4114 if (ERROR("SPACING", 4138 if (ERROR("SPACING",
4115 "space required before the open brace '{'\n" . $herecurr) && 4139 "space required before the open brace '{'\n" . $herecurr) &&
@@ -4561,6 +4585,9 @@ sub process {
4561 { 4585 {
4562 } 4586 }
4563 4587
4588 # Make asm volatile uses seem like a generic function
4589 $dstat =~ s/\b_*asm_*\s+_*volatile_*\b/asm_volatile/g;
4590
4564 my $exceptions = qr{ 4591 my $exceptions = qr{
4565 $Declare| 4592 $Declare|
4566 module_param_named| 4593 module_param_named|