From owner-freebsd-arch@FreeBSD.ORG Sat Nov 15 05:04:01 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B272D16A4CE for ; Sat, 15 Nov 2003 05:04:01 -0800 (PST) Received: from gw.celabo.org (gw.celabo.org [208.42.49.153]) by mx1.FreeBSD.org (Postfix) with ESMTP id 80BD643FE3 for ; Sat, 15 Nov 2003 05:03:58 -0800 (PST) (envelope-from nectar@freebsd.org) Received: from localhost (localhost [127.0.0.1]) by gw.celabo.org (Postfix) with ESMTP id 0BD035489C; Sat, 15 Nov 2003 07:03:58 -0600 (CST) Received: from gw.celabo.org ([127.0.0.1]) by localhost (hellblazer.celabo.org [127.0.0.1]) (amavisd-new, port 10024) with SMTP id 08540-07; Sat, 15 Nov 2003 07:03:47 -0600 (CST) Received: from lum.celabo.org (dhcp-204.celabo.org [10.0.1.204]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "lum.celabo.org", Issuer "celabo.org CA" (verified OK)) by gw.celabo.org (Postfix) with ESMTP id 443F654883; Sat, 15 Nov 2003 07:03:47 -0600 (CST) Received: from freebsd.org (localhost [127.0.0.1]) by lum.celabo.org (Postfix) with ESMTP id 2DFC010902D; Sat, 15 Nov 2003 07:04:05 -0600 (CST) Message-ID: <3FB62444.9000102@freebsd.org> Date: Sat, 15 Nov 2003 07:04:04 -0600 From: Jacques Vidrine User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruce Evans References: <20031114194119.GA94198@madman.celabo.org> <20031115114906.L11453@gamplex.bde.org> <3FB5B258.6010207@freebsd.org> <20031115190419.G1478@gamplex.bde.org> In-Reply-To: <20031115190419.G1478@gamplex.bde.org> X-Enigmail-Version: 0.81.7.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-arch@FreeBSD.org Subject: Re: __TIME_MIN/__TIME_MAX X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Nov 2003 13:04:01 -0000 Bruce Evans said the following on 11/15/03 2:17 AM: > On Fri, 14 Nov 2003, Jacques Vidrine wrote: >> So this kind of thing OK? >> >> long n; >> time_t t; >> errno = 0; >> n = strtoul(...); >> if (errno == ERANGE || (long)(t = n) != n) >> /* out of range */; > > > Not quite like that. strtoul() returns an unsigned long whose value may > be lost by assigning it to a plain long. Mixtures of signed and unsigned > types are tricky to handle as usual. Suppose we make n unsigned long > and it has value ULONG_MAX, and time_t is long, then (t = n) == n, > but t doesn't actually represent n (casting (t = n) to long or unsigned > long doesn't help). So it seems to be necessary to be aware that time_t > is signed and either use strtol() initially or check that t >= 0 if > n is unsigned long. If time_t is actually signed then we may get a GCC > warning for this check... Doh, sorry, that's a typo. I meant strtol (which is what is currently used in the relevant portion of libc--- strptime.c, BTW). Negative values must be allowed here. Cheers, -- Jacques Vidrine NTT/Verio SME FreeBSD UNIX Heimdal nectar@celabo.org jvidrine@verio.net nectar@freebsd.org nectar@kth.se