diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-02 17:30:35 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-02 17:31:55 +0200 |
commit | 4c989f89b6d9d6f45072df10f7d42b658d783058 (patch) | |
tree | f5ed191adbef929da8a6ab621688f3f7af780d52 /src/core/manager.c | |
parent | meson: Compile with -ftrivial-auto-var-init=zero in release mode (diff) | |
download | systemd-4c989f89b6d9d6f45072df10f7d42b658d783058.tar.xz systemd-4c989f89b6d9d6f45072df10f7d42b658d783058.zip |
core: rework variable initialization to avoid gcc warning
In file included from ../src/basic/siphash24.h:11,
from ../src/basic/hash-funcs.h:6,
from ../src/basic/hashmap.h:8,
from ../src/shared/fdset.h:6,
from ../src/shared/bpf-program.h:9,
from ../src/core/unit.h:11,
from ../src/core/all-units.h:4,
from ../src/core/manager.c:23:
../src/basic/time-util.h: In function 'manager_dispatch_jobs_in_progress':
../src/basic/time-util.h:140:38: error: 'x' may be used uninitialized [-Werror=maybe-uninitialized]
140 | #define FORMAT_TIMESPAN(t, accuracy) format_timespan((char[FORMAT_TIMESPAN_MAX]){}, FORMAT_TIMESPAN_MAX, t, accuracy)
| ^~~~~~~~~~~~~~~
In function 'manager_print_jobs_in_progress',
inlined from 'manager_dispatch_jobs_in_progress' at ../src/core/manager.c:3007:9:
../src/core/manager.c:219:18: note: 'x' was declared here
219 | uint64_t x;
| ^
cc1: all warnings being treated as errors
For some reason this (false positive) warning starts appearing after
-ftrivial-auto-var-init is used.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r-- | src/core/manager.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 98daa764eb..79449af659 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -216,7 +216,7 @@ static void manager_print_jobs_in_progress(Manager *m) { unsigned counter = 0, print_nr; char cylon[6 + CYLON_BUFFER_EXTRA + 1]; unsigned cylon_pos; - uint64_t x; + uint64_t timeout = 0; assert(m); assert(m->n_running_jobs > 0); @@ -245,7 +245,7 @@ static void manager_print_jobs_in_progress(Manager *m) { if (m->n_running_jobs > 1) xsprintf(job_of_n, "(%u of %u) ", counter, m->n_running_jobs); - bool have_timeout = job_get_timeout(j, &x) > 0; + (void) job_get_timeout(j, &timeout); /* We want to use enough information for the user to identify previous lines talking about the same * unit, but keep the message as short as possible. So if 'Starting foo.service' or 'Starting @@ -255,7 +255,7 @@ static void manager_print_jobs_in_progress(Manager *m) { const char *ident = unit_status_string(j->unit, NULL); const char *time = FORMAT_TIMESPAN(now(CLOCK_MONOTONIC) - j->begin_usec, 1*USEC_PER_SEC); - const char *limit = have_timeout ? FORMAT_TIMESPAN(x - j->begin_usec, 1*USEC_PER_SEC) : "no limit"; + const char *limit = timeout > 0 ? FORMAT_TIMESPAN(timeout - j->begin_usec, 1*USEC_PER_SEC) : "no limit"; if (m->status_unit_format == STATUS_UNIT_FORMAT_DESCRIPTION) /* When using 'Description', we effectively don't have enough space to show the nested status |