diff options
author | dd <dd@FreeBSD.org> | 2001-09-09 14:23:31 +0000 |
---|---|---|
committer | dd <dd@FreeBSD.org> | 2001-09-09 14:23:31 +0000 |
commit | 2b3c9b55980d5dfe320041f119eeaf561de21a68 (patch) | |
tree | 9070eaf46f66b04432ac1266b4cac2bf26ae865b /usr.bin/wall | |
parent | 99476df91e28e03e04f238b1de280770d658d762 (diff) | |
download | FreeBSD-src-2b3c9b55980d5dfe320041f119eeaf561de21a68.zip FreeBSD-src-2b3c9b55980d5dfe320041f119eeaf561de21a68.tar.gz |
- Move the prototype of ttymsg() into ttymsg.h. syslogd and talkd
also use this, and they shouldn't have to have their own prototypes.
- Silence warnings about constness and signedness in ttymsg(). This
includes changing the return value to a `const char *', and changing
the types of `left' and `wret' (both byte counts) to ssize_t.
Reviewed by: bde
Diffstat (limited to 'usr.bin/wall')
-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]; |