aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2008-04-29 03:59:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:05 -0400
commit9c9ba34ee3dbc34e829f42e42a5e5273b1183500 (patch)
tree852a974821beaf9dce3b69610610ecdb9ad36696 /scripts
parent171ae1a491e216ef728436f9cc958e05cccf5a27 (diff)
update checkpatch.pl to version 0.18
This version brings a few fixes for the extern checks, and a couple of new checks. Of note: - false is now recognised as a 0 assignment in static/external assignments, - printf format strings including %L are reported, - a number of fixes for the extern in .c file detector which had temporarily lost its ability to detect variables; undetected due to the loss of its test. Andy Whitcroft (8): Version: 0.18 false should trip 0 assignment checks tests: reinstate missing tests tests: allow specification of the file extension for a test fix extern checks for variables check for and report %Lu, %Ld, and %Li ensure we only start a statement on lines with some content extern spacing Signed-off-by: Andy Whitcroft <apw@shadowen.org> Cc: Ingo Molnar <mingo@elte.hu> 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.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