aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl19
1 files changed, 12 insertions, 7 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8f9e394298cd..8657f99bfb2b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -210,10 +210,10 @@ our $typeTypedefs = qr{(?x:
210 210
211our $logFunctions = qr{(?x: 211our $logFunctions = qr{(?x:
212 printk| 212 printk|
213 pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| 213 [a-z]+_(emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)|
214 (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)|
215 WARN| 214 WARN|
216 panic 215 panic|
216 MODULE_[A-Z_]+
217)}; 217)};
218 218
219our @typeList = ( 219our @typeList = (
@@ -1462,7 +1462,7 @@ sub process {
1462#80 column limit 1462#80 column limit
1463 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && 1463 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1464 $rawline !~ /^.\s*\*\s*\@$Ident\s/ && 1464 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1465 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ || 1465 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
1466 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && 1466 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1467 $length > 80) 1467 $length > 80)
1468 { 1468 {
@@ -1946,13 +1946,13 @@ sub process {
1946# printk should use KERN_* levels. Note that follow on printk's on the 1946# printk should use KERN_* levels. Note that follow on printk's on the
1947# same line do not need a level, so we use the current block context 1947# same line do not need a level, so we use the current block context
1948# to try and find and validate the current printk. In summary the current 1948# to try and find and validate the current printk. In summary the current
1949# printk includes all preceeding printk's which have no newline on the end. 1949# printk includes all preceding printk's which have no newline on the end.
1950# we assume the first bad printk is the one to report. 1950# we assume the first bad printk is the one to report.
1951 if ($line =~ /\bprintk\((?!KERN_)\s*"/) { 1951 if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
1952 my $ok = 0; 1952 my $ok = 0;
1953 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) { 1953 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
1954 #print "CHECK<$lines[$ln - 1]\n"; 1954 #print "CHECK<$lines[$ln - 1]\n";
1955 # we have a preceeding printk if it ends 1955 # we have a preceding printk if it ends
1956 # with "\n" ignore it, else it is to blame 1956 # with "\n" ignore it, else it is to blame
1957 if ($lines[$ln - 1] =~ m{\bprintk\(}) { 1957 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
1958 if ($rawlines[$ln - 1] !~ m{\\n"}) { 1958 if ($rawlines[$ln - 1] !~ m{\\n"}) {
@@ -2044,7 +2044,7 @@ sub process {
2044 for (my $n = 0; $n < $#elements; $n += 2) { 2044 for (my $n = 0; $n < $#elements; $n += 2) {
2045 $off += length($elements[$n]); 2045 $off += length($elements[$n]);
2046 2046
2047 # Pick up the preceeding and succeeding characters. 2047 # Pick up the preceding and succeeding characters.
2048 my $ca = substr($opline, 0, $off); 2048 my $ca = substr($opline, 0, $off);
2049 my $cc = ''; 2049 my $cc = '';
2050 if (length($opline) >= ($off + length($elements[$n + 1]))) { 2050 if (length($opline) >= ($off + length($elements[$n + 1]))) {
@@ -2748,6 +2748,11 @@ sub process {
2748 WARN("sizeof(& should be avoided\n" . $herecurr); 2748 WARN("sizeof(& should be avoided\n" . $herecurr);
2749 } 2749 }
2750 2750
2751# check for line continuations in quoted strings with odd counts of "
2752 if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
2753 WARN("Avoid line continuations in quoted strings\n" . $herecurr);
2754 }
2755
2751# check for new externs in .c files. 2756# check for new externs in .c files.
2752 if ($realfile =~ /\.c$/ && defined $stat && 2757 if ($realfile =~ /\.c$/ && defined $stat &&
2753 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) 2758 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)