Netdev List
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [PATCH v2] declance: Fix 64-bit compilation warnings
Date: Wed, 02 Jul 2014 23:25:46 -0700	[thread overview]
Message-ID: <1404368746.14741.36.camel@joe-AO725> (raw)
In-Reply-To: <alpine.LFD.2.11.1407030637030.15455@eddie.linux-mips.org>

On Thu, 2014-07-03 at 07:01 +0100, Maciej W. Rozycki wrote:
> On Wed, 2 Jul 2014, Joe Perches wrote:
> 
> > > > The kernel vsprintf implementation doesn't prefix
> > > > pointers with 0x, so you can use 0x%p if you really
> > > > want that with a leading prefix, but you don't have
> > > > to use it.
> > > 
> > >  It does, when the `#' format modifier is used (go try yourself!).
> > 
> > I know it does, but it's incidental.
> 
>  Is it?  Someone took the effort to handle it:
> 
> 	int default_width = 2 * sizeof(void *) + (spec.flags & SPECIAL ? 2 : 0);
> 
> while they could do:
> 
> 	int default_width = 2 * sizeof(void *);
> 
> 	spec.flags &= ~SPECIAL;

Grant Likely did that a couple of years ago.

commit 725fe002d315c2501c110b7245d3eb4f4535f4d6
Author: Grant Likely <grant.likely@secretlab.ca>
Date:   Thu May 31 16:26:08 2012 -0700

    vsprintf: correctly handle width when '#' flag used in %#p format
    
    The '%p' output of the kernel's vsprintf() uses spec.field_width to
    determine how many digits to output based on 2 * sizeof(void*) so that all
    digits of a pointer are shown.  ie.  a pointer will be output as
    "001A2B3C" instead of "1A2B3C".  However, if the '#' flag is used in the
    format (%#p), then the code doesn't take into account the width of the
    '0x' prefix and will end up outputing "0x1A2B3C" instead of "0x001A2B3C".
    
    This patch reworks the "pointer()" format hook to include 2 characters for
    the '0x' prefix if the '#' flag is included.

Not sure it ever mattered myself.

>  Hmm, actually I wonder if GCC maintainers could be persuaded to accept a 
> `linux_printk' format checker, that would accurately match our semantics 
> and could handle some of our other extensions too.  There are precedents 
> already, `cmn_err' and `CFString' (for Solaris and Darwin), so it's not 
> like a no-no outright.  WDYT?
> 

Maybe via a gcc plugin.

https://gcc.gnu.org/wiki/plugins

If you're going to write one, it'd be nice to validate all
the %p<foo> extensions too.

  reply	other threads:[~2014-07-03  6:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-29  2:10 [PATCH v2] declance: Fix 64-bit compilation warnings Maciej W. Rozycki
2014-07-03  1:28 ` David Miller
2014-07-03  2:29   ` Maciej W. Rozycki
2014-07-03  2:34     ` Maciej W. Rozycki
2014-07-03  3:05       ` Joe Perches
2014-07-03  4:51         ` Maciej W. Rozycki
2014-07-03  5:16           ` Joe Perches
2014-07-03  6:01             ` Maciej W. Rozycki
2014-07-03  6:25               ` Joe Perches [this message]
2014-07-03 16:57                 ` Grant Likely
2014-07-05 14:56                 ` Maciej W. Rozycki
2014-07-05 16:07                   ` Joe Perches
2014-07-05 17:39                     ` Maciej W. Rozycki
2014-07-05 18:08                       ` Joe Perches
2014-07-05 18:20                         ` Maciej W. Rozycki
2014-07-05 18:31                           ` Joe Perches
2014-07-05 20:25                             ` Maciej W. Rozycki
2014-07-05 20:45                               ` [PATCH] vsprintf: Remove SPECIAL from pointer types Joe Perches
2014-07-06 11:44                                 ` Maciej W. Rozycki
2014-07-06 14:32                                   ` Joe Perches
2014-07-07  8:26                                 ` David Laight
2014-07-07 13:26                                   ` Joe Perches
2014-07-07 12:01                             ` [PATCH v2] declance: Fix 64-bit compilation warnings Grant Likely
2014-07-07 12:18                               ` Maciej W. Rozycki
2014-07-07 13:40                               ` Joe Perches

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=1404368746.14741.36.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=davem@davemloft.net \
    --cc=grant.likely@secretlab.ca \
    --cc=macro@linux-mips.org \
    --cc=netdev@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