aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-12-21 01:46:19 -0500
committerMike Frysinger <vapier@gentoo.org>2021-12-21 01:48:31 -0500
commit8b247dd5d8ec890608e5c2295fc57b45c066e787 (patch)
treea79eb1c346adde1b722b11aaae21fe01d70ccce3 /src
parent8ffc4162e267cf55a8fe789792fc3568fd82ecd7 (diff)
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!
Diffstat (limited to 'src')
-rw-r--r--src/rc/broadcast.c10
1 files changed, 8 insertions, 2 deletions
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);