]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
job: properly initialize all enum fields
authorLennart Poettering <lennart@amutable.com>
Fri, 24 Apr 2026 13:19:06 +0000 (15:19 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 24 Apr 2026 15:38:33 +0000 (16:38 +0100)
This changes the .result field to invalid initially, which arguably
makes more sense than "done", which was previously the default.

This is a correctnes fix, and afaics has no effect on the API, since we
do not expose this 1:1 as D-Bus property: it's only seen on D-Bus as
part of the job completion signal, at which part it is correctly
initialized.

Noticed while reviewing: https://github.com/systemd/systemd/pull/41583

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

index 7dd8a4617db263032f26ac9b4f52ad72f2008655..920d246b8849a9c6d5d05bc03152e9b732cc8744 100644 (file)
@@ -41,6 +41,8 @@ Job* job_new_raw(Unit *unit) {
                 .manager = unit->manager,
                 .unit = unit,
                 .type = _JOB_TYPE_INVALID,
+                .state = JOB_WAITING,
+                .result = _JOB_RESULT_INVALID,
         };
 
         return j;
index d8aa6ce17c53ad87ba9865a1a4f6856025bfe273..ff1d25ff5022b88455cc5528117c5e6f8192f88a 100644 (file)
@@ -106,7 +106,6 @@ typedef struct Job {
 
         JobType type;
         JobState state;
-
         JobResult result;
 
         unsigned run_queue_idx;