Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 May 2005 19:39:20 +0000 (GMT)
From:      wpaul@FreeBSD.ORG (Bill Paul)
To:        bde@zeta.org.au (Bruce Evans)
Cc:        delphij@frontfree.net
Subject:   Re: [current tinderbox] failure on amd64/amd64
Message-ID:  <20050505193920.2120B16A4CF@hub.freebsd.org>
In-Reply-To: <20050506021433.W4828@epsplex.bde.org> from Bruce Evans at "May 6, 2005 02:21:18 am"

next in thread | previous in thread | raw e-mail | index | archive | help
> On Thu, 5 May 2005, Bill Paul wrote:
> 
> >> On Thu, 5 May 2005, Xin LI wrote:
> >>
> >>> On Thu, May 05, 2005 at 04:44:28AM -0400, FreeBSD Tinderbox wrote:
> >>>> /tinderbox/CURRENT/amd64/amd64/src/sys/modules/ndis/../../compat/ndis/subr_ndis.c: In function `NdisMFreeSharedMemory':
> >>>> /tinderbox/CURRENT/amd64/amd64/src/sys/modules/ndis/../../compat/ndis/subr_ndis.c:1710: warning: long long unsigned int format, uint64_t arg (arg 3)
> >>>
> >>> Maybe we should make use of the PRIx64 macro?  (see patch attached)
> >>
> >> No.  PRI* is a bug in C99; it should never be used.  Just cast the arg to
> >> a suitable larger type with a known format (uintmax_t here).  (C99 is
> >> missing support for better ways; either %I as in sfio (?) or %DWIM where
> >> the compiler rewrites the string to match the arg would be better.)
> >
> > I think what you really meant to say was:
> >
> > "Use %jx instead of %qx."
> >
> > Am I right?
> 
> No, the arg must match the format.  %jx matches uintmax_t, but the arg has
> type uint64_t.  uint64_t just happens to be the same as uintmax_t on all
> supported machines, so using %jx without casting the arg to match gives a
> latent bug.
> 
> Bruce

So what you really, _really_ meant to say was:

"Cast the argument to uintmax_t _and_ use %jx instead of %qx."

Am I right?

-Bill

--
=============================================================================
-Bill Paul            (510) 749-2329 | Senior Engineer, Master of Unix-Fu
                 wpaul@windriver.com | Wind River Systems
=============================================================================
              <adamw> you're just BEGGING to face the moose
=============================================================================



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