lkml.org 
[lkml]   [2014]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] checkpatch: Add test for printf formats with 0x that emit decimal
On 08/03/2014 07:50 PM, Joe Perches wrote:
> 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.

Good idea!

>
> Signed-off-by: Joe Perches <joe@perches.com>
> Noticed-by: Hans Wennborg <hans@hanshq.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])/) {

Maybe the regex should have a \b to check for a word boundary before the
0 to avoid matching things like "800x%d"? (I don't know if that occurs
in the kernel, but I've seen it elsewhere.)

- Hans


\
 
 \ /
  Last update: 2014-08-04 05:41    [W:0.088 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site