[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201217171111.GA8295@ls3530.fritz.box>
Date: Thu, 17 Dec 2020 18:11:11 +0100
From: Helge Deller <deller@....de>
To: Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] checkpatch: add new warning when lookup_symbol_name() is used
In most cases people use lookup_symbol_name() to resolve a kernel symbol
and then print it via printk().
In such cases using the %ps, %pS, %pSR or %pB printk formats are easier
to use and thus should be preferred.
Signed-off-by: Helge Deller <deller@....de>
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fab38b493cef..0d5515a3d875 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4317,6 +4317,12 @@ sub process {
"LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
}
+# avoid lookup_symbol_name()
+ if ($line =~ /\blookup_symbol_name\b/) {
+ WARN("PREFER_PRINTK_FORMAT",
+ "If possible prefer %ps or %pS printk format string to print symbol name instead of using lookup_symbol_name()\n" . $herecurr);
+ }
+
# check for uses of printk_ratelimit
if ($line =~ /\bprintk_ratelimit\s*\(/) {
WARN("PRINTK_RATELIMITED",
Powered by blists - more mailing lists