From owner-cvs-all Fri Feb 8 11:10:17 2002 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 6C33337B400; Fri, 8 Feb 2002 11:10:04 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id GAA24402; Sat, 9 Feb 2002 06:09:55 +1100 Date: Sat, 9 Feb 2002 06:12:34 +1100 (EST) From: Bruce Evans X-X-Sender: To: David Malone Cc: Peter Wemm , , Subject: Re: cvs commit: src/usr.bin/finger lprint.c In-Reply-To: <20020208101150.GA74534@walton.maths.tcd.ie> Message-ID: <20020209060237.U776-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 8 Feb 2002, David Malone wrote: > On Thu, Feb 07, 2002 at 11:52:52PM -0800, Peter Wemm wrote: > > peter 2002/02/07 23:52:52 PST > > > > Modified files: > > usr.bin/finger lprint.c > > Log: > > GRR. Unbreak WARNS=2. > > cc1: warnings being treated as errors > > usr.bin/finger/lprint.c: In function `lprint': > > usr.bin/finger/lprint.c:191: warning: precision is not type int (arg 2) > > *** Error code 1 > > Was it a header file change which caused this? I'm pretty sure it > compiled when I last committed to it. (Or maybe bug you only see > on the alpha). Yes, the bug is only detected on machines where size_t is larger than int. The precision is given by the expression: maxlen - strlen(w->tty) + 1 Here maxlen has type int and strlen() has type size_t. size_t is normally no larger than int, so the type of max_len is normally promoted to the type of strlen() in the binary operation '-' instead of vice versa, and the expression has type size_t. gcc should probably warn about mixing signed variables with unsigned variables like this, but it doesn't. gcc should warn that the precision is not of type int on 386's too (precision has type size_t == unsigned), but it doesn't. Thus the bug is only detected if size_t is larger than int. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message