From 5235cd7f9d56ba9584b361c5ab7e710e561b74b5 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 22 Apr 2015 15:05:03 +0000 Subject: [PATCH] window_index is only used in one place (window_destroy) so inline it there. --- usr.bin/tmux/server.c | 3 ++- usr.bin/tmux/tmux.h | 3 +-- usr.bin/tmux/window.c | 18 ++++++------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index b7f1537c643..eaa3507e72a 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.119 2015/04/21 22:32:40 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.120 2015/04/22 15:05:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -389,6 +389,7 @@ void server_signal_callback(int sig, unused short events, unused void *data) { int fd; + switch (sig) { case SIGTERM: server_shutdown = 1; diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index c8daf41d259..dcf24547ded 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.494 2015/04/21 22:38:49 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.495 2015/04/22 15:05:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2141,7 +2141,6 @@ struct winlink *winlink_previous_by_number(struct winlink *, struct session *, int); void winlink_stack_push(struct winlink_stack *, struct winlink *); void winlink_stack_remove(struct winlink_stack *, struct winlink *); -int window_index(struct window *, u_int *); struct window *window_find_by_id(u_int); struct window *window_create1(u_int, u_int); struct window *window_create(const char *, int, char **, const char *, diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 5ce73e31b68..3492dc3149b 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.120 2015/04/21 22:38:50 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.121 2015/04/22 15:05:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -245,16 +245,6 @@ winlink_stack_remove(struct winlink_stack *stack, struct winlink *wl) } } -int -window_index(struct window *s, u_int *i) -{ - for (*i = 0; *i < ARRAY_LENGTH(&windows); (*i)++) { - if (s == ARRAY_ITEM(&windows, *i)) - return (0); - } - return (-1); -} - struct window * window_find_by_id(u_int id) { @@ -341,7 +331,11 @@ window_destroy(struct window *w) window_unzoom(w); - if (window_index(w, &i) != 0) + for (i = 0; i < ARRAY_LENGTH(&windows); i++) { + if (w == ARRAY_ITEM(&windows, i)) + break; + } + if (i == ARRAY_LENGTH(&windows)) fatalx("index not found"); ARRAY_SET(&windows, i, NULL); while (!ARRAY_EMPTY(&windows) && ARRAY_LAST(&windows) == NULL) -- 2.20.1