hostapd timercmp() misusage?
Jouni Malinen
jkmaline
Thu Oct 30 18:53:14 PST 2003
On Thu, Oct 30, 2003 at 12:23:19PM -0800, Mark Glines wrote:
> I just noticed that a couple places in hostapd that use timercmp() use
> ">=" as the operator, but my sys/time.h says:
>
> /* Convenience macros for operations on timevals.
> NOTE: `timercmp' does not work for >= or <=. */
Would you happen to have any examples of cases that would not work? I
have the same comment in the header file, but the implementation looks
correct even for >= and <=.. Anyway, better be safe than sorry, so I did
change these in eloop.c.
> - if (timercmp(&now, &eloop.timeout->time, >=))
> + if (timercmp(&eloop.timeout->time, &now, <))
That is not correct.. timercmp(a, b, >=) is equal to !timercmp(a, b, <)
(well, assuming >= would be supported operator). Your change breaks
expected behavior if the timevals happen to be equal. Not that this
would affect anything in the first case in eloop.c and even with the
second case, the difference is quite minimal.
--
Jouni Malinen PGP id EFC895FA
More information about the Hostap
mailing list