From: Hans Wennborg <hans@hanshq.net>
To: Joe Perches <joe@perches.com>, Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>
Subject: Re: [PATCH] checkpatch: Add test for printf formats with 0x that emit decimal
Date: Sun, 03 Aug 2014 20:03:55 -0700 [thread overview]
Message-ID: <53DEF81B.1000303@hanshq.net> (raw)
In-Reply-To: <1407120645.16152.28.camel@joe-AO725>
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
next prev parent reply other threads:[~2014-08-04 3:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-02 22:20 [PATCH 1/1] cris: fix %d confusingly prefixed with 0x in format string Hans Wennborg
2014-08-03 0:46 ` Joe Perches
2014-08-03 1:19 ` Hans Wennborg
2014-08-03 6:10 ` Joe Perches
2014-08-04 0:25 ` Hans Wennborg
2014-08-04 0:33 ` Joe Perches
2014-08-04 2:50 ` [PATCH] checkpatch: Add test for printf formats with 0x that emit decimal Joe Perches
2014-08-04 3:03 ` Hans Wennborg [this message]
2014-08-04 3:46 ` Joe Perches
2014-08-05 1:17 ` Hans Wennborg
2014-08-03 2:26 ` [PATCH 1/1] cris: fix %d confusingly prefixed with 0x in format string Steve French
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53DEF81B.1000303@hanshq.net \
--to=hans@hanshq.net \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox