Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Mar 2001 21:14:20 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        alpha@FreeBSD.org, cvs-committers@FreeBSD.org
Subject:   RE: cvs commit: src/sys/alpha/alpha busdma_machdep.c
Message-ID:  <Pine.BSF.4.21.0103062039590.9987-100000@besplex.bde.org>
In-Reply-To: <XFMail.010305210515.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 5 Mar 2001, John Baldwin wrote:

> On 06-Mar-01 John Baldwin wrote:
> > jhb         2001/03/05 18:52:08 PST
> > 
> >   Modified files:
> >     sys/alpha/alpha      busdma_machdep.c 
> >   Log:
> >   Quiet a warning due to bus_size_t being a long on the alpha.
> 
> Should this use '%p' instead of '0x%lx' perhaps?

No.  bus_size_t happens to be an (unsigned) integral type and probably
should be documented as such (I think bus sizes tend to be small, so
there will never be problems representing them as integers, at least
if there is a 64-bit integral type).

Printing bus_addr_t's correctly is harder.  Bus addresses might need
to be represented by arrays or structs.

0x%lx format should never be used.  Use %#lx instead.  Only give the
0x prefix explicitly if you really want small values to be harder to
read.  I think you would only want this tables with %0*x formats.

Perhaps %#llx format should be used.  bus_size_t is opaque, but you
have to know that it is no larger than long to print it using %#lx
format.

Perhaps the value should be cast to the type that matches the format.
bus_size_t is opaque, but you have to know that it is u_long to print
it using %#lx format.  The advantage of this is that it will keep
working without warnings if bus_size_t or u_long is changed, provided
the values that actually occur can be represented by both bus_size_t
and u_long.  The disadvantage of this is that it breaks compile-time
checking that the arg type matches the format.

I usually print typedefed types by converting to [unsigned] long and
print using an [unsigned] long format, but machine-dependent code
can reasonably know the typedef.  When C99 becomes normal, I will
usually convert to [u]intmax_t and print using a %j format.

Bruce


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0103062039590.9987-100000>