From owner-cvs-all@FreeBSD.ORG Thu Aug 7 05:59:44 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B2F537B401; Thu, 7 Aug 2003 05:59:44 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 62C5243F93; Thu, 7 Aug 2003 05:59:42 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3p2/8.8.7) with ESMTP id WAA05970; Thu, 7 Aug 2003 22:59:38 +1000 Date: Thu, 7 Aug 2003 22:59:35 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Hartmut Brandt In-Reply-To: <20030806162837.D622@beagle.fokus.fraunhofer.de> Message-ID: <20030807222014.B1480@gamplex.bde.org> References: <200308061130.h76BUrPt029894@repoman.freebsd.org> <20030806162837.D622@beagle.fokus.fraunhofer.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: Andrew Gallatin cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/dev/en midway.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2003 12:59:44 -0000 > On Wed, 6 Aug 2003, Andrew Gallatin wrote: > > AG>Hartmut Brandt [harti@FreeBSD.org] wrote: > AG>> harti 2003/08/06 04:30:53 PDT > AG>> > AG>> FreeBSD src repository > AG>> > AG>> Modified files: > AG>> sys/dev/en midway.c > AG>> Log: > AG>> Print an array index that is computed as ptrdiff_t with %tu. > AG> > AG>I don't understand why, but this breaks the sparc64 and alpha tinderboxes. > AG>See > AG>http://docs.freebsd.org/cgi/getmsg.cgi?fetch=574500+0+current/freebsd-current > > Not really. The breakage was earlier when the ptrdiff_t was printed via > %d. David O'Brien fixed that by converting to long and using %ld. The > above commit now uses the knowledge that the difference is actually an > array index and therefor uses %tu. The tinderbox log file seems to be from > yesterday before David's fix. It also uses the knowledge that the difference is non-negative. Why not just print the difference as it is using the natural format %td? This makes no difference if the, uhm, difference is non-negative, but avoids undefined behaviour if the difference is somehow negative. Printing -1 using %tu on i386's gives an interesting example of the undefined behaviour that results when a negative value is printed using an unsigned format. I expected the result UINT_MAX (2^32-1), but the actual result is UINTMAX_MAX (2^64-1). This is because the implementation represents numbers using "uintmax_t ujval" for the %tu and %td formats, so it represents -1 as UINTMAX_MAX, and then it just prints this value. Bruce