Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Oct 2002 15:40:55 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Marcel Moolenaar <marcel@FreeBSD.org>
Cc:        cvs-committers@FreeBSD.org, <cvs-all@FreeBSD.org>
Subject:   Re: cvs commit: src/sys/pci agp_amd.c
Message-ID:  <20021013151835.C21098-100000@gamplex.bde.org>
In-Reply-To: <200210122040.g9CKeatu097643@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 12 Oct 2002, Marcel Moolenaar wrote:

> marcel      2002/10/12 13:40:36 PDT
>
>   Modified files:
>     sys/pci              agp_amd.c
>   Log:
>   Make this compile on 64-bit architectures (e.g. ia64) by not assuming
>   pointers (but more precisely vm_offset_t) can be printed with %x. Use
>   %p instead and cast the argument to caddr_t.

This has more printf format errors than before:
- vm_offset_t is not a pointer.  It is a (typedefed) unsigned integral
  type, so it should be printed using %#lx or %#jx after casting it to
  u_long or uintmax_t.  vm_offset_t is unlikely to be larger than u_long
  on any reasonable machine, so using uintmax_t is normally just a
  pessimization.  Anyway, vm_offset_t's are usually printed using %lx
  elsewhere.
- vm_offset_t is cast to a pointer without going through intptr_t or
  uintptr_t.  This is only technically incorrect.  vm_offset_t is
  likely to be the same as uintptr_t in practice.
- caddr_t is not void *.  The behaviour of %p is undefined unless its
  arg has type void *.
- %p is a little broken in the kernel, so it gives output bug for bug
  compatible with %8x: it doesn't print an 0x prefix like it does in
  userland.  The kernel printf even does extra work for %#p to kill
  the prefix.

Bruce


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




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