From a4cb8afb8ff82ed55ca3667e1ccee9f3757a4a20 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 21 Sep 2022 03:30:11 +0900 Subject: [PATCH] core/device: check that no unit is ready and not simultaneously This should not happen, just for safety. --- src/core/device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/device.c b/src/core/device.c index 21dc5890fc5..b3cf77d50c6 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -903,6 +903,13 @@ static int device_setup_units(Manager *m, sd_device *dev, Set **ready_units, Set /* Next, add/update additional .device units point to aliases and symlinks. */ (void) device_setup_extra_units(m, dev, ready_units, not_ready_units); + + /* Safety check: no unit should be in ready_units and not_ready_units simultaneously. */ + Unit *u; + SET_FOREACH(u, *not_ready_units) + if (set_remove(*ready_units, u)) + log_unit_error(u, "Cannot active and deactive simultaneously. Deactivating."); + return 0; } -- 2.47.3