From: David Rheinsberg Date: Mon, 28 Apr 2025 11:13:10 +0000 (+0200) Subject: basic/time-util: fix error handling of clock_nanosleep() X-Git-Tag: v258-rc1~728 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=81660754981ce66d194df9f1773edd22840f3daa;p=thirdparty%2Fsystemd.git basic/time-util: fix error handling of clock_nanosleep() `clock_nanosleep()` returns error codes directly, rather than using `errno`. Ensure that we use those codes, rather than checking for `<0`. --- diff --git a/src/basic/time-util.h b/src/basic/time-util.h index 14d660ee7e9..3f6e3c9f41c 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -222,8 +222,8 @@ static inline int usleep_safe(usec_t usec) { 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; + /* `clock_nanosleep()` does not use `errno`, but returns positive error codes. */ + return -clock_nanosleep(CLOCK_MONOTONIC, 0, TIMESPEC_STORE(usec), NULL); } /* The last second we can format is 31. Dec 9999, 1s before midnight, because otherwise we'd enter 5 digit