summaryrefslogtreecommitdiffstats
path: root/src/core/job.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-05-09 20:25:37 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-05-10 08:06:39 +0200
commitfcd7e0b7edf57d8de1de35bcef26c22ecd62b256 (patch)
tree5daae10c7713bc2d76e0d5b57b501d9e4c672921 /src/core/job.c
parenttree-wide: drop _pure_ attribute from non-pure functions (diff)
downloadsystemd-fcd7e0b7edf57d8de1de35bcef26c22ecd62b256.tar.xz
systemd-fcd7e0b7edf57d8de1de35bcef26c22ecd62b256.zip
core: several cleanups for job_get_timeout()
- add missing assertion, - rename the argument for storing result, - always initialize result on success.
Diffstat (limited to 'src/core/job.c')
-rw-r--r--src/core/job.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/core/job.c b/src/core/job.c
index 24f407ad83..f87b0f7c74 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;
}