aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl25
1 files changed, 20 insertions, 5 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fd21b5eaed3f..b6bbbcdc557e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,7 +9,7 @@ use strict;
9my $P = $0; 9my $P = $0;
10$P =~ s@.*/@@g; 10$P =~ s@.*/@@g;
11 11
12my $V = '0.17'; 12my $V = '0.18';
13 13
14use Getopt::Long qw(:config no_auto_abbrev); 14use Getopt::Long qw(:config no_auto_abbrev);
15 15
@@ -1144,7 +1144,7 @@ sub process {
1144 1144
1145# Check for potential 'bare' types 1145# Check for potential 'bare' types
1146 my ($stat, $cond); 1146 my ($stat, $cond);
1147 if ($realcnt) { 1147 if ($realcnt && $line =~ /.\s*\S/) {
1148 ($stat, $cond) = ctx_statement_block($linenr, 1148 ($stat, $cond) = ctx_statement_block($linenr,
1149 $realcnt, 0); 1149 $realcnt, 0);
1150 $stat =~ s/\n./\n /g; 1150 $stat =~ s/\n./\n /g;
@@ -1316,12 +1316,12 @@ sub process {
1316 } 1316 }
1317 1317
1318# check for external initialisers. 1318# check for external initialisers.
1319 if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL);/) { 1319 if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL|false)\s*;/) {
1320 ERROR("do not initialise externals to 0 or NULL\n" . 1320 ERROR("do not initialise externals to 0 or NULL\n" .
1321 $herecurr); 1321 $herecurr);
1322 } 1322 }
1323# check for static initialisers. 1323# check for static initialisers.
1324 if ($line =~ /\s*static\s.*=\s*(0|NULL);/) { 1324 if ($line =~ /\s*static\s.*=\s*(0|NULL|false)\s*;/) {
1325 ERROR("do not initialise statics to 0 or NULL\n" . 1325 ERROR("do not initialise statics to 0 or NULL\n" .
1326 $herecurr); 1326 $herecurr);
1327 } 1327 }
@@ -1973,7 +1973,7 @@ sub process {
1973 1973
1974# check for new externs in .c files. 1974# check for new externs in .c files.
1975 if ($realfile =~ /\.c$/ && defined $stat && 1975 if ($realfile =~ /\.c$/ && defined $stat &&
1976 $stat =~ /^.(?:extern\s+)?$Type\s+$Ident(\s*)\(/s) 1976 $stat =~ /^.\s*(?:extern\s+)?$Type\s+$Ident(\s*)\(/s)
1977 { 1977 {
1978 my $paren_space = $1; 1978 my $paren_space = $1;
1979 1979
@@ -1988,6 +1988,11 @@ sub process {
1988 if ($paren_space =~ /\n/) { 1988 if ($paren_space =~ /\n/) {
1989 WARN("arguments for function declarations should follow identifier\n" . $herecurr); 1989 WARN("arguments for function declarations should follow identifier\n" . $herecurr);
1990 } 1990 }
1991
1992 } elsif ($realfile =~ /\.c$/ && defined $stat &&
1993 $stat =~ /^.\s*extern\s+/)
1994 {
1995 WARN("externs should be avoided in .c files\n" . $herecurr);
1991 } 1996 }
1992 1997
1993# checks for new __setup's 1998# checks for new __setup's
@@ -2033,6 +2038,16 @@ sub process {
2033 { 2038 {
2034 WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); 2039 WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
2035 } 2040 }
2041
2042# check for %L{u,d,i} in strings
2043 my $string;
2044 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
2045 $string = substr($rawline, $-[1], $+[1] - $-[1]);
2046 if ($string =~ /(?<!%)%L[udi]/) {
2047 WARN("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
2048 last;
2049 }
2050 }
2036 } 2051 }
2037 2052
2038 # If we have no input at all, then there is nothing to report on 2053 # If we have no input at all, then there is nothing to report on