]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: logind: add missing asserts
authorMike Yuan <me@yhndnzj.com>
Mon, 13 Mar 2023 22:56:17 +0000 (06:56 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 14 Mar 2023 11:21:06 +0000 (19:21 +0800)
src/systemctl/systemctl-logind.c

index 1c3b68f09f17a31cb038ecb8d0e0df225b48c9ff..f910fe6675742942483be9424c4574cc5d2b0987 100644 (file)
@@ -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;