1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

core/unit: add one assertion, reduce variable scope

This commit is contained in:
Mike Yuan 2024-06-03 06:11:02 +02:00
parent aa7f2246ba
commit f6f271f0db
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3

View File

@ -2597,9 +2597,6 @@ static bool unit_process_job(Job *j, UnitActiveState ns, bool reload_success) {
}
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success) {
const char *reason;
Manager *m;
assert(u);
assert(os < _UNIT_ACTIVE_STATE_MAX);
assert(ns < _UNIT_ACTIVE_STATE_MAX);
@ -2608,7 +2605,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
* UnitActiveState! That means that ns == os is an expected behavior here. For example: if a mount point is
* remounted this function will be called too! */
m = u->manager;
Manager *m = ASSERT_PTR(u->manager);
/* Let's enqueue the change signal early. In case this unit has a job associated we want that this unit is in
* the bus queue, so that any job change signal queued will force out the unit change signal first. */
@ -2707,6 +2704,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
unit_trigger_notify(u);
if (!MANAGER_IS_RELOADING(m)) {
const char *reason;
if (os != UNIT_FAILED && ns == UNIT_FAILED) {
reason = strjoina("unit ", u->id, " failed");
emergency_action(m, u->failure_action, 0, u->reboot_arg, unit_failure_action_exit_status(u), reason);