From 05633c9bc32c398139372ff127db4a7ae30621e2 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Tue, 22 Aug 2017 22:48:06 +1000 Subject: [PATCH] Consistently use SIGNAL_HANDLER() macro to define signal handler functions With this change, the signal handler signature is defined in only one place. Also make most signal handler functions static (those that are only referred to in irc.c). --- include/irc_std.h | 6 +++--- include/ircterm.h | 2 +- include/screen.h | 1 - source/irc.c | 20 +++++++++----------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/include/irc_std.h b/include/irc_std.h index a5aaccc..486dba5 100644 --- a/include/irc_std.h +++ b/include/irc_std.h @@ -160,12 +160,12 @@ typedef int socklen_t; #include -typedef RETSIGTYPE sigfunc (int); -sigfunc *my_signal (int, sigfunc *, int); - #define SIGNAL_HANDLER(x) \ RETSIGTYPE x (int unused) +typedef SIGNAL_HANDLER(sigfunc); +sigfunc *my_signal (int, sigfunc *, int); + #include #define index strchr diff --git a/include/ircterm.h b/include/ircterm.h index 070a30c..a8b9932 100644 --- a/include/ircterm.h +++ b/include/ircterm.h @@ -709,7 +709,7 @@ extern char default_pair[2]; #endif #endif - RETSIGTYPE term_cont (int); +SIGNAL_HANDLER(term_cont); void term_beep (void); int term_echo (int); int term_init (char *); diff --git a/include/screen.h b/include/screen.h index 79758c7..b4cfb9d 100644 --- a/include/screen.h +++ b/include/screen.h @@ -40,7 +40,6 @@ void window_redirect (char *, int); void redraw_resized (Window *, ShrinkInfo, int); void close_all_screen (void); -RETSIGTYPE sig_refresh_screen (int); int check_screen_redirect (char *); void BX_kill_screen (Screen *); ShrinkInfo resize_display (Window *); diff --git a/source/irc.c b/source/irc.c index 28c7378..956fc90 100644 --- a/source/irc.c +++ b/source/irc.c @@ -350,16 +350,14 @@ void reset_clock(Window *win, char *unused, int unused1) update_all_status(win, NULL, 0); } - - /* sig_refresh_screen: the signal-callable version of refresh_screen */ -SIGNAL_HANDLER(sig_refresh_screen) +static SIGNAL_HANDLER(sig_refresh_screen) { refresh_screen(0, NULL); } /* irc_exit: cleans up and leaves */ -SIGNAL_HANDLER(irc_exit_old) +static SIGNAL_HANDLER(irc_exit_old) { irc_exit(1,NULL, NULL); } @@ -377,7 +375,7 @@ SIGNAL_HANDLER(child_reap) #endif } -SIGNAL_HANDLER(nothing) +static SIGNAL_HANDLER(nothing) { /* nothing to do! */ } @@ -390,11 +388,11 @@ static int sigpipe_hit = 0; } #if 0 -SIGNAL_HANDLER(sigusr2) +static SIGNAL_HANDLER(sigusr2) { mtrace(); } -SIGNAL_HANDLER(sigusr3) +static SIGNAL_HANDLER(sigusr3) { muntrace(); } @@ -467,7 +465,7 @@ void BX_irc_exit (int really_quit, char *reason, char *format, ...) volatile int segv_recurse = 0; /* sigsegv: something to handle segfaults in a nice way */ /* this needs to be changed to *NOT* use printf(). */ -SIGNAL_HANDLER(coredump) +static SIGNAL_HANDLER(coredump) { #if defined(WINNT) extern char *sys_siglist[]; @@ -519,7 +517,7 @@ void irc_quit(char key, char * ptr) * cntl_c: emergency exit.... if somehow everything else freezes up, hitting * ^C five times should kill the program. */ -SIGNAL_HANDLER(cntl_c) +static SIGNAL_HANDLER(cntl_c) { if (cntl_c_hit++ >= 4) @@ -528,7 +526,7 @@ SIGNAL_HANDLER(cntl_c) kill(getpid(), SIGALRM); } -SIGNAL_HANDLER(sig_user1) +static SIGNAL_HANDLER(sig_user1) { bitchsay("Got SIGUSR1, closing DCC connections and EXECed processes"); close_all_dcc(); @@ -536,7 +534,7 @@ SIGNAL_HANDLER(sig_user1) } -SIGNAL_HANDLER(sig_detach) +static SIGNAL_HANDLER(sig_detach) { detachcmd(NULL, NULL, NULL, NULL); }