From owner-cvs-all Mon Jul 30 16:34: 1 2001 Delivered-To: cvs-all@freebsd.org Received: from dragon.nuxi.com (trang.nuxi.com [206.40.252.115]) by hub.freebsd.org (Postfix) with ESMTP id D534337B403; Mon, 30 Jul 2001 16:33:55 -0700 (PDT) (envelope-from obrien@NUXI.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.11.4/8.11.1) id f6UNWYQ83800; Mon, 30 Jul 2001 16:32:34 -0700 (PDT) (envelope-from obrien) Date: Mon, 30 Jul 2001 16:31:12 -0700 From: "David O'Brien" To: John Baldwin Cc: Garrett Wollman , 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> Reply-To: obrien@FreeBSD.org References: <200107301811.f6UIB1J00180@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from jhb@FreeBSD.org on Mon, Jul 30, 2001 at 11:20:17AM -0700 X-Operating-System: FreeBSD 5.0-CURRENT Organization: The NUXI BSD group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 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 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