time-util: add macros around timespec_store() that operates on compund literal allocated timespec struct

This way we can convert usec_t to timespec on-the-fly, without a buffer.

No actual behaviour change just some shortening of code.
This commit is contained in:
Lennart Poettering
2022-03-18 17:13:36 +01:00
parent de0988f9d2
commit 52bb308c13
10 changed files with 17 additions and 26 deletions
+1 -2
View File
@@ -159,7 +159,6 @@ int pipe_eof(int fd) {
}
int ppoll_usec(struct pollfd *fds, size_t nfds, usec_t timeout) {
struct timespec ts;
int r;
assert(fds || nfds == 0);
@@ -167,7 +166,7 @@ int ppoll_usec(struct pollfd *fds, size_t nfds, usec_t timeout) {
if (nfds == 0)
return 0;
r = ppoll(fds, nfds, timeout == USEC_INFINITY ? NULL : timespec_store(&ts, timeout), NULL);
r = ppoll(fds, nfds, timeout == USEC_INFINITY ? NULL : TIMESPEC_STORE(timeout), NULL);
if (r < 0)
return -errno;
if (r == 0)