mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
time-util: make usleep_safe() return earlier if 0 is passed
This commit is contained in:
parent
06cfce8671
commit
97df9fa065
|
@ -219,6 +219,9 @@ static inline int usleep_safe(usec_t usec) {
|
|||
* ⚠️ Note we are not using plain nanosleep() here, since that operates on CLOCK_REALTIME, not
|
||||
* CLOCK_MONOTONIC! */
|
||||
|
||||
if (usec == 0)
|
||||
return 0;
|
||||
|
||||
// FIXME: use RET_NERRNO() macro here. Currently, this header cannot include errno-util.h.
|
||||
return clock_nanosleep(CLOCK_MONOTONIC, 0, TIMESPEC_STORE(usec), NULL) < 0 ? -errno : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue