summaryrefslogtreecommitdiffstats
path: root/tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools.c b/tools.c
index 8fce755..4105597 100644
--- a/tools.c
+++ b/tools.c
@@ -332,9 +332,11 @@ int pcilib_sleep_until_deadline(struct timeval *tv) {
pcilib_timeout_t duration;
duration = pcilib_calc_time_to_deadline(tv);
- wait.tv_sec = duration / 1000000;
- wait.tv_nsec = 1000 * (duration % 1000000);
- nanosleep(&wait, NULL);
+ if (duration > 0) {
+ wait.tv_sec = duration / 1000000;
+ wait.tv_nsec = 1000 * (duration % 1000000);
+ nanosleep(&wait, NULL);
+ }
return 0;
}