summaryrefslogtreecommitdiffstats
path: root/cmd-switch-client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-12-20 00:17:22 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-12-20 00:17:22 +0000
commit9358cfaf4a566a060af81312ff73ee1e3e8c8ced (patch)
tree9bb80e4b6807c9b434f7b463c7caed9cdb581584 /cmd-switch-client.c
parenta51dcdc430150b688d56ec35e8c96ce6f978f68b (diff)
Use pointer rather than index for the client's last session.
Diffstat (limited to 'cmd-switch-client.c')
-rw-r--r--cmd-switch-client.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/cmd-switch-client.c b/cmd-switch-client.c
index dfe8aca1..1be8a6c7 100644
--- a/cmd-switch-client.c
+++ b/cmd-switch-client.c
@@ -159,9 +159,8 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
}
} else if (data->flag_last) {
- if (c->last_session != UINT_MAX &&
- c->last_session < ARRAY_LENGTH(&sessions))
- s = ARRAY_ITEM(&sessions, c->last_session);
+ if (c->last_session != NULL && session_alive(c->last_session))
+ s = c->last_session;
if (s == NULL) {
ctx->error(ctx, "can't find last session");
return (-1);
@@ -172,7 +171,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
if (c->session != NULL)
- session_index(c->session, &c->last_session);
+ c->last_session = c->session;
c->session = s;
recalculate_sizes();