From: Mike Yuan Date: Sun, 9 Jun 2024 12:48:37 +0000 (+0200) Subject: core/unit: merge nested if statements, use else where appropriate X-Git-Tag: v257-rc1~1170^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b984151e502ffbc31c61eb9eec5f2046d77608df;p=thirdparty%2Fsystemd.git core/unit: merge nested if statements, use else where appropriate We already use `else if` for unit state checks above. Let's use that at one more place to make mutually exclusive cases more distinct. --- diff --git a/src/core/unit.c b/src/core/unit.c index 2da5876237a..a11c075c7fc 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2611,17 +2611,16 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su * the bus queue, so that any job change signal queued will force out the unit change signal first. */ unit_add_to_dbus_queue(u); - /* Update systemd-oomd on the property/state change */ - if (os != ns) { - /* Always send an update if the unit is going into an inactive state so systemd-oomd knows to stop - * monitoring. - * Also send an update whenever the unit goes active; this is to handle a case where an override file - * sets one of the ManagedOOM*= properties to "kill", then later removes it. systemd-oomd needs to - * know to stop monitoring when the unit changes from "kill" -> "auto" on daemon-reload, but we don't - * have the information on the property. Thus, indiscriminately send an update. */ - if (UNIT_IS_INACTIVE_OR_FAILED(ns) || UNIT_IS_ACTIVE_OR_RELOADING(ns)) - (void) manager_varlink_send_managed_oom_update(u); - } + /* Update systemd-oomd on the property/state change. + * + * Always send an update if the unit is going into an inactive state so systemd-oomd knows to + * stop monitoring. + * Also send an update whenever the unit goes active; this is to handle a case where an override file + * sets one of the ManagedOOM*= properties to "kill", then later removes it. systemd-oomd needs to + * know to stop monitoring when the unit changes from "kill" -> "auto" on daemon-reload, but we don't + * have the information on the property. Thus, indiscriminately send an update. */ + if (os != ns && (UNIT_IS_INACTIVE_OR_FAILED(ns) || UNIT_IS_ACTIVE_OR_RELOADING(ns))) + (void) manager_varlink_send_managed_oom_update(u); /* Update timestamps for state changes */ if (!MANAGER_IS_RELOADING(m)) { @@ -2734,9 +2733,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su /* Maybe we can release some resources now? */ unit_submit_to_release_resources_queue(u); - } - if (UNIT_IS_ACTIVE_OR_RELOADING(ns)) { + } else if (UNIT_IS_ACTIVE_OR_RELOADING(ns)) { /* Start uphold units regardless if going up was expected or not */ check_uphold_dependencies(u);