tree-wide: use timestamp_is_set() more

This commit is contained in:
Lennart Poettering
2022-02-22 22:49:40 +01:00
parent ec93eb48f2
commit 0da36375eb
11 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -1195,7 +1195,7 @@ int write_timestamp_file_atomic(const char *fn, usec_t n) {
/* Creates a "timestamp" file, that contains nothing but a
* usec_t timestamp, formatted in ASCII. */
if (n <= 0 || n >= USEC_INFINITY)
if (!timestamp_is_set(n))
return -ERANGE;
xsprintf(ln, USEC_FMT "\n", n);
@@ -1216,7 +1216,7 @@ int read_timestamp_file(const char *fn, usec_t *ret) {
if (r < 0)
return r;
if (t <= 0 || t >= (uint64_t) USEC_INFINITY)
if (!timestamp_is_set(t))
return -ERANGE;
*ret = (usec_t) t;
+4 -4
View File
@@ -126,7 +126,7 @@ usec_t map_clock_usec(usec_t from, clockid_t from_clock, clockid_t to_clock) {
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) {
assert(ts);
if (u == USEC_INFINITY || u == 0) {
if (!timestamp_is_set(u)) {
ts->realtime = ts->monotonic = u;
return ts;
}
@@ -141,7 +141,7 @@ triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u)
assert(ts);
if (u == USEC_INFINITY || u == 0) {
if (!timestamp_is_set(u)) {
ts->realtime = ts->monotonic = ts->boottime = u;
return ts;
}
@@ -349,7 +349,7 @@ char *format_timestamp_style(
1 + 1 + /* space and shortest possible zone */
1))
return NULL; /* Not enough space even for the shortest form. */
if (t <= 0 || t == USEC_INFINITY)
if (!timestamp_is_set(t))
return NULL; /* Timestamp is unset */
if (style == TIMESTAMP_UNIX) {
@@ -427,7 +427,7 @@ char *format_timestamp_relative(char *buf, size_t l, usec_t t) {
const char *s;
usec_t n, d;
if (t <= 0 || t == USEC_INFINITY)
if (!timestamp_is_set(t))
return NULL;
n = now(CLOCK_REALTIME);
+1 -1
View File
@@ -199,7 +199,7 @@ int fd_setcrtime(int fd, usec_t usec) {
assert(fd >= 0);
if (IN_SET(usec, 0, USEC_INFINITY))
if (!timestamp_is_set(usec))
usec = now(CLOCK_REALTIME);
le = htole64((uint64_t) usec);