From owner-svn-src-head@FreeBSD.ORG Mon Jul 2 07:51:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F1961065670; Mon, 2 Jul 2012 07:51:11 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx07.syd.optusnet.com.au (fallbackmx07.syd.optusnet.com.au [211.29.132.9]) by mx1.freebsd.org (Postfix) with ESMTP id 214F48FC1F; Mon, 2 Jul 2012 07:51:10 +0000 (UTC) Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au [211.29.132.182]) by fallbackmx07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q627p3qU008989; Mon, 2 Jul 2012 17:51:03 +1000 Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q627osdq031071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 2 Jul 2012 17:50:55 +1000 Date: Mon, 2 Jul 2012 17:50:53 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Xin LI In-Reply-To: <201207020238.q622cR4q038051@svn.freebsd.org> Message-ID: <20120702171933.I807@besplex.bde.org> References: <201207020238.q622cR4q038051@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237942 - head/sbin/ping X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 02 Jul 2012 07:51:11 -0000 On Mon, 2 Jul 2012, Xin LI wrote: > Log: > Use timeclear() instead of home grown version. > > MFC after: 2 weeks timerclear() is a NetBSD/OpenBSD compatibility mistake. It should at least have been named timevalclear(). (timevalclear() is the kernel name, and is intentionally left out of sys/time.h for !_KERNEL.) ping remains fairly portable by not using NetBSD/OpenBSD APIs for any other timeval access, despite most of the others taking longer to spell out than clearing. In .c files in /usr/src/*bin, the timerclear() mistake is only used in usr.bin/talk. The more useful timeradd() is only used in netstat (once), rtsold (thrice) and bsnpd (once). The even more useful timercmp() is used in pkill (once), routed (lots, but this is really contrib code), netstat (once), rtsold (lots) and bsnpd (lots). In .c files in /usr/src/contrib, timerclear() only used in ofed and pf. So these mistakes would be easy to avoid (except in ports). Mistakes for the timevalfoo() kernel API in userland are less common. For timevaladd(): - routed uses timevaladd() and supplies its own copy of the kernel code. This is approximately correct. It is portable, and the kernel version is hard to abuse since it is an extern function. Optimizing timevaladd() as a macro would be silly and is not done by either. The uglieness in routed is that it mixes this with timerfoo(). - ktrace. Like routed, except it copies the kernel code even more directly. (In the kernel and in ktrace, timevaladd() just adds then calls timevalfix() to handle wrap around. In routed, wrap around is handled directly. timeradd() handles wrap directly using a bloated macro. Another bug in the timeradd() API is that the macro is unsafe, but its name indicates that it is safe. Using extern functions avoids this bug for some of the timeval*() APIs.) - timed: like routed. Bruce