summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2023-03-14 06:56:17 +0800
committerMike Yuan <me@yhndnzj.com>2023-03-14 19:21:06 +0800
commit9071eea01bd26d838bfd793db497efd849ad44da (patch)
treec02142aac61addac7c51605cbb66580d909244d4 /src/systemctl
parent3a36d19938c1dcc10bb11ff5d2f3e2e7eec26997 (diff)
downloadsystemd-9071eea01bd26d838bfd793db497efd849ad44da.tar.gz
systemctl: logind: add missing asserts
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-logind.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c
index 1c3b68f09f..f910fe6675 100644
--- a/src/systemctl/systemctl-logind.c
+++ b/src/systemctl/systemctl-logind.c
@@ -21,6 +21,8 @@ static int logind_set_wall_message(sd_bus *bus) {
_cleanup_free_ char *m = NULL;
int r;
+ assert(bus);
+
m = strv_join(arg_wall, " ");
if (!m)
return log_oom();
@@ -55,7 +57,10 @@ int logind_reboot(enum action a) {
sd_bus *bus;
int r;
- if (a < 0 || a >= _ACTION_MAX || !actions[a])
+ assert(a >= 0);
+ assert(a < _ACTION_MAX);
+
+ if (!actions[a])
return -EINVAL;
r = acquire_bus(BUS_FULL, &bus);
@@ -106,6 +111,9 @@ int logind_check_inhibitors(enum action a) {
unsigned c = 0;
int r;
+ assert(a >= 0);
+ assert(a < _ACTION_MAX);
+
if (arg_check_inhibitors == 0 || arg_force > 0)
return 0;