This function was returning 0 or 1 on success. It has many callers, and it
wasn't clear if any of them care about the distinction. It turns out they don't
and the return values were done for convenience because manager_load_unit_prepare()
returns 0 or 1. Let's invert the code in the static function to follow the usual
pattern where 0 means "no work was done" and 1 means "work was done", and make
the non-static function always return 0 to make the code easier to read, and
also add comments that explain what is happening.
No functional change.
unit->load_state = UNIT_STUB;
else {
*ret = unit;
- return 1;
+ return 0; /* The unit was already loaded */
}
} else {
unit = cleanup_unit = unit_new(m, unit_vtable[t]->object_size);
*ret = unit;
TAKE_PTR(cleanup_unit);
- return 0;
+ return 1; /* The unit was added the load queue */
}
int manager_load_unit(
/* This will load the unit config, but not actually start any services or anything. */
r = manager_load_unit_prepare(m, name, path, e, ret);
- if (r != 0)
+ if (r <= 0)
return r;
+ /* Unit was newly loaded */
manager_dispatch_load_queue(m);
-
*ret = unit_follow_merge(*ret);
return 0;
}