diff options
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index f43d95a25712..5971b0c11616 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -3829,6 +3829,26 @@ sub process { | |||
| 3829 | "type '$tmp' should be specified in [[un]signed] [short|int|long|long long] order\n" . $herecurr); | 3829 | "type '$tmp' should be specified in [[un]signed] [short|int|long|long long] order\n" . $herecurr); |
| 3830 | } | 3830 | } |
| 3831 | 3831 | ||
| 3832 | # check for unnecessary <signed> int declarations of short/long/long long | ||
| 3833 | while ($sline =~ m{\b($TypeMisordered(\s*\*)*|$C90_int_types)\b}g) { | ||
| 3834 | my $type = trim($1); | ||
| 3835 | next if ($type !~ /\bint\b/); | ||
| 3836 | next if ($type !~ /\b(?:short|long\s+long|long)\b/); | ||
| 3837 | my $new_type = $type; | ||
| 3838 | $new_type =~ s/\b\s*int\s*\b/ /; | ||
| 3839 | $new_type =~ s/\b\s*(?:un)?signed\b\s*/ /; | ||
| 3840 | $new_type =~ s/^const\s+//; | ||
| 3841 | $new_type = "unsigned $new_type" if ($type =~ /\bunsigned\b/); | ||
| 3842 | $new_type = "const $new_type" if ($type =~ /^const\b/); | ||
| 3843 | $new_type =~ s/\s+/ /g; | ||
| 3844 | $new_type = trim($new_type); | ||
| 3845 | if (WARN("UNNECESSARY_INT", | ||
| 3846 | "Prefer '$new_type' over '$type' as the int is unnecessary\n" . $herecurr) && | ||
| 3847 | $fix) { | ||
| 3848 | $fixed[$fixlinenr] =~ s/\b\Q$type\E\b/$new_type/; | ||
| 3849 | } | ||
| 3850 | } | ||
| 3851 | |||
| 3832 | # check for static const char * arrays. | 3852 | # check for static const char * arrays. |
| 3833 | if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) { | 3853 | if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) { |
| 3834 | WARN("STATIC_CONST_CHAR_ARRAY", | 3854 | WARN("STATIC_CONST_CHAR_ARRAY", |
