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
+2 -3
View File
@@ -134,9 +134,8 @@ int clock_reset_timewarp(void) {
#define EPOCH_FILE "/usr/lib/clock-epoch"
int clock_apply_epoch(ClockChangeDirection *ret_attempted_change) {
struct stat st;
struct timespec ts;
usec_t epoch_usec, now_usec;
struct stat st;
/* NB: we update *ret_attempted_change in *all* cases, both
* on success and failure, to indicate what we intended to do! */
@@ -161,7 +160,7 @@ int clock_apply_epoch(ClockChangeDirection *ret_attempted_change) {
return 0;
}
if (clock_settime(CLOCK_REALTIME, timespec_store(&ts, epoch_usec)) < 0)
if (clock_settime(CLOCK_REALTIME, TIMESPEC_STORE(epoch_usec)) < 0)
return -errno;
return 1;