From owner-freebsd-current Sat Dec 28 23:49:20 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0576637B401; Sat, 28 Dec 2002 23:49:18 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id BCF7843E4A; Sat, 28 Dec 2002 23:49:16 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id SAA08162; Sun, 29 Dec 2002 18:49:13 +1100 Date: Sun, 29 Dec 2002 18:51:07 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Mike Barcroft Cc: Matthew Dillon , , Subject: Re: ia64 tinderbox failure In-Reply-To: <20021229004907.C98334@espresso.q9media.com> Message-ID: <20021229184137.C40787-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 29 Dec 2002, Mike Barcroft wrote: > Peter Wemm writes: > > ===> sbin/swapon > > cc1: warnings being treated as errors > > /home/tinderbox/ia64/src/sbin/swapon/swapon.c: In function `swaplist': > > /home/tinderbox/ia64/src/sbin/swapon/swapon.c:246: warning: field width is not type int (arg 3) > > ... > > *** Error code 1 > > Proposed fix: > > %%% > Index: swapon.c > =================================================================== > RCS file: /work/repo/src/sbin/swapon/swapon.c,v > retrieving revision 1.14 > diff -u -r1.14 swapon.c > --- swapon.c 28 Dec 2002 23:39:47 -0000 1.14 > +++ swapon.c 29 Dec 2002 05:53:17 -0000 > @@ -53,6 +53,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -210,8 +211,8 @@ > { > size_t mibsize, size; > struct xswdev xsw; > - int mib[16], n, pagesize; > - size_t hlen; > + int hlen, mib[16], n, pagesize; > + size_t hsize; > long blocksize; > long long total = 0; > long long used = 0; > @@ -229,7 +230,8 @@ > hlen = 10; > break; > default: > - getbsize(&hlen, &blocksize); > + getbsize(&hsize, &blocksize); > + hlen = MIN(INT_MAX, hsize); > break; > } > > %%% The correct fix is to unbreak getbsize() so that it takes an `int *' as its first arg like it used to. The interface change and the above change just give a header length that is not directly usably by any of its users. The header length is what must be passed to printf in %*s formats; it should have type int since that is what printf takes; any bounds checking of it belongs in getbsize() (but in practice it is a small positive number since anything else would give preposterous formatting, so there is never a problem with its bounds). Other users of getbsize() in the src tree but perhaps not ones in ports have been broken to match the interface breakage. The usual breakage is to cast the size_t to int without checking bounds. > BTW, the tabbing in this area of the source file is messed up. indent(1) with my .indent.pro does a fairly good job of fixing these without introducing more bugs. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message