Date: Mon, 2 Jul 2012 17:50:53 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Xin LI <delphij@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237942 - head/sbin/ping Message-ID: <20120702171933.I807@besplex.bde.org> In-Reply-To: <201207020238.q622cR4q038051@svn.freebsd.org> References: <201207020238.q622cR4q038051@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120702171933.I807>