Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2001 16:31:12 -0700
From:      "David O'Brien" <obrien@FreeBSD.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.sbin/newsyslog Makefile newsyslog.c
Message-ID:  <20010730163112.A83693@dragon.nuxi.com>
In-Reply-To: <XFMail.010730112017.jhb@FreeBSD.org>; from jhb@FreeBSD.org on Mon, Jul 30, 2001 at 11:20:17AM -0700
References:  <200107301811.f6UIB1J00180@khavrinen.lcs.mit.edu> <XFMail.010730112017.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 30, 2001 at 11:20:17AM -0700, John Baldwin wrote:
> > It looks like someone cut-and-pasted my canonical `parse an integer
> > correctly' code into a new function where the results were not used
> > carefully.  It would be an error to use `strtol' to parse a number
> > which is not supposed to be negative.
...
> Not to mention, the code in question doesn't check to see if strtoul()
> failed (it doesnt' check to see what the 't' var points to) which it
> would do for a negative number, yes?

It does check.  strtoul() is documented to return INT_MAX and set errno
in the negative input case.  The code exits if the value from strtoul()
is > N (where N is a very small number).  Thus the return value from
strtoul() is checked for validity.  A problem with negative input is not
distinguished between invalid positive input.

> If you want to stick with strtoul() (which is fine) then I think the
> other vars should be unsigned rather than adding band-aid casts.

They'll need casts to.  We cannot get away from the int(signed) nature of
the members of `struct tm'.
 
-- 
-- David  (obrien@FreeBSD.org)

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?20010730163112.A83693>