Refactor wallmsg() slightly, fixes "unused value" found by Coverity

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-06 06:58:37 +01:00
parent e8674a8fd7
commit 3cff584621

View File

@ -1960,16 +1960,17 @@ void wallmsg(struct filed *f, struct iovec *iov, int iovcnt)
if (setjmp(ttybuf) == 0) {
(void)signal(SIGALRM, endtty);
(void)alarm(15);
/* open the terminal */
ttyf = open(p, O_WRONLY | O_NOCTTY);
if (ttyf >= 0) {
struct stat statb;
struct stat st;
int rc;
if (fstat(ttyf, &statb) == 0 &&
(statb.st_mode & S_IWRITE))
rc = fstat(ttyf, &st);
if (rc == 0 && (st.st_mode & S_IWRITE))
(void)writev(ttyf, iov, iovcnt);
close(ttyf);
ttyf = -1;
}
}
(void)alarm(0);