aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2017-11-17 18:28:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 19:10:02 -0500
commiteeef5733e30e736926c762fa3336c4dd5702bcdf (patch)
treebe1e6633c56967c6d8812a759c50bddb143dfd79 /scripts/checkpatch.pl
parent258f79d5a1e49271f5aff38e6c1baeeaad0d82aa (diff)
checkpatch: printks always need a KERN_<LEVEL>
There was code in checkpatch that allowed continuation printks to be used without KERN_CONT. Remove the continuation check and always require a KERN_<LEVEL>. Link: http://lkml.kernel.org/r/61980ef41d5b9b6543da1c49055042e0ab74d308.1507047008.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl26
1 files changed, 4 insertions, 22 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8dce8a8d9ed0..2a8c6c3c1bdb 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3829,28 +3829,10 @@ sub process {
3829 "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); 3829 "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
3830 } 3830 }
3831 3831
3832# printk should use KERN_* levels. Note that follow on printk's on the 3832# printk should use KERN_* levels
3833# same line do not need a level, so we use the current block context 3833 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
3834# to try and find and validate the current printk. In summary the current 3834 WARN("PRINTK_WITHOUT_KERN_LEVEL",
3835# printk includes all preceding printk's which have no newline on the end. 3835 "printk() should include KERN_<LEVEL> facility level\n" . $herecurr);
3836# we assume the first bad printk is the one to report.
3837 if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
3838 my $ok = 0;
3839 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
3840 #print "CHECK<$lines[$ln - 1]\n";
3841 # we have a preceding printk if it ends
3842 # with "\n" ignore it, else it is to blame
3843 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
3844 if ($rawlines[$ln - 1] !~ m{\\n"}) {
3845 $ok = 1;
3846 }
3847 last;
3848 }
3849 }
3850 if ($ok == 0) {
3851 WARN("PRINTK_WITHOUT_KERN_LEVEL",
3852 "printk() should include KERN_ facility level\n" . $herecurr);
3853 }
3854 } 3836 }
3855 3837
3856 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) { 3838 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {