From owner-svn-src-head@FreeBSD.ORG Wed Aug 7 04:18:15 2013 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 3DBA6CD2; Wed, 7 Aug 2013 04:18:15 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id E495324E7; Wed, 7 Aug 2013 04:18:14 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id 56ABB3C311D; Wed, 7 Aug 2013 14:17:44 +1000 (EST) Date: Wed, 7 Aug 2013 14:17:35 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Hiroki Sato Subject: Re: svn commit: r253995 - in head/usr.sbin: rtadvd rtsold In-Reply-To: <20130807.023507.62577067127422432.hrs@allbsd.org> Message-ID: <20130807135707.D1390@besplex.bde.org> References: <201308061549.r76FnImt054058@svn.freebsd.org> <1375807689.3320.48.camel@revolution.hippie.lan> <20130807.023507.62577067127422432.hrs@allbsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=Yos2GeoX c=1 sm=1 tr=0 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 a=PO7r1zJSAAAA:8 a=GK8lxtAv8-QA:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=vvS4_d6FUmMA:10 a=6I5d2MoRAAAA:8 a=7mwgwrTu0o20uq4M6eIA:9 a=IseOFbTV6ZHPFK9c:21 a=CPrBP7CiaCtwgbpz:21 a=CjuIK1q_8ugA:10 a=SV7veod9ZcQA:10 Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, ian@FreeBSD.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2013 04:18:15 -0000 On Wed, 7 Aug 2013, Hiroki Sato wrote: > Ian Lepore 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. After the change to monotonic times, the max time in seconds can't be more than a few million. 1 non-leap year = 31.536 million seconds. This is not quite enough for anyone, so use LONG_MAX > 2147 million to work for 68 years. Thus all uses of intmax_t are bogus, and even all uses of long are unnecessary, since they are only needed to support systems with < 32-bit ints. but no such systems are supported. The change to monotonic times gave lots of style bugs. Mainly expansion of lines beyond 80 columns by large ugly code. In the above, the lines with the complicated expressions for the maximums became too long. Bruce