Date: Wed, 07 Aug 2013 02:35:07 +0900 (JST) From: Hiroki Sato <hrs@FreeBSD.org> To: ian@FreeBSD.org Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r253995 - in head/usr.sbin: rtadvd rtsold Message-ID: <20130807.023507.62577067127422432.hrs@allbsd.org> In-Reply-To: <1375807689.3320.48.camel@revolution.hippie.lan> References: <201308061549.r76FnImt054058@svn.freebsd.org> <1375807689.3320.48.camel@revolution.hippie.lan>
next in thread | previous in thread | raw e-mail | index | archive | help
----Security_Multipart(Wed_Aug__7_02_35_07_2013_872)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ian Lepore <ian@FreeBSD.org> wrote in <1375807689.3320.48.camel@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 ----Security_Multipart(Wed_Aug__7_02_35_07_2013_872)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (FreeBSD) iEYEABECAAYFAlIBM8sACgkQTyzT2CeTzy1HjwCgm7MxBuKwjGFoNeTDkxEzbAJZ mHgAmgM0ejxJFGsS8Wbd4EPfa4Omkeai =n77k -----END PGP SIGNATURE----- ----Security_Multipart(Wed_Aug__7_02_35_07_2013_872)----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130807.023507.62577067127422432.hrs>