summaryrefslogtreecommitdiffstats
path: root/src/systemctl/systemctl-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-06-07 16:26:18 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-06-09 13:25:17 +0200
commitc4da8e90fa65a042c6cdf495f5bfe5df087010a4 (patch)
tree55129813115aa5345c599c9d1d827ddd4de602ae /src/systemctl/systemctl-util.c
parentshared/bus-util: rename variables to follow newer style (diff)
downloadsystemd-c4da8e90fa65a042c6cdf495f5bfe5df087010a4.tar.xz
systemd-c4da8e90fa65a042c6cdf495f5bfe5df087010a4.zip
systemctl: simplify code a bit
gcc insists that bus may be used unitialized here, but I don't see any possibility of that.
Diffstat (limited to 'src/systemctl/systemctl-util.c')
-rw-r--r--src/systemctl/systemctl-util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c
index 6a71bce5fb..13a039cdfb 100644
--- a/src/systemctl/systemctl-util.c
+++ b/src/systemctl/systemctl-util.c
@@ -291,8 +291,6 @@ int check_triggering_units(sd_bus *bus, const char *unit) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *n = NULL, *dbus_path = NULL, *load_state = NULL;
_cleanup_strv_free_ char **triggered_by = NULL;
- bool print_warning_label = true;
- UnitActiveState active_state;
int r;
r = unit_name_mangle(unit, 0, &n);
@@ -321,7 +319,10 @@ int check_triggering_units(sd_bus *bus, const char *unit) {
if (r < 0)
return log_error_errno(r, "Failed to get triggered by array of %s: %s", n, bus_error_message(&error, r));
+ bool first = true;
STRV_FOREACH(i, triggered_by) {
+ UnitActiveState active_state;
+
r = get_state_one_unit(bus, *i, &active_state);
if (r < 0)
return r;
@@ -329,9 +330,9 @@ int check_triggering_units(sd_bus *bus, const char *unit) {
if (!IN_SET(active_state, UNIT_ACTIVE, UNIT_RELOADING))
continue;
- if (print_warning_label) {
+ if (first) {
log_warning("Warning: Stopping %s, but it can still be activated by:", n);
- print_warning_label = false;
+ first = false;
}
log_warning(" %s", *i);