bin/71616: [PATCH] cleanup of the usr.sbin/yp_mkdb code

Brooks Davis brooks at one-eyed-alien.net
Mon Sep 13 08:46:19 PDT 2004


On Mon, Sep 13, 2004 at 06:10:26AM +0000, Giorgos Keramidas wrote:
> The following reply was made to PR bin/71616; it has been noted by GNATS.
> 
> From: Giorgos Keramidas <keramida at freebsd.org>
> To: Brooks Davis <brooks at one-eyed-alien.net>
> Cc: bug-followup at freebsd.org
> Subject: Re: bin/71616: [PATCH] cleanup of the usr.sbin/yp_mkdb code
> Date: Mon, 13 Sep 2004 09:05:27 +0300
> 
>  On 2004-09-12 16:40, Brooks Davis <brooks at one-eyed-alien.net> wrote:
>  > On Sun, Sep 12, 2004 at 08:10:55PM +0000, Giorgos Keramidas wrote:
>  > >  On 2004-09-12 04:37, Dan Lukes <dan at obluda.cz> wrote:
>  > >  > *** usr.sbin/yp_mkdb/yp_mkdb.c.ORIG	Sun Sep  5 18:54:07 2004
>  > >  > --- usr.sbin/yp_mkdb/yp_mkdb.c	Sun Sep  5 19:01:20 2004
>  > >  > [...]
>  > >  > - 	snprintf(buf, sizeof(buf), "%lu", time(NULL));
>  > >  > + 	snprintf(buf, sizeof(buf), "%lu", (long unsigned int)time(NULL));
>  > >
>  > >  Just a minor comment: An (unsigned long) cast should be fine here.
>  >
>  > Using unsigned here is actually bogus. time_t is a signed type
>  > in FreeBSD.  SUSv3 says "time_t and clock_t shall be integer or
>  > real-floating types."  In FreeBSD a cast an integer type is safe.
>  >
>  > Either long or intmax_t are decent choices today.
>  
>  Hmmm, true.  I had forgotten about negative values of time_t that represent
>  dates before 1970.
>  
>  Thanks :)

SUS doesn't seem to require this, but in practice it's safe even if
time_t is unsigned (the year 2.92E11 bug isn't something I'm going to
worry about :-) and ours is signed.

-- Brooks

-- 
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-bugs/attachments/20040913/70cdd313/attachment.bin


More information about the freebsd-bugs mailing list