From 4bffc964b9e4c91877d1a863b06cab4748732b15 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 2 Jul 2013 16:08:34 +1000 Subject: [PATCH] sysfs: fix bugs in new sysfs_wait function. - 'tv' isn't initialised properly. - 100? I'm sure I fixed that already! Seems not. Signed-off-by: NeilBrown --- sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sysfs.c b/sysfs.c index 19d56aa..13558c5 100644 --- a/sysfs.c +++ b/sysfs.c @@ -904,15 +904,18 @@ int sysfs_wait(int fd, int *msec) else { struct timeval start, end, tv; gettimeofday(&start, NULL); - if (*msec < 1000) + if (*msec < 1000) { + tv.tv_sec = 0; tv.tv_usec = (*msec)*1000; - else + } else { tv.tv_sec = (*msec)/1000; + tv.tv_usec = 0; + } n = select(fd+1, NULL, NULL, &fds, &tv); gettimeofday(&end, NULL); end.tv_sec -= start.tv_sec; *msec -= (end.tv_sec * 1000 + end.tv_usec/1000 - - start.tv_usec/100) + 1; + - start.tv_usec/1000) + 1; } return n; }