From 8b247dd5d8ec890608e5c2295fc57b45c066e787 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 21 Dec 2021 01:46:19 -0500 Subject: broadcast: fix compiler warnings Newer gcc reports: broadcast.c: In function 'broadcast': broadcast.c:132:15: warning: variable 'tp' might be clobbered by 'longjmp' or 'vfork' [-Wclobbered] 132 | FILE *tp; Move the storage off the stack to avoid. This makes the function not safe for multithread use, but we don't do that anywhere, so who cares! --- src/rc/broadcast.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/rc/broadcast.c') diff --git a/src/rc/broadcast.c b/src/rc/broadcast.c index d9eb7240..402a9fb9 100644 --- a/src/rc/broadcast.c +++ b/src/rc/broadcast.c @@ -117,6 +117,8 @@ static int file_isatty(const char *fname) /* * broadcast function. + * + * NB: Not multithread safe. */ void broadcast(char *text) { @@ -128,11 +130,15 @@ void broadcast(char *text) char *p; char *line = NULL; struct sigaction sa; - volatile int fd; - FILE *tp; int flags; char *term = NULL; struct utmpx *utmp; + /* + * These are set across the sigsetjmp call, so they can't be stored on + * the stack, otherwise they might be clobbered. + */ + static int fd; + static FILE *tp; getuidtty(&user, &tty); -- cgit v1.2.3