[PATCH] vsprintf: Remove SPECIAL from pointer types

From: Joe Perches
Date: Sat Jul 05 2014 - 16:45:31 EST


Because gcc issues a complaint about any pointer format with %#p,
remove the use of SPECIAL to prefix 0x to various pointer types.

There are no uses in the kernel tree of %#p.

This removes the capability added by commit 725fe002d315
("vsprintf: correctly handle width when '#' flag used in %#p format").

There are some incidental message logging output changes of %pa
uses with this change. None are in seq output so there are no
api changes.

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---

Fine by me, here...

On Sat, 2014-07-05 at 21:25 +0100, Maciej W. Rozycki wrote:
> On Sat, 5 Jul 2014, Joe Perches wrote:
>
> > > > I don't think %#p is valid so it
> > > > shouldn't have been set by #.
> > >
> > > Huh? As recently as last Wednesday you pointed me at the specific commit
> > > from Grant that made it valid (GCC format complaints aside).
> >
> > Those gcc complaints are precisely the thing
> > that makes it invalid.
>
> So enforce that in code then, clear the SPECIAL flag where appropriate
> and do not try to handle it in one place while leaving other ones to
> behave randomly (i.e. a supposedly fixed field width varies depending on
> the two uppermost digits). Please note that it's only your proposed
> change that introduces that randomness, right now code does what's
> supposed and documented to, except a bit inconsistently.
>
> > I believe you're tilting at windmills.
> >
> > Hey, it works sometimes. Knock yourself out.
>
> I pointed out an inconsistency with the intent to propose a fix once a
> consensus have been reached, one way or another. And I think shifting the
> inconsistency to a different place, which is what your proposal does,
> isn't really a complete solution, although I do recognise the improvement.

lib/vsprintf.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6fe2c84..1cad65b 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -632,7 +632,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
return string(buf, end, sym, spec);
#else
spec.field_width = 2 * sizeof(void *);
- spec.flags |= SPECIAL | SMALL | ZEROPAD;
+ spec.flags |= SMALL | ZEROPAD;
spec.base = 16;

return number(buf, end, value, spec);
@@ -1165,18 +1165,18 @@ char *address_val(char *buf, char *end, const void *addr,
{
unsigned long long num;

- spec.flags |= SPECIAL | SMALL | ZEROPAD;
+ spec.flags |= SMALL | ZEROPAD;
spec.base = 16;

switch (fmt[1]) {
case 'd':
num = *(const dma_addr_t *)addr;
- spec.field_width = sizeof(dma_addr_t) * 2 + 2;
+ spec.field_width = sizeof(dma_addr_t) * 2;
break;
case 'p':
default:
num = *(const phys_addr_t *)addr;
- spec.field_width = sizeof(phys_addr_t) * 2 + 2;
+ spec.field_width = sizeof(phys_addr_t) * 2;
break;
}

@@ -1259,7 +1259,7 @@ static noinline_for_stack
char *pointer(const char *fmt, char *buf, char *end, void *ptr,
struct printf_spec spec)
{
- int default_width = 2 * sizeof(void *) + (spec.flags & SPECIAL ? 2 : 0);
+ int default_width = 2 * sizeof(void *);

if (!ptr && *fmt != 'K') {
/*



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/