From 52e9404e8516fcb4a9f2c11716482b35c32b0c94 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. --- usr.bin/tmux/resize.c | 4 ++-- usr.bin/tmux/server-fn.c | 6 +++--- usr.bin/tmux/session.c | 8 ++++---- usr.bin/tmux/tmux.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/usr.bin/tmux/resize.c b/usr.bin/tmux/resize.c index 40f94150282..9327079d7cb 100644 --- a/usr.bin/tmux/resize.c +++ b/usr.bin/tmux/resize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resize.c,v 1.15 2015/04/22 15:30:11 nicm Exp $ */ +/* $OpenBSD: resize.c,v 1.16 2015/04/22 15:32:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 808e5f35838..b1d72e69ce8 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.82 2015/04/21 21:24:49 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.83 2015/04/22 15:32:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/usr.bin/tmux/session.c b/usr.bin/tmux/session.c index 94ff3a04a92..09da65c3ed4 100644 --- a/usr.bin/tmux/session.c +++ b/usr.bin/tmux/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.46 2014/10/22 23:18:53 nicm Exp $ */ +/* $OpenBSD: session.c,v 1.47 2015/04/22 15:32:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 2d217c7b3b0..9d86f7d8de2 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.496 2015/04/22 15:30:11 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.497 2015/04/22 15:32:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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); -- 2.20.1