Fix return timeout of fp_get_next_timeout

On function fp_get_next_timeout if exist fprint timeout or libusb
timeout the function return the smaller of they.

But if one of that not exist and have a smaller value the function
return a timeout that not exist.
This commit is contained in:
Sergio Cerlesi 2011-02-16 09:34:55 +01:00 committed by Bastien Nocera
parent aab031ce37
commit 3dd905d4e9

View file

@ -270,6 +270,14 @@ API_EXPORTED int fp_get_next_timeout(struct timeval *tv)
if (r_fprint == 0 && r_libusb == 0)
return 0;
/* if fprint have no pending timeouts return libusb timeout */
else if (r_fprint == 0)
*tv = libusb_timeout;
/* if libusb have no pending timeouts return fprint timeout */
else if (r_libusb == 0)
*tv = fprint_timeout;
/* otherwise return the smaller of the 2 timeouts */
else if (timercmp(&fprint_timeout, &libusb_timeout, <))
*tv = fprint_timeout;