diff options
-rw-r--r-- | usr.bin/wall/ttymsg.c | 13 | ||||
-rw-r--r-- | usr.bin/wall/ttymsg.h | 3 | ||||
-rw-r--r-- | usr.bin/wall/wall.c | 6 |
3 files changed, 15 insertions, 7 deletions
diff --git a/usr.bin/wall/ttymsg.c b/usr.bin/wall/ttymsg.c index c65cfe8..c03454e 100644 --- a/usr.bin/wall/ttymsg.c +++ b/usr.bin/wall/ttymsg.c @@ -51,6 +51,8 @@ static const char rcsid[] = #include <stdlib.h> #include <unistd.h> +#include "ttymsg.h" + /* * Display the contents of a uio structure on a terminal. Used by wall(1), * syslogd(8), and talkd(8). Forks and finishes in child if write would block, @@ -58,17 +60,18 @@ static const char rcsid[] = * error; string is not newline-terminated. Various "normal" errors are * ignored (exclusive-use, lack of permission, etc.). */ -char * +const char * ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout) { struct iovec localiov[7]; - int cnt, fd, left, wret; + ssize_t left, wret; + int cnt, fd; static char device[MAXNAMLEN] = _PATH_DEV; static char errbuf[1024]; int forked; forked = 0; - if (iovcnt > sizeof(localiov) / sizeof(localiov[0])) + if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0]))) return ("too many iov's (change code in wall/ttymsg.c)"); strlcpy(device + sizeof(_PATH_DEV) - 1, line, sizeof(device)); @@ -91,7 +94,7 @@ ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout) return (errbuf); } - for (cnt = left = 0; cnt < iovcnt; ++cnt) + for (cnt = 0, left = 0; cnt < iovcnt; ++cnt) left += iov[cnt].iov_len; for (;;) { @@ -105,7 +108,7 @@ ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout) iovcnt * sizeof(struct iovec)); iov = localiov; } - for (cnt = 0; wret >= iov->iov_len; ++cnt) { + for (cnt = 0; (size_t)wret >= iov->iov_len; ++cnt) { wret -= iov->iov_len; ++iov; --iovcnt; diff --git a/usr.bin/wall/ttymsg.h b/usr.bin/wall/ttymsg.h new file mode 100644 index 0000000..31312aa --- /dev/null +++ b/usr.bin/wall/ttymsg.h @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +const char *ttymsg(struct iovec *, int, const char *, int); diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index b2eec29..3e25676 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -67,9 +67,10 @@ static const char rcsid[] = #include <unistd.h> #include <utmp.h> +#include "ttymsg.h" + static void makemsg(char *); static void usage(void); -char *ttymsg(struct iovec *, int, const char *, int); #define IGNOREUSER "sleeper" @@ -92,7 +93,8 @@ main(int argc, char *argv[]) FILE *fp; struct wallgroup *g; struct group *grp; - char *p, **np; + char **np; + const char *p; struct passwd *pw; char line[sizeof(utmp.ut_line) + 1]; char username[sizeof(utmp.ut_name) + 1]; |