[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.11.1407030637030.15455@eddie.linux-mips.org>
Date: Thu, 3 Jul 2014 07:01:05 +0100 (BST)
From: "Maciej W. Rozycki" <macro@...ux-mips.org>
To: Joe Perches <joe@...ches.com>
cc: David Miller <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: [PATCH v2] declance: Fix 64-bit compilation warnings
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;
instead (clearing the flag to suit `number' called later on, that is).
And I actually find it a natural consequence of how we implement `%p';
using `#' to switch between the two formats seems to fit ISO C perfectly
(as an extension, that is, of course, but that does not contradict the
requirement of "undefined behaviour").
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?
> I phrased it badly though.
> There's no code that uses it.
>
> $ git grep "%#p" | wc -l
> 0
Yeah, I did this before too; no surprise given the warning GCC produces.
> > I think using 0x%p
> > would be ugly; here it wouldn't really matter, but ordinarily allowing a
> > format to produce `0x (null)' would be rather lame, so I don't want to
> > spread examples someone might foolishly copy.
>
> $ git grep "0x%p" | wc -l
> 1747
>
> <shrug> What's one more...
Heh, see what I mean. And somehow I don't feel compelled to follow 1747
mistakes. ;) We could fix them all though if we had a proper
`linux_printk' checker though.
Maciej
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists