Date: Mon, 11 Mar 2019 10:41:38 +0000 From: Alexey Dokuchaev <danfe@freebsd.org> To: Bruce Evans <brde@optusnet.com.au> Cc: Justin Hibbits <chmeeedalf@gmail.com>, Justin Hibbits <jhibbits@freebsd.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r344960 - head/sys/powerpc/powerpc Message-ID: <20190311104138.GA60526@FreeBSD.org> In-Reply-To: <20190311191740.J2090@besplex.bde.org> References: <201903090318.x293IcLc023548@repo.freebsd.org> <20190309085058.GA60945@FreeBSD.org> <20190310171640.31bb9c54@titan.knownspace> <20190311191740.J2090@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 11, 2019 at 08:18:01PM +1100, Bruce Evans wrote: > ... > - poor formatting from %p. %p is guaranteed to bad for formatted output. > It is specified to give an (any) implementation-defined sequence of > printing characters. To use it except for low quality debugging > output, not quite as above (the above attempts medium quality, with > some alignment of fields but no attention to field widths for number > values), you first have to know what the implementation defines, > then don't use it when it is unsuitable. It is easiest to never use > it. In FreeBSD, printf(3) documents its format as being as if it > is %#x or %#lx. This gives no control over the field width. Yeah, this had annoyed me before, I recall some utilities suffer from broken formatting because of %p. > Conversion of pointers to uintmax_t or intmax_t gives full control > over the format, just like for converted integer types. This is not > quite easier and clearer for pointers. 3 casts are needed to go from > an arbitrary pointer to a uintmax_t. First to const volatile void * > (not to plain void *, since that gives cast-qual warnings if the > pointer is const or volatile). Then to uintptr_t. Then to uintmax_t. Thanks for the insight Bruce. ./danfe
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190311104138.GA60526>