From: Yu Watanabe Date: Tue, 19 Dec 2023 15:48:49 +0000 (+0900) Subject: time-util: make usleep_safe() return earlier if 0 is passed X-Git-Tag: v256-rc1~1455^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97df9fa065767cbedadd144b0e1b193a95e7ffbd;p=thirdparty%2Fsystemd.git time-util: make usleep_safe() return earlier if 0 is passed --- diff --git a/src/basic/time-util.h b/src/basic/time-util.h index ed4c1aabd48..29373477f48 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -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; }