Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Sep 1998 23:52:16 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, gibbs@plutotech.com
Cc:        current@FreeBSD.ORG, Don.Lewis@tsc.tdk.com
Subject:   Re: New kernel compile warnings with CAM
Message-ID:  <199809161352.XAA07659@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help

>>%p requires a `void *' arg.

>What's the official policy here?  I used a cast of (intptr_t) in the
>changes I submitted, but if we should be using %p and (void *) instead,
>so be it.

Casts (to_intptr_t) require a `void *' operand (at least if you want
intptr_t to be guaranteed to not lose information and don't want
to see the raw bits in the pointer).  Also, the width of intptr_t is
machine-dependent.  This makes printing pointers by casting to (intptr_t)
even more onerous than printing them by casting to (void *), e.g.:

	struct foo *bar;

	printf("%?\n", (intptr_t)(void *)bar);

where '?' is a machine-dependent format suitable for intptr_t's.

%p should be used for pointers except possibly where you want complete
control of the format or want to see the raw bits in the pointer.
Anything that requires a cast should be avoided since casts defeat type
checking and may cause undetected overflow.  Unfortunately, %p usually
requires a cast.

Bruce

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809161352.XAA07659>