* [PATCH] checkpatch: Emit an error on formats with 0x%<decimal>
@ 2015-08-03 16:15 Joe Perches
2015-08-03 19:56 ` [PATCH V2] " Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2015-08-03 16:15 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Whitcroft, LKML
Using 0x%d is wrong. Emit a message when it happens.
Miscellanea:
improve the %Lu warning to match formats like %16Lu
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 50693f5..e367eab 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4816,16 +4816,20 @@ sub process {
"Consecutive strings are generally better as a single string\n" . $herecurr);
}
-# check for %L{u,d,i} in strings
+# check for %L{u,d,i} and 0x%[udi] in strings
my $string;
while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
$string = substr($rawline, $-[1], $+[1] - $-[1]);
$string =~ s/%%/__/g;
- if ($string =~ /(?<!%)%L[udi]/) {
+ if ($string =~ /(?<!%)%[\*\d\.\$]*L[udi]/) {
WARN("PRINTF_L",
"\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
last;
}
+ if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) {
+ ERROR("PRINTF_0xDECIMAL",
+ "Prefixing 0x with decimal output is defective\n" . $herecurr);
+ }
}
# check for line continuations in quoted strings with odd counts of "
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH V2] checkpatch: Emit an error on formats with 0x%<decimal>
2015-08-03 16:15 [PATCH] checkpatch: Emit an error on formats with 0x%<decimal> Joe Perches
@ 2015-08-03 19:56 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2015-08-03 19:56 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Whitcroft, LKML
Using 0x%d is wrong. Emit a message when it happens.
Miscellanea:
improve the %Lu warning to match formats like %16Lu
Signed-off-by: Joe Perches <joe@perches.com>
---
Resend with better email client
scripts/checkpatch.pl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 50693f5..e367eab 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4816,16 +4816,20 @@ sub process {
"Consecutive strings are generally better as a single string\n" . $herecurr);
}
-# check for %L{u,d,i} in strings
+# check for %L{u,d,i} and 0x%[udi] in strings
my $string;
while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
$string = substr($rawline, $-[1], $+[1] - $-[1]);
$string =~ s/%%/__/g;
- if ($string =~ /(?<!%)%L[udi]/) {
+ if ($string =~ /(?<!%)%[\*\d\.\$]*L[udi]/) {
WARN("PRINTF_L",
"\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
last;
}
+ if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) {
+ ERROR("PRINTF_0xDECIMAL",
+ "Prefixing 0x with decimal output is defective\n" . $herecurr);
+ }
}
# check for line continuations in quoted strings with odd counts of "
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-03 19:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 16:15 [PATCH] checkpatch: Emit an error on formats with 0x%<decimal> Joe Perches
2015-08-03 19:56 ` [PATCH V2] " Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).