]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: simplify code
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 23 Jun 2022 07:56:33 +0000 (09:56 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 23 Jun 2022 15:55:09 +0000 (17:55 +0200)
Follow-up for 4885d7490b23e08d8444e5a68927ce9ce8727e5a.

src/login/logind-session.c

index ac3904352e950176d414490912bd919cd3f826c8..22bb4c371498926a0c9f426ea6d7ca2e3f4813a5 100644 (file)
@@ -359,12 +359,11 @@ fail:
 }
 
 static int session_load_devices(Session *s, const char *devices) {
-        const char *p;
         int r = 0;
 
         assert(s);
 
-        for (p = devices;;) {
+        for (const char *p = devices;;) {
                 _cleanup_free_ char *word = NULL;
                 SessionDevice *sd;
                 dev_t dev;
@@ -551,7 +550,7 @@ int session_load(Session *s) {
                         s->class = c;
         }
 
-        if (state && streq(state, "closing"))
+        if (streq_ptr(state, "closing"))
                 s->stopping = true;
 
         if (s->fifo_path) {
@@ -1050,11 +1049,8 @@ int session_set_display(Session *s, const char *display) {
         assert(s);
         assert(display);
 
-        if (streq(s->display, display))
-                return 0;
-
         r = free_and_strdup(&s->display, display);
-        if (r < 0)
+        if (r <= 0)  /* 0 means the strings were equal */
                 return r;
 
         session_save(s);
@@ -1333,9 +1329,7 @@ void session_leave_vt(Session *s) {
 }
 
 bool session_is_controller(Session *s, const char *sender) {
-        assert(s);
-
-        return streq_ptr(s->controller, sender);
+        return streq_ptr(ASSERT_PTR(s)->controller, sender);
 }
 
 static void session_release_controller(Session *s, bool notify) {