diff options
author | Joe Perches <joe@perches.com> | 2015-09-09 15:37:47 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-10 13:29:01 -0700 |
commit | 6e30075742316a1d72b7e8f794f6e0bd44d774e2 (patch) | |
tree | 33526451b4d8503ef8f6afcb6fd529eed0e613d2 /scripts | |
parent | 7bd7e483c27d884c2f59e286e42623abba413f83 (diff) | |
download | linux-6e30075742316a1d72b7e8f794f6e0bd44d774e2.tar.gz linux-6e30075742316a1d72b7e8f794f6e0bd44d774e2.tar.bz2 linux-6e30075742316a1d72b7e8f794f6e0bd44d774e2.zip |
checkpatch: emit an error on formats with 0x%<decimal>
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 41ecae81de99..d98ffdd2180f 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 " |