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 <neilb@suse.de>
This commit is contained in:
NeilBrown 2013-07-02 16:08:34 +10:00
parent 71556ff9ac
commit 4bffc964b9
1 changed files with 6 additions and 3 deletions

View File

@ -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;
}