Re: [PATCH v2 2/5] monitor: Use miliseconds instead of seconds in the timeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Lukasz,

On Wed, Mar 5, 2014 at 5:22 AM, Lukasz Rymanowski
<lukasz.rymanowski@xxxxxxxxx> wrote:
> -static inline int timeout_set(int fd, unsigned int seconds)
> +static inline int timeout_set(int fd, unsigned int msec)
>  {
>         struct itimerspec itimer;
> +       unsigned int sec = msec / 1000;
>
>         memset(&itimer, 0, sizeof(itimer));
>         itimer.it_interval.tv_sec = 0;
>         itimer.it_interval.tv_nsec = 0;
> -       itimer.it_value.tv_sec = seconds;
> -       itimer.it_value.tv_nsec = 0;
> +       itimer.it_value.tv_sec = sec;
> +       itimer.it_value.tv_nsec = (msec - (sec * 1000)) * 1000;

Would you not be multiplying by 1000000 (i.e. 10^6) instead?

Also, why not use:

itimer.it_value.tv_nsec = (msec % 1000) * 1000000;

>
>         return timerfd_settime(fd, 0, &itimer, NULL);
>  }

Best Regards,
-- 
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux