From: Yu Watanabe Date: Tue, 9 May 2023 18:25:37 +0000 (+0900) Subject: core: several cleanups for job_get_timeout() X-Git-Tag: v254-rc1~511^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcd7e0b7edf57d8de1de35bcef26c22ecd62b256;p=thirdparty%2Fsystemd.git core: several cleanups for job_get_timeout() - add missing assertion, - rename the argument for storing result, - always initialize result on success. --- diff --git a/src/core/job.c b/src/core/job.c index 24f407ad83a..f87b0f7c747 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -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; } diff --git a/src/core/job.h b/src/core/job.h index dcb5c7fff6c..f3e0b93fed5 100644 --- a/src/core/job.h +++ b/src/core/job.h @@ -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);