Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Feb 2002 06:12:34 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        David Malone <dwmalone@maths.tcd.ie>
Cc:        Peter Wemm <peter@FreeBSD.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org>
Subject:   Re: cvs commit: src/usr.bin/finger lprint.c
Message-ID:  <20020209060237.U776-100000@gamplex.bde.org>
In-Reply-To: <20020208101150.GA74534@walton.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help
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




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