int tm_usec;
int r;
+ /* Returns -ENOENT if the expression is not going to elapse anymore */
+
assert(spec);
assert(tm);
}
}
-static int calendar_spec_next_usec_impl(const CalendarSpec *spec, usec_t usec, usec_t *next) {
+static int calendar_spec_next_usec_impl(const CalendarSpec *spec, usec_t usec, usec_t *ret_next) {
struct tm tm;
time_t t;
int r;
usec_t tm_usec;
assert(spec);
- assert(next);
if (usec > USEC_TIMESTAMP_FORMATTABLE_MAX)
return -EINVAL;
if (t < 0)
return -EINVAL;
- *next = (usec_t) t * USEC_PER_SEC + tm_usec;
+ if (ret_next)
+ *ret_next = (usec_t) t * USEC_PER_SEC + tm_usec;
+
return 0;
}
int return_value;
} SpecNextResult;
-int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next) {
+int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *ret_next) {
SpecNextResult *shared, tmp;
int r;
+ assert(spec);
+
if (isempty(spec->timezone))
- return calendar_spec_next_usec_impl(spec, usec, next);
+ return calendar_spec_next_usec_impl(spec, usec, ret_next);
shared = mmap(NULL, sizeof *shared, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
if (shared == MAP_FAILED)
if (munmap(shared, sizeof *shared) < 0)
return negative_errno();
- if (tmp.return_value == 0)
- *next = tmp.next;
+ if (tmp.return_value == 0 && ret_next)
+ *ret_next = tmp.next;
return tmp.return_value;
}