[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1412222900.3247.33.camel@joe-AO725>
Date: Wed, 01 Oct 2014 21:08:20 -0700
From: Joe Perches <joe@...ches.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Paul McQuade <paulmcquad@...il.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, neilb@...e.de, sasha.levin@...cle.com,
rientjes@...gle.com, hughd@...gle.com,
paul.gortmaker@...driver.com, liwanp@...ux.vnet.ibm.com,
n-horiguchi@...jp.nec.com, iamjoonsoo.kim@....com
Subject: [PATCH] checkpatch: Warn on logging functions with KERN_<LEVEL>
Warn on probable misuses of logging functions with KERN_<LEVEL>
like pr_err(KERN_ERR "foo\n");
Suggested-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Joe Perches <joe@...ches.com>
---
> > - printk(KERN_ERR "ksm: register sysfs failed\n");
> > + pr_err(KERN_ERR "ksm: register sysfs failed\n");
> A quick grep indicates that we have the same mistake in tens of places.
> checkpatch rule, please?
scripts/checkpatch.pl | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 52a223e..374abf4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4447,6 +4447,17 @@ sub process {
}
}
+# check for logging functions with KERN_<LEVEL>
+ if ($line !~ /printk\s*\(/ &&
+ $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
+ my $level = $1;
+ if (WARN("UNNECESSARY_KERN_LEVEL",
+ "Possible unnecessary $level\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\s*$level\s*//;
+ }
+ }
+
# check for bad placement of section $InitAttribute (e.g.: __initdata)
if ($line =~ /(\b$InitAttribute\b)/) {
my $attr = $1;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists