From 9a453dd3546b2c3053e8e34bf4d6775b1a05d3a8 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 22 Apr 2015 15:32:33 +0000 Subject: [PATCH] Make session_has return a flag, returning the first winlink found is a recipe for errors. --- resize.c | 2 +- server-fn.c | 4 ++-- session.c | 6 +++--- tmux.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resize.c b/resize.c index 5b89b093..330c37b5 100644 --- a/resize.c +++ b/resize.c @@ -104,7 +104,7 @@ recalculate_sizes(void) if (flag) has = s->curw->window == w; else - has = session_has(s, w) != NULL; + has = session_has(s, w); if (has) { if (s->sx < ssx) ssx = s->sx; diff --git a/server-fn.c b/server-fn.c index 83ea9474..c5487aa6 100644 --- a/server-fn.c +++ b/server-fn.c @@ -199,7 +199,7 @@ server_status_window(struct window *w) */ RB_FOREACH(s, sessions, &sessions) { - if (session_has(s, w) != NULL) + if (session_has(s, w)) server_status_session(s); } } @@ -268,7 +268,7 @@ server_kill_window(struct window *w) s = next_s; next_s = RB_NEXT(sessions, &sessions, s); - if (session_has(s, w) == NULL) + if (!session_has(s, w)) continue; server_unzoom_window(w); while ((wl = winlink_find_by_window(&s->windows, w)) != NULL) { diff --git a/session.c b/session.c index 03ddb10d..c0535725 100644 --- a/session.c +++ b/session.c @@ -309,16 +309,16 @@ session_detach(struct session *s, struct winlink *wl) } /* Return if session has window. */ -struct winlink * +int session_has(struct session *s, struct window *w) { struct winlink *wl; RB_FOREACH(wl, winlinks, &s->windows) { if (wl->window == w) - return (wl); + return (1); } - return (NULL); + return (0); } struct winlink * diff --git a/tmux.h b/tmux.h index e52b14f1..a47218e5 100644 --- a/tmux.h +++ b/tmux.h @@ -2321,7 +2321,7 @@ struct winlink *session_new(struct session *, const char *, int, char **, struct winlink *session_attach(struct session *, struct window *, int, char **); int session_detach(struct session *, struct winlink *); -struct winlink *session_has(struct session *, struct window *); +int session_has(struct session *, struct window *); int session_next(struct session *, int); int session_previous(struct session *, int); int session_select(struct session *, int);