Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1578844 > unrolled thread

[PATCH v2] checkpatch: add warning on invalid %p extensions

Started bywilliam.c.roberts@intel.com
First post2017-02-10 23:50 +0100
Last post2017-02-10 23:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] checkpatch: add warning on invalid %p extensions william.c.roberts@intel.com - 2017-02-10 23:50 +0100

#1578844 — [PATCH v2] checkpatch: add warning on invalid %p extensions

Fromwilliam.c.roberts@intel.com
Date2017-02-10 23:50 +0100
Subject[PATCH v2] checkpatch: add warning on invalid %p extensions
Message-ID<t9saR-149-9@gated-at.bofh.it>
From: William Roberts <william.c.roberts@intel.com>

The kernel supports %p extensions as documented in
Documentation/printk-formats.txt. Warn on possibly
improper use of non-extension characters.

One issue would be the usage of %pk when %pK should have
been used. This has a side-effect of appearing to work
alright, but does not respect the kptr_restrict setting
as %pK does.

Sample output:
WARNING: Invalid vsprintf pointer extension '%pk'
+			printk(KERN_INFO "Could not allocate IRQ %d for PCI Applicom device. %pk\n", dev->irq, pci_get_class); // NOT OK

WARNING: Invalid vsprintf pointer extension '%pn'
+			sprintf(buf, "%pn", x); // NOT OK

Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 982c52c..fa22751 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6096,6 +6096,12 @@ sub process {
 			      "recursive locking is bad, do not use this ever.\n" . $herecurr);
 		}
 
+# check for vsprintf extension %p<foo> misuses
+		if (get_quoted_string($line, $rawline) =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGN]).)/) {
+			WARN("VSPRINTF_POINTER_EXTENSION",
+			     "Invalid vsprintf pointer extension '$1'\n" . $herecurr);
+		}
+
 # check for lockdep_set_novalidate_class
 		if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
 		    $line =~ /__lockdep_no_validate__\s*\)/ ) {
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web