[Libusbx-devel] libusbx-1.0.10-rc1 now available

Xiaofan Chen xiaofanc at gmail.com
Sat Apr 14 19:08:05 EDT 2012


On Sun, Apr 15, 2012 at 2:02 AM, Pete Batard <pete at akeo.ie> wrote:
> On 2012.04.14 10:25, Xiaofan Chen wrote:
>>
>> There are a few compiler warnings under Slackware 9.0
>> which is the first version of Slackware to have a gcc 3.x
>> version
>>
>> CC     libusb_1_0_la-linux_usbfs.lo
>> os/linux_usbfs.c: In function `find_monotonic_clock':
>> os/linux_usbfs.c:210: warning: unused variable `ts'
>> os/linux_usbfs.c:211: warning: unused variable `r'
>
> Unless Hans wants to take this on, I'm gonna say "too old,
> don't care, plus gcc is free and can be upgraded."
>
> As I stated, we have to set limits as to what we want to
> support, and Slack 9.0 is rather old.
>

I am okay with not fixing problems related to old
toolchain or old OS. But in this case, I believe you
did not even read the warning and the codes here.
It is quite obvious where the problem is.
The problem is that when CLOCK_MONOTONIC
is not available (even on newer Linux system which
targets embedded system), the two variables become
unused. The fix is to simply put the definition inside
the ifdef block.

I will get Peter to fix this.

/* the monotonic clock is not usable on all systems (e.g. embedded ones often
 * seem to lack it). fall back to REALTIME if we have to. */

static clockid_t find_monotonic_clock(void)
{
	struct timespec ts;
	int r;

#ifdef CLOCK_MONOTONIC
	/* Linux 2.6.28 adds CLOCK_MONOTONIC_RAW but we don't use it
	 * because it's not available through timerfd */
	r = clock_gettime(CLOCK_MONOTONIC, &ts);
	if (r == 0)
		return CLOCK_MONOTONIC;
	usbi_dbg("monotonic clock doesn't work, errno %d", errno);
#endif

	return CLOCK_REALTIME;
}

-- 
Xiaofan



More information about the libusbx mailing list