[PATCH] Remove extra 0x in the %p formatting string

Timur I. Bakeyev timur at freebsd.org
Wed May 16 19:59:54 UTC 2018


On 16 May 2018 at 18:18, Franz Sirl <Franz.Sirl-kernel at lauterbach.com>
wrote:

>
> Note that %p is not portable, for example Solaris 10/11 don't prefix 0x to
> the value. And glibc prints "(nil)" for a NULL-pointer.
>

I believe that %p is in the ANSI C standard. Solaris with it's own very
special C compiler.. Unfortunately, standard doesn't really define, how the
pointer should look like. Hence lack of 0x in some implementations and
(nil). As for the last one, I believe that

    buffer is: (nil)

still looks better than:

   buffer is: 0x(nil)

If we want even more portability we may employ PRIxPTR macro from
stdint.h/inttypes.h(which didn't present in Solaris 2.8 at least :>) and
cast to uintptr_t. But not sure we need such a complications.

With regards,
Timur Bakeyev.


More information about the samba-technical mailing list