diff options
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4c0383da1c9a..d8670810db65 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -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]))) { |
@@ -2654,11 +2654,6 @@ sub process { | |||
2654 | WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); | 2654 | WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); |
2655 | } | 2655 | } |
2656 | 2656 | ||
2657 | # SPIN_LOCK_UNLOCKED & RW_LOCK_UNLOCKED are deprecated | ||
2658 | if ($line =~ /\b(SPIN_LOCK_UNLOCKED|RW_LOCK_UNLOCKED)/) { | ||
2659 | ERROR("Use of $1 is deprecated: see Documentation/spinlocks.txt\n" . $herecurr); | ||
2660 | } | ||
2661 | |||
2662 | # warn about #if 0 | 2657 | # warn about #if 0 |
2663 | if ($line =~ /^.\s*\#\s*if\s+0\b/) { | 2658 | if ($line =~ /^.\s*\#\s*if\s+0\b/) { |
2664 | CHK("if this code is redundant consider removing it\n" . | 2659 | CHK("if this code is redundant consider removing it\n" . |
@@ -2809,9 +2804,9 @@ sub process { | |||
2809 | WARN("consider using a completion\n" . $herecurr); | 2804 | WARN("consider using a completion\n" . $herecurr); |
2810 | 2805 | ||
2811 | } | 2806 | } |
2812 | # recommend strict_strto* over simple_strto* | 2807 | # recommend kstrto* over simple_strto* |
2813 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { | 2808 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { |
2814 | WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr); | 2809 | WARN("consider using kstrto* in preference to simple_$1\n" . $herecurr); |
2815 | } | 2810 | } |
2816 | # check for __initcall(), use device_initcall() explicitly please | 2811 | # check for __initcall(), use device_initcall() explicitly please |
2817 | if ($line =~ /^.\s*__initcall\s*\(/) { | 2812 | if ($line =~ /^.\s*__initcall\s*\(/) { |
@@ -2907,6 +2902,11 @@ sub process { | |||
2907 | $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { | 2902 | $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { |
2908 | WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); | 2903 | WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); |
2909 | } | 2904 | } |
2905 | |||
2906 | # Check for memset with swapped arguments | ||
2907 | if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) { | ||
2908 | ERROR("memset size is 3rd argument, not the second.\n" . $herecurr); | ||
2909 | } | ||
2910 | } | 2910 | } |
2911 | 2911 | ||
2912 | # If we have no input at all, then there is nothing to report on | 2912 | # If we have no input at all, then there is nothing to report on |
@@ -2949,6 +2949,7 @@ sub process { | |||
2949 | if ($rpt_cleaners) { | 2949 | if ($rpt_cleaners) { |
2950 | print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n"; | 2950 | print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n"; |
2951 | print " scripts/cleanfile\n\n"; | 2951 | print " scripts/cleanfile\n\n"; |
2952 | $rpt_cleaners = 0; | ||
2952 | } | 2953 | } |
2953 | } | 2954 | } |
2954 | 2955 | ||