From owner-freebsd-alpha Tue Mar 6 2:14:41 2001 Delivered-To: freebsd-alpha@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 91AB037B718; Tue, 6 Mar 2001 02:14:35 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA07524; Tue, 6 Mar 2001 21:14:32 +1100 Date: Tue, 6 Mar 2001 21:14:20 +1100 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: John Baldwin Cc: alpha@FreeBSD.org, cvs-committers@FreeBSD.org Subject: RE: cvs commit: src/sys/alpha/alpha busdma_machdep.c In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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