summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2021-07-02 17:16:21 +0000
committercheloha <cheloha@cvs.openbsd.org>2021-07-02 17:16:21 +0000
commit18edd7611c6b7d48c6d999f20b0cdde1d6a9e062 (patch)
treec2c72a0ad1f808425f2d6d95da0c90019dab0261 /lib/libc/gen
parent259ec9d4995476169c9196936f8ca007bbb4c0e1 (diff)
usleep(3): always call nanosleep(2)
usleep(3) is a wrapper around nanosleep(2). We should always call nanosleep(), even if the input is zero. This makes behavior easier to reason about and ensures we get a nanosleep() ktrace hit if a program calls usleep(). ok millert@
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/usleep.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c
index 5e2c51464ea..a0c431a83be 100644
--- a/lib/libc/gen/usleep.c
+++ b/lib/libc/gen/usleep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usleep.c,v 1.10 2005/08/08 08:05:34 espie Exp $ */
+/* $OpenBSD: usleep.c,v 1.11 2021/07/02 17:16:20 cheloha Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,11 +37,8 @@ usleep(useconds_t useconds)
{
struct timespec rqt;
- if (useconds == 0)
- return(0);
-
rqt.tv_sec = useconds / 1000000;
rqt.tv_nsec = (useconds % 1000000) * 1000;
- return(nanosleep(&rqt, NULL));
+ return nanosleep(&rqt, NULL);
}