[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1407120645.16152.28.camel@joe-AO725>
Date: Sun, 03 Aug 2014 19:50:45 -0700
From: Joe Perches <joe@...ches.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, Hans Wennborg <hans@...shq.net>,
Andy Whitcroft <apw@...onical.com>
Subject: [PATCH] checkpatch: Add test for printf formats with 0x that emit
decimal
0x%<foo> should be used to emit hexadecimal values.
Uses of 0x%[udi] emit decimal values but these should
probably instead use 0x%x variants.
Warn on these uses.
Signed-off-by: Joe Perches <joe@...ches.com>
Noticed-by: Hans Wennborg <hans@...shq.net>
---
scripts/checkpatch.pl | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index da74e65..0178fe0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4985,6 +4985,10 @@ sub process {
while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
$string = substr($rawline, $-[1], $+[1] - $-[1]);
$string =~ s/%%/__/g;
+ if ($string =~ /(0x(?<!%)%[0-9.\*]*[Ll]*[udi])(?![xX])/) {
+ WARN("PRINTF_HEX_WITH_DECIMAL",
+ "Using printf format $1 emits a decimal not hexadecimal value\n" . $herecurr);
+ }
if ($string =~ /(?<!%)%L[udi]/) {
WARN("PRINTF_L",
"\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
--
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