Date: Sun, 29 Dec 2002 18:51:07 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Mike Barcroft <mike@FreeBSD.ORG> Cc: Matthew Dillon <dillon@apollo.backplane.com>, <current@FreeBSD.ORG>, <ia64@FreeBSD.ORG> Subject: Re: ia64 tinderbox failure Message-ID: <20021229184137.C40787-100000@gamplex.bde.org> In-Reply-To: <20021229004907.C98334@espresso.q9media.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 29 Dec 2002, Mike Barcroft wrote: > Peter Wemm <peter@freebsd.org> 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 <err.h> > #include <errno.h> > #include <fstab.h> > +#include <limits.h> > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > @@ -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-ia64" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021229184137.C40787-100000>