Skip to content

Commit

Permalink
logind: simplify code
Browse files Browse the repository at this point in the history
Follow-up for 4885d7490b23e08d8444e5a68927ce9ce8727e5a.

(cherry picked from commit e5c09aad375551b9db499703ab7eb123d408ba16)

Resolves: #2209328
  • Loading branch information
keszybz authored and dtardon committed Jun 1, 2023
1 parent ab5a221 commit 36a944a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/login/logind-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,11 @@ int session_save(Session *s) {
}

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;
Expand Down Expand Up @@ -531,7 +530,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) {
Expand Down Expand Up @@ -1073,11 +1072,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);
Expand Down

0 comments on commit 36a944a

Please sign in to comment.