From owner-svn-src-head@FreeBSD.ORG Sat Nov 3 20:16:58 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 8931A2FE; Sat, 3 Nov 2012 20:16:58 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from duck.symmetricom.us (duck.symmetricom.us [206.168.13.214]) by mx1.freebsd.org (Postfix) with ESMTP id 4DB348FC0C; Sat, 3 Nov 2012 20:16:52 +0000 (UTC) Received: from damnhippie.dyndns.org (daffy.symmetricom.us [206.168.13.218]) by duck.symmetricom.us (8.14.5/8.14.5) with ESMTP id qA3KGpi9040214; Sat, 3 Nov 2012 14:16:51 -0600 (MDT) (envelope-from freebsd@damnhippie.dyndns.org) Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id qA3KGTWF010204; Sat, 3 Nov 2012 14:16:29 -0600 (MDT) (envelope-from freebsd@damnhippie.dyndns.org) Subject: Re: svn commit: r242519 - head/usr.sbin/watchdogd From: Ian Lepore To: d@delphij.net In-Reply-To: <50957588.5070504@delphij.net> References: <201211031838.qA3IcSUR021854@svn.freebsd.org> <1351968359.1120.106.camel@revolution.hippie.lan> <50957588.5070504@delphij.net> Content-Type: text/plain; charset="us-ascii" Date: Sat, 03 Nov 2012 14:16:29 -0600 Message-ID: <1351973789.1120.122.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Xin LI 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: Sat, 03 Nov 2012 20:16:58 -0000 On Sat, 2012-11-03 at 12:50 -0700, Xin Li wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > On 11/3/12 11:45 AM, Ian Lepore wrote: > > On Sat, 2012-11-03 at 18:38 +0000, Xin LI wrote: > >> Author: delphij Date: Sat Nov 3 18:38:28 2012 New Revision: > >> 242519 URL: http://svn.freebsd.org/changeset/base/242519 > > [...] > > Shouldn't we also change the type of the variable 'a' from double > > to int64 (and the strtod() and the 1e9 constant), thus removing all > > dregs of floating point where it isn't really needed? (Sorry, but > > 20 years of working on wimpy embedded systems without FP hardware > > just make me blurt out these things automatically). > > While it do make sense in practical (in my opinion), I think that > would lose functionality because the watchdog can be programmed in a > manner that timeout is set to smaller than 1 second (not for the > demonized case). Maybe we can make it an build option? > > Index: Makefile > =================================================================== > - --- Makefile (revision 242519) > +++ Makefile (working copy) > @@ -7,7 +7,15 @@ MAN= watchdogd.8 watchdog.8 > LDADD= -lutil > DPADD= ${LIBUTIL} > > +.if defined(SMALL) > +CFLAGS+= -DSMALL > +.endif > + > .include > > test: ${PROG} > +.if defined(SMALL) > + ./${PROG} -t 1 > +.else > ./${PROG} -t 1.0 > +.endif > Index: watchdogd.c > =================================================================== > - --- watchdogd.c (revision 242519) > +++ watchdogd.c (working copy) > @@ -241,7 +241,11 @@ parseargs(int argc, char *argv[]) > { > int c; > char *p; > +#if defined(SMALL) > + long a; > +#else > double a; > +#endif > > c = strlen(argv[0]); > if (argv[0][c - 1] == 'd') > @@ -273,7 +277,11 @@ parseargs(int argc, char *argv[]) > case 't': > p = NULL; > errno = 0; > +#if defined(SMALL) > + a = strtol(optarg, &p, 0); > +#else > a = strtod(optarg, &p); > +#endif > if ((p != NULL && *p != '\0') || errno != 0) > errx(EX_USAGE, "-t argument is not a > number"); > if (a < 0) > Oh. I remembered that < WD_TO_1SEC check and somehow completely forgot the is_daemon part and its implication; I just thought timeouts of less than 1 second weren't allowed. It's hard for me to imagine someone setting the timeout to less than 1 second, but if that's been a supported feature all along then we should probably just leave things as-is. Getting libm out of the picture was the big win, the remaining FP code is a pretty small thing. -- Ian