From 0c5e3f4c2f95d6a73bf840bc82dd0a1ce91e4016 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 7 Oct 2014 19:16:16 +0000 Subject: [PATCH] signal: Provide generic signal_pre_select(). Identical copies of this function exist in afs.c, gui.c, audiod.c and server.c. This commit defines a generic version as an inline function in signal.h and gets rid of the copies. --- afs.c | 8 +------- audiod.c | 6 ------ gui.c | 6 ------ server.c | 6 ------ signal.h | 6 ++++++ 5 files changed, 7 insertions(+), 25 deletions(-) diff --git a/afs.c b/afs.c index a21a99d0..1d23c9ff 100644 --- a/afs.c +++ b/afs.c @@ -28,8 +28,8 @@ #include "ipc.h" #include "list.h" #include "sched.h" -#include "signal.h" #include "fd.h" +#include "signal.h" #include "mood.h" #include "sideband.h" #include "command.h" @@ -719,12 +719,6 @@ static int open_afs_tables(void) return ret; } -static void signal_pre_select(struct sched *s, void *context) -{ - struct signal_task *st = context; - para_fd_set(st->fd, &s->rfds, &s->max_fileno); -} - static int afs_signal_post_select(struct sched *s, __a_unused void *context) { int signum, ret; diff --git a/audiod.c b/audiod.c index 77d21f37..4285dd5e 100644 --- a/audiod.c +++ b/audiod.c @@ -990,12 +990,6 @@ err: exit(EXIT_FAILURE); } -static void signal_pre_select(struct sched *s, void *context) -{ - struct signal_task *st = context; - para_fd_set(st->fd, &s->rfds, &s->max_fileno); -} - static int signal_post_select(struct sched *s, void *context) { struct signal_task *st = context; diff --git a/gui.c b/gui.c index 5d1a1b62..620367e5 100644 --- a/gui.c +++ b/gui.c @@ -1132,12 +1132,6 @@ static int input_post_select(__a_unused struct sched *s, __a_unused void *contex return 0; } -static void signal_pre_select(struct sched *s, void *context) -{ - struct signal_task *st = context; - para_fd_set(st->fd, &s->rfds, &s->max_fileno); -} - static void print_scroll_msg(void) { unsigned lines_total, filled = ringbuffer_filled(bot_win_rb); diff --git a/server.c b/server.c index 6c2cbb87..a048cfda 100644 --- a/server.c +++ b/server.c @@ -227,12 +227,6 @@ out: exit(EXIT_FAILURE); } -static void signal_pre_select(struct sched *s, void *context) -{ - struct signal_task *st = context; - para_fd_set(st->fd, &s->rfds, &s->max_fileno); -} - /* * called when server gets SIGHUP or when client invokes hup command. */ diff --git a/signal.h b/signal.h index 1e562af7..643c148f 100644 --- a/signal.h +++ b/signal.h @@ -16,6 +16,12 @@ struct signal_task { struct task *task; }; +_static_inline_ void signal_pre_select(struct sched *s, void *context) +{ + struct signal_task *st = context; + para_fd_set(st->fd, &s->rfds, &s->max_fileno); +} + int para_signal_init(void); void para_sigaction(int sig, void (*handler)(int)); void para_install_sighandler(int); -- 2.39.5