diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-12 12:56:40 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-12 12:56:40 -0500 |
commit | 4440b27d41faa504a4e48203284233625aaac9c5 (patch) | |
tree | 6a46b5f13c0b0cbe9f9d183d17dc635a8a147c0b | |
parent | 7a6a095a9ef6ec014a23a231e5d11e8a2ef0fe17 (diff) |
core/manager: silence gcc warning about unitialized variable
At -O3, this was printed a hundred times for various callers of
manager_add_job_by_name(). AFAICT, there is no error and `unit` is always
intialized. Nevertheless, add explicit initialization to silence the noise.
src/core/manager.c: In function 'manager_start_target':
src/core/manager.c:1413:16: warning: 'unit' may be used uninitialized in this function [-Wmaybe-uninitialized]
return manager_add_job(m, type, unit, mode, e, ret);
^
src/core/manager.c:1401:15: note: 'unit' was declared here
Unit *unit;
^
-rw-r--r-- | src/core/manager.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 0f8f808b4a..5646889a8e 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1398,7 +1398,7 @@ tr_abort: } int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, sd_bus_error *e, Job **ret) { - Unit *unit; + Unit *unit = NULL; /* just to appease gcc, initialization is not really necessary */ int r; assert(m); @@ -1409,6 +1409,7 @@ int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode r = manager_load_unit(m, name, NULL, NULL, &unit); if (r < 0) return r; + assert(unit); return manager_add_job(m, type, unit, mode, e, ret); } |