svn commit: r253995 - in head/usr.sbin: rtadvd rtsold

Hiroki Sato hrs at FreeBSD.org
Tue Aug 6 17:35:41 UTC 2013


Ian Lepore <ian at FreeBSD.org> wrote
  in <1375807689.3320.48.camel at revolution.hippie.lan>:

ia> On Tue, 2013-08-06 at 15:49 +0000, Hiroki Sato wrote:
ia> >  	/* Generate maximum time in timespec. */
ia> > -	memset(&tm_max.tv_sec, 0xff, sizeof(tm_max.tv_sec));
ia> > -	memset(&tm_max.tv_nsec, 0xff, sizeof(tm_max.tv_nsec));
ia> > -	tm_max.tv_sec &= ~(1UL << (sizeof(tm_max.tv_sec) * 8 - 1));
ia> > -	tm_max.tv_nsec &= ~(1UL << (sizeof(tm_max.tv_nsec) * 8 - 1));
ia> > +	tm_max.tv_sec = (-1) & ~((time_t)1 << ((sizeof(tm_max.tv_sec) * 8) - 1));
ia> > +	tm_max.tv_nsec = (-1) & ~((long)1 << ((sizeof(tm_max.tv_nsec) * 8) - 1));
ia> >
ia> >  	/* set log level */
ia> >  	if (dflag > 1)
ia>
ia> The maximum number of nsec is 999999999 regardless of the type of
ia> tv_nsec.
ia>
ia> That expression for max time_t sure is ugly, but I can't think of
ia> anything that isn't just differently-ugly.  At least the comment makes
ia> the purpose clear.

 This was defined as {0x7fffffff, 0x7fffffff} in the original code and
 used just as a large enough value to make a conditional (tm_max >
 tm_other) be always true, not the exact maximum value.  Yes, this is
 ugly and can be improved.

-- Hiroki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20130807/562a197f/attachment.sig>


More information about the svn-src-all mailing list