summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2017-01-25 11:09:27 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2017-01-31 17:42:43 +1100
commitf1671f69dfb24483b86010285988fa28eed3514c (patch)
treed192147cc1d8e63ee3cf1960f88d7876f5fba34a
parentb3cbf7f152fd78c2ad3a7652170bfd85641cda5a (diff)
checkpatch: warn when formats use %Z and suggest %z
vsnprintf extension %Z<foo> is non-standard C. Suggest the use of %z instead. Miscellanea: o Correct the misuse of type string PRINTF_0xDECIMAL type strings are supposed to be uppercase only. Fix this and add tr/[a-z]/[A-Z] to the type check in case I forget this again sometime in the future. o Improve the mechanism to find these defects so all 3 current checks are done on the format string Link: http://lkml.kernel.org/r/20170109235955.GA6787@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rwxr-xr-xscripts/checkpatch.pl6
1 files changed, 6 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a556d1a2d85e..47d0f8a337e7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5207,6 +5207,12 @@ sub process {
"\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
last;
}
+ # check for %Z
+ if ($string =~ /(?<!%)%[\*\d\.\$]*Z[diouxX]/) {
+ WARN("PRINTF_Z",
+ "%Z is non-standard C, use %z\n" . $herecurr);
+ last;
+ }
if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) {
ERROR("PRINTF_0xDECIMAL",
"Prefixing 0x with decimal output is defective\n" . $herecurr);