]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: add missing asserts
authorMike Yuan <me@yhndnzj.com>
Mon, 28 Aug 2023 13:21:06 +0000 (21:21 +0800)
committerMike Yuan <me@yhndnzj.com>
Mon, 28 Aug 2023 14:50:42 +0000 (22:50 +0800)
src/login/logind-session.c
src/login/logind.c

index 4d1caee4d3793a04424b8fdd080e865463607b0a..939a728a8286ff2b5bd158768d787d028953b974 100644 (file)
@@ -1293,6 +1293,8 @@ int session_kill(Session *s, KillWho who, int signo) {
 static int session_open_vt(Session *s) {
         char path[sizeof("/dev/tty") + DECIMAL_STR_MAX(s->vtnr)];
 
+        assert(s);
+
         if (s->vtnr < 1)
                 return -ENODEV;
 
@@ -1311,6 +1313,8 @@ static int session_prepare_vt(Session *s) {
         int vt, r;
         struct vt_mode mode = {};
 
+        assert(s);
+
         if (s->vtnr < 1)
                 return 0;
 
@@ -1366,6 +1370,8 @@ error:
 static void session_restore_vt(Session *s) {
         int r;
 
+        assert(s);
+
         if (s->vtfd < 0)
                 return;
 
@@ -1444,6 +1450,8 @@ static void session_release_controller(Session *s, bool notify) {
         _unused_ _cleanup_free_ char *name = NULL;
         SessionDevice *sd;
 
+        assert(s);
+
         if (!s->controller)
                 return;
 
index 79cab9402104f4d2d9caa067b375af7403fe1838..0e85bffe2bd9f38d1f6ccd5973a03464a9d4d181 100644 (file)
@@ -438,6 +438,8 @@ static int manager_attach_fds(Manager *m) {
         /* Upon restart, PID1 will send us back all fds of session devices that we previously opened. Each
          * file descriptor is associated with a given session. The session ids are passed through FDNAMES. */
 
+        assert(m);
+
         n = sd_listen_fds_with_names(true, &fdnames);
         if (n < 0)
                 return log_warning_errno(n, "Failed to acquire passed fd list: %m");
@@ -668,7 +670,7 @@ static int manager_connect_bus(Manager *m) {
 }
 
 static int manager_vt_switch(sd_event_source *src, const struct signalfd_siginfo *si, void *data) {
-        Manager *m = data;
+        Manager *m = ASSERT_PTR(data);
         Session *active;
 
         /*