All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Wennborg <hans@hanshq.net>
To: Joe Perches <joe@perches.com>
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: Mon, 04 Aug 2014 18:17:51 -0700	[thread overview]
Message-ID: <53E030BF.1010907@hanshq.net> (raw)
In-Reply-To: <1407124017.16152.31.camel@joe-AO725>

On 08/03/2014 08:46 PM, Joe Perches wrote:
> 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.

I grepped with your regex over the code and didn't get any false 
positives, so it seems fine. Feel free to ignore my previous comment.

Thanks,
Hans

  reply	other threads:[~2014-08-05  1:17 UTC|newest]

Thread overview: 22+ 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
     [not found] ` <1407018043-648-1-git-send-email-hans-7z9IcJk4adCsTnJN9+BGXg@public.gmane.org>
2014-08-03  0:46   ` Joe Perches
2014-08-03  0:46     ` Joe Perches
2014-08-03  0:46     ` Joe Perches
2014-08-03  1:19     ` Hans Wennborg
2014-08-03  1:19       ` Hans Wennborg
2014-08-03  6:10       ` Joe Perches
2014-08-03  6:10         ` Joe Perches
2014-08-03  6:10         ` Joe Perches
2014-08-04  0:25         ` Hans Wennborg
2014-08-04  0:25           ` Hans Wennborg
2014-08-04  0:25           ` Hans Wennborg
2014-08-04  0:33           ` Joe Perches
2014-08-04  0:33             ` Joe Perches
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
2014-08-05  1:17                   ` Hans Wennborg [this message]
2014-08-03  2:26     ` [PATCH 1/1] cris: fix %d confusingly prefixed with 0x in format string Steve French
2014-08-03  2:26       ` Steve French
2014-08-03  2:26       ` 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=53E030BF.1010907@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.