[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1404657160.27043.29.camel@joe-AO725>
Date: Sun, 06 Jul 2014 07:32:40 -0700
From: Joe Perches <joe@...ches.com>
To: "Maciej W. Rozycki" <macro@...ux-mips.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Grant Likely <grant.likely@...retlab.ca>,
David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vsprintf: Remove SPECIAL from pointer types
On Sun, 2014-07-06 at 12:44 +0100, Maciej W. Rozycki wrote:
> On Sat, 5 Jul 2014, Joe Perches wrote:
>
> > Because gcc issues a complaint about any pointer format with %#p,
> > remove the use of SPECIAL to prefix 0x to various pointer types.
[]
> Conceptually good, thanks for your effort, but you still need to clear
> SPECIAL in `pointer' and maybe elsewhere, as that'll have been set for the
> case concerned in `format_decode' by this code:
>
> case '#': spec->flags |= SPECIAL; break;
>
> (that doesn't check what follows) and then respected once `number' is
> reached. E.g.:
>
> char *pointer(const char *fmt, char *buf, char *end, void *ptr,
> struct printf_spec spec)
> {
> int default_width = 2 * sizeof(void *);
>
> spec.flags &= ~SPECIAL;
>
> or suchlike. Sorry to have been unclear about it.
I think you're not right here.
The patch shouldn't remove the capability to prefix.
But neither am I right with the commit log actually.
It should say something like "remove the default extra
width for the 0x prefix from %#p".
Actually, I'm not sure that removing "SPECIAL adds
the pointer prefix length" to width is that good.
I think it doesn't matter much.
I do like removing the prefix it from %pa though.
linux's printf like capability is not exactly like
gcc's. It doesn't have to be. linux's implementation
already does not prefix 0x to pointers when gcc does.
gcc uses '(nil)', linux '(null)', etc.
And linux's variant does a bunch of extended outputs
for %p<foo> variants where it overrides any size and
prefixing specified.
The only difference introduced by the proposed patch
here is that a generic pointer type will now have a
variable output width if %#p is used depending on the
high two bytes of the pointer value if a size is not
specified.
fyi: gcc will output a prefix 0x with %#p just as it
does for %p.
The major difference is that linux uses a default of
sizeof(void *) * 2 for the width and zero fills without
prefix, gcc defaults to the minimum # of chars required
and prefixes.
cheers, Joe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists