[Dnsmasq-discuss] Patch: Add --ping-timeout option

Matthias Andree matthias.andree at gmx.de
Wed May 16 20:00:32 BST 2012

What is the purpose of casting stuff to float type explicitly (see
quoted part below)?

difftime() returns double, so the comparison arguments will be
type-promoted to "double" anyways, no matter if you provide float, or
integer.  (This applies equally to the original code, not just the new

Regarding the option numbering in src/option.c, I'd propose to go with
enum rather than #define.  Doing so exposes the symbols in debuggers.

> --- a/src/dnsmasq.c
> +++ b/src/dnsmasq.c
> @@ -1486,7 +1486,7 @@ int icmp_ping(struct in_addr addr)
>  	 retry_send());
>    for (now = start = dnsmasq_time();
> -       difftime(now, start) < (float)PING_WAIT;)
> +       difftime(now, start) < (daemon->ping_timeout*2/1000.0f);)
>      {
>        struct timeval tv;
>        fd_set rset, wset;

More information about the Dnsmasq-discuss mailing list