Return-Path: MIME-Version: 1.0 In-Reply-To: <1394011361-9469-2-git-send-email-lukasz.rymanowski@tieto.com> References: <1394011361-9469-1-git-send-email-lukasz.rymanowski@tieto.com> <1394011361-9469-2-git-send-email-lukasz.rymanowski@tieto.com> Date: Wed, 5 Mar 2014 09:39:18 -0400 Message-ID: Subject: Re: [PATCH v2 2/5] monitor: Use miliseconds instead of seconds in the timeout From: Anderson Lizardo To: Lukasz Rymanowski Cc: BlueZ development Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Lukasz, On Wed, Mar 5, 2014 at 5:22 AM, Lukasz Rymanowski 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