summaryrefslogtreecommitdiffstats
path: root/src/login
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-15 08:14:53 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-19 00:10:29 +0100
commit03677889f0ef42cdc534bf3b31265a054b20a354 (patch)
tree53caa0977a8afc5d0ee90e038ffd566e9e22451f /src/login
parentvarious: make parse_env_file error handling the same in various places (diff)
downloadsystemd-03677889f0ef42cdc534bf3b31265a054b20a354.tar.xz
systemd-03677889f0ef42cdc534bf3b31265a054b20a354.zip
list: declare iterator of LIST_FOREACH() in the loop
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-dbus.c4
-rw-r--r--src/login/logind-device.c1
-rw-r--r--src/login/logind-seat-dbus.c1
-rw-r--r--src/login/logind-seat.c13
-rw-r--r--src/login/logind-user-dbus.c1
-rw-r--r--src/login/logind-user.c9
-rw-r--r--src/login/logind.c10
7 files changed, 10 insertions, 29 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 2ed4eeddfe..954f9c61d7 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -3813,8 +3813,8 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
if (streq_ptr(path, user->service_job)) {
user->service_job = mfree(user->service_job);
- LIST_FOREACH(sessions_by_user, session, user->sessions)
- (void) session_jobs_reply(session, id, unit, NULL /* don't propagate user service failures to the client */);
+ LIST_FOREACH(sessions_by_user, s, user->sessions)
+ (void) session_jobs_reply(s, id, unit, NULL /* don't propagate user service failures to the client */);
user_save(user);
}
diff --git a/src/login/logind-device.c b/src/login/logind-device.c
index 982a772194..592ee3b9d6 100644
--- a/src/login/logind-device.c
+++ b/src/login/logind-device.c
@@ -67,7 +67,6 @@ void device_free(Device *d) {
}
void device_attach(Device *d, Seat *s) {
- Device *i;
bool had_master;
assert(d);
diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c
index f82991c5da..cd20693cbe 100644
--- a/src/login/logind-seat-dbus.c
+++ b/src/login/logind-seat-dbus.c
@@ -56,7 +56,6 @@ static int property_get_sessions(
sd_bus_error *error) {
Seat *s = userdata;
- Session *session;
int r;
assert(bus);
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 58912b85b3..8e603f1f38 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -122,8 +122,6 @@ int seat_save(Seat *s) {
}
if (s->sessions) {
- Session *i;
-
fputs("SESSIONS=", f);
LIST_FOREACH(sessions_by_seat, i, s->sessions) {
fprintf(f,
@@ -349,7 +347,7 @@ int seat_switch_to_previous(Seat *s) {
}
int seat_active_vt_changed(Seat *s, unsigned vtnr) {
- Session *i, *new_active = NULL;
+ Session *new_active = NULL;
int r;
assert(s);
@@ -368,7 +366,7 @@ int seat_active_vt_changed(Seat *s, unsigned vtnr) {
break;
}
- if (!new_active) {
+ if (!new_active)
/* no running one? then we can't decide which one is the
* active one, let the first one win */
LIST_FOREACH(sessions_by_seat, i, s->sessions)
@@ -376,7 +374,6 @@ int seat_active_vt_changed(Seat *s, unsigned vtnr) {
new_active = i;
break;
}
- }
r = seat_set_active(s, new_active);
manager_spawn_autovt(s->manager, vtnr);
@@ -467,7 +464,6 @@ int seat_stop(Seat *s, bool force) {
}
int seat_stop_sessions(Seat *s, bool force) {
- Session *session;
int r = 0, k;
assert(s);
@@ -482,7 +478,6 @@ int seat_stop_sessions(Seat *s, bool force) {
}
void seat_evict_position(Seat *s, Session *session) {
- Session *iter;
unsigned pos = session->position;
session->position = 0;
@@ -496,12 +491,11 @@ void seat_evict_position(Seat *s, Session *session) {
/* There might be another session claiming the same
* position (eg., during gdm->session transition), so let's look
* for it and set it on the free slot. */
- LIST_FOREACH(sessions_by_seat, iter, s->sessions) {
+ LIST_FOREACH(sessions_by_seat, iter, s->sessions)
if (iter->position == pos && session_get_state(iter) != SESSION_CLOSING) {
s->positions[pos] = iter;
break;
}
- }
}
}
@@ -599,7 +593,6 @@ bool seat_can_graphical(Seat *s) {
}
int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
- Session *session;
bool idle_hint = true;
dual_timestamp ts = DUAL_TIMESTAMP_NULL;
diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index 572a16a7af..67b6556d7d 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -106,7 +106,6 @@ static int property_get_sessions(
sd_bus_error *error) {
User *u = userdata;
- Session *session;
int r;
assert(bus);
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 8d6bafe45d..af33bf7a4f 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -189,7 +189,6 @@ static int user_save_internal(User *u) {
u->last_session_timestamp);
if (u->sessions) {
- Session *i;
bool first;
fputs("SESSIONS=", f);
@@ -499,8 +498,8 @@ static void user_stop_service(User *u, bool force) {
}
int user_stop(User *u, bool force) {
- Session *s;
int r = 0;
+
assert(u);
/* This is called whenever we begin with tearing down a user record. It's called in two cases: explicit API
@@ -534,7 +533,6 @@ int user_stop(User *u, bool force) {
}
int user_finalize(User *u) {
- Session *s;
int r = 0, k;
assert(u);
@@ -575,7 +573,6 @@ int user_finalize(User *u) {
}
int user_get_idle_hint(User *u, dual_timestamp *t) {
- Session *s;
bool idle_hint = true;
dual_timestamp ts = DUAL_TIMESTAMP_NULL;
@@ -721,8 +718,6 @@ void user_add_to_gc_queue(User *u) {
}
UserState user_get_state(User *u) {
- Session *i;
-
assert(u);
if (u->stopping)
@@ -805,8 +800,6 @@ static int elect_display_compare(Session *s1, Session *s2) {
}
void user_elect_display(User *u) {
- Session *s;
-
assert(u);
/* This elects a primary session for each user, which we call the "display". We try to keep the assignment
diff --git a/src/login/logind.c b/src/login/logind.c
index 3b4de5b799..0483902edd 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -685,7 +685,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;
- Session *active, *iter;
+ Session *active;
/*
* We got a VT-switch signal and we have to acknowledge it immediately.
@@ -732,16 +732,14 @@ static int manager_vt_switch(sd_event_source *src, const struct signalfd_siginfo
return 0;
}
- if (active->vtfd >= 0) {
+ if (active->vtfd >= 0)
session_leave_vt(active);
- } else {
- LIST_FOREACH(sessions_by_seat, iter, m->seat0->sessions) {
+ else
+ LIST_FOREACH(sessions_by_seat, iter, m->seat0->sessions)
if (iter->vtnr == active->vtnr && iter->vtfd >= 0) {
session_leave_vt(iter);
break;
}
- }
- }
return 0;
}