]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: several cleanups for job_get_timeout()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 May 2023 18:25:37 +0000 (03:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 May 2023 06:06:39 +0000 (15:06 +0900)
- add missing assertion,
- rename the argument for storing result,
- always initialize result on success.

src/core/job.c
src/core/job.h

index 24f407ad83a191cbf909e5d1e63e1249a048d3d7..f87b0f7c7471bc5fcb8ca963e4f925be6f184fee 100644 (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;
 }
 
index dcb5c7fff6cf86c8c1291331b20be6089ff6e758..f3e0b93fed5a6e308f9880cbe43d7d83b5cc3b95 100644 (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);