mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
calendarspec: make return time value of calendar_spec_next_usec() optional
If noone is interested, there's no reason to return it. (Also document the ENOENT error code in a comment)
This commit is contained in:
parent
c5b7ae0edb
commit
9bb656bd0c
|
@ -1193,6 +1193,8 @@ static int find_next(const CalendarSpec *spec, struct tm *tm, usec_t *usec) {
|
|||
int tm_usec;
|
||||
int r;
|
||||
|
||||
/* Returns -ENOENT if the expression is not going to elapse anymore */
|
||||
|
||||
assert(spec);
|
||||
assert(tm);
|
||||
|
||||
|
@ -1285,14 +1287,13 @@ static int find_next(const CalendarSpec *spec, struct tm *tm, usec_t *usec) {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1310,7 +1311,9 @@ static int calendar_spec_next_usec_impl(const CalendarSpec *spec, usec_t usec, u
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -1319,12 +1322,14 @@ typedef struct SpecNextResult {
|
|||
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)
|
||||
|
@ -1352,8 +1357,8 @@ int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue