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;
               ^
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-02-12 12:56:40 -05:00
parent 7a6a095a9e
commit 4440b27d41
1 changed files with 2 additions and 1 deletions

View File

@ -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);
}