]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
sysfs: fix bugs in new sysfs_wait function.
authorNeilBrown <neilb@suse.de>
Tue, 2 Jul 2013 06:08:34 +0000 (16:08 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 2 Jul 2013 06:08:34 +0000 (16:08 +1000)
- 'tv' isn't initialised properly.
- 100?  I'm sure I fixed that already! Seems not.

Signed-off-by: NeilBrown <neilb@suse.de>
sysfs.c

diff --git a/sysfs.c b/sysfs.c
index 19d56aa939afc5f58a8104ebcc1bde2e3acc27ad..13558c5fd0516e1c4a19f355a77f5df62b57e924 100644 (file)
--- 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;
 }