summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-10-17 13:13:42 -0400
committerDave Barach <dave@barachs.net>2017-10-17 15:19:22 -0400
commitb9f2cf0bff89ccf5c88072213a25efb65fb5516e (patch)
tree1f34f55543b5dfeaf5edd199ca7587121188534a /src/vppinfra
parenta3db0782d4c069733fa2e3ac1763efd4499b1de7 (diff)
VPP-1032: fix coverity warnings
Change-Id: Ic3a0c51e5408921051deaf2e50372d9654574b27 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/time.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/vppinfra/time.h b/src/vppinfra/time.h
index 3fdc7d43ea8..288922d8a83 100644
--- a/src/vppinfra/time.h
+++ b/src/vppinfra/time.h
@@ -263,10 +263,12 @@ unix_usage_now (void)
always_inline void
unix_sleep (f64 dt)
{
- struct timespec t;
- t.tv_sec = dt;
- t.tv_nsec = 1e9 * dt;
- nanosleep (&t, 0);
+ struct timespec ts, tsrem;
+ ts.tv_sec = dt;
+ ts.tv_nsec = 1e9 * (dt - (f64) ts.tv_sec);
+
+ while (nanosleep (&ts, &tsrem) < 0)
+ ts = tsrem;
}
#else /* ! CLIB_UNIX */