core: several cleanups for job_get_timeout()

- add missing assertion,
- rename the argument for storing result,
- always initialize result on success.
This commit is contained in:
Yu Watanabe
2023-05-10 15:06:39 +09:00
parent bc52801034
commit fcd7e0b7ed
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -1404,11 +1404,13 @@ void job_shutdown_magic(Job *j) {
(void) asynchronous_sync(NULL);
}
int job_get_timeout(Job *j, usec_t *timeout) {
int job_get_timeout(Job *j, usec_t *ret) {
usec_t x = USEC_INFINITY, y = USEC_INFINITY;
Unit *u = ASSERT_PTR(ASSERT_PTR(j)->unit);
int r;
assert(ret);
if (j->timer_event_source) {
r = sd_event_source_get_time(j->timer_event_source, &x);
if (r < 0)
@@ -1421,10 +1423,12 @@ int job_get_timeout(Job *j, usec_t *timeout) {
return r;
}
if (x == USEC_INFINITY && y == USEC_INFINITY)
if (x == USEC_INFINITY && y == USEC_INFINITY) {
*ret = 0;
return 0;
}
*timeout = MIN(x, y);
*ret = MIN(x, y);
return 1;
}
+1 -1
View File
@@ -220,7 +220,7 @@ char *job_dbus_path(Job *j);
void job_shutdown_magic(Job *j);
int job_get_timeout(Job *j, usec_t *timeout);
int job_get_timeout(Job *j, usec_t *ret);
bool job_may_gc(Job *j);
void job_add_to_gc_queue(Job *j);