Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 03 Nov 2012 12:50:32 -0700
From:      Xin Li <delphij@delphij.net>
To:        Ian Lepore <freebsd@damnhippie.dyndns.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Xin LI <delphij@freebsd.org>
Subject:   Re: svn commit: r242519 - head/usr.sbin/watchdogd
Message-ID:  <50957588.5070504@delphij.net>
In-Reply-To: <1351968359.1120.106.camel@revolution.hippie.lan>
References:  <201211031838.qA3IcSUR021854@svn.freebsd.org> <1351968359.1120.106.camel@revolution.hippie.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
-----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
>> 
>> Log: Replace log(3) with flsll(3) for watchdogd(8) and drop libm
>> dependency.
>> 
>> MFC after:	2 weeks
>> 
>> Modified: head/usr.sbin/watchdogd/Makefile 
>> head/usr.sbin/watchdogd/watchdogd.c
>> 
>> Modified: head/usr.sbin/watchdogd/Makefile 
>> ==============================================================================
>>
>> 
- --- head/usr.sbin/watchdogd/Makefile	Sat Nov  3 18:21:32 2012	(r242518)
>> +++ head/usr.sbin/watchdogd/Makefile	Sat Nov  3 18:38:28 2012
>> (r242519) @@ -4,8 +4,8 @@ PROG=	watchdogd LINKS=
>> ${BINDIR}/watchdogd ${BINDIR}/watchdog MAN=	watchdogd.8
>> watchdog.8
>> 
>> -LDADD=	-lm -lutil -DPADD=	${LIBM} ${LIBUTIL} +LDADD=	-lutil 
>> +DPADD=	${LIBUTIL}
>> 
>> .include <bsd.prog.mk>
>> 
>> 
>> Modified: head/usr.sbin/watchdogd/watchdogd.c 
>> ==============================================================================
>>
>> 
- --- head/usr.sbin/watchdogd/watchdogd.c	Sat Nov  3 18:21:32 2012	(r242518)
>> +++ head/usr.sbin/watchdogd/watchdogd.c	Sat Nov  3 18:38:28 2012
>> (r242519) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include
>> <stdio.h> #include <stdlib.h> #include <string.h> +#include
>> <strings.h> #include <sysexits.h> #include <unistd.h>
>> 
>> @@ -280,7 +281,7 @@ parseargs(int argc, char *argv[]) if (a ==
>> 0) timeout = WD_TO_NEVER; else -				timeout = 1.0 + log(a * 1e9)
>> / log(2.0); +				timeout = flsll(a * 1e9); if (debugging) 
>> printf("Timeout is 2^%d nanoseconds\n", timeout);
> 
> 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 <bsd.prog.mk>

 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)


Cheers,
-----BEGIN PGP SIGNATURE-----

iQEcBAEBCAAGBQJQlXWIAAoJEG80Jeu8UPuzKiwIAMGknRDKiXIWLBL86ABfOZVU
EkuT7u4S90hAlAyWdropISadgReRF3yenYPGM9oCHtoLLS5Ma2iLd8tMFqv76uxo
0nyqY7HpKRBcYfurYcVTcckrphQdD4DbviRPgBPsZ6/ClHN8Bkjc2Am6zSbzwM5C
XZTNicX5/M4IqArYg5L8j3Z4WLo3HIG/oo1OMU+hP+vJT9vBIWK8ap9n3ajNz15p
OjKNZXs88X0OaeqhO0Ayn2lGIxkDQ6OszYHi6UUQ7p1m3Op4ewx/SlrgEhDpzBY2
l643UHj/6IUfLUvahp1m82FEKelFYleoZ02scpgu951+che3+t03z9NFUFjl/OA=
=UN3H
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50957588.5070504>