public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Hans Wennborg <hans@hanshq.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	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:46:57 -0700	[thread overview]
Message-ID: <1407124017.16152.31.camel@joe-AO725> (raw)
In-Reply-To: <53DEF81B.1000303@hanshq.net>

On Sun, 2014-08-03 at 20:03 -0700, Hans Wennborg wrote:
> 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!
[]
> > diff --git 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.)

Maybe.

Code it to do the appropriate thing and test it too.
See if there any other cases that should be emitted.

cheers, Joe



  reply	other threads:[~2014-08-04  3:47 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
2014-08-04  3:46               ` Joe Perches [this message]
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=1407124017.16152.31.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=hans@hanshq.net \
    --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