summaryrefslogtreecommitdiffstats
path: root/term-utils/ttymsg.c
diff options
context:
space:
mode:
authorSami Kerola2011-04-06 21:31:02 +0200
committerKarel Zak2011-04-12 11:19:15 +0200
commit5e6bf8008bbc605929e5b884dc92b6c08b80d57b (patch)
tree858ec8f4e74be572ca2bd812472ade30fb0258e2 /term-utils/ttymsg.c
parentwall: use long options (diff)
downloadkernel-qcow2-util-linux-5e6bf8008bbc605929e5b884dc92b6c08b80d57b.tar.gz
kernel-qcow2-util-linux-5e6bf8008bbc605929e5b884dc92b6c08b80d57b.tar.xz
kernel-qcow2-util-linux-5e6bf8008bbc605929e5b884dc92b6c08b80d57b.zip
ttymsg: fix compiler warnings and use EXIT_
[kzak@redhat.com: - remove 'register' storage class specifier] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/ttymsg.c')
-rw-r--r--term-utils/ttymsg.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/term-utils/ttymsg.c b/term-utils/ttymsg.c
index a4df59e6c..b5c197327 100644
--- a/term-utils/ttymsg.c
+++ b/term-utils/ttymsg.c
@@ -64,12 +64,13 @@
* ignored (exclusive-use, lack of permission, etc.).
*/
char *
-ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
+ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
static char device[MAXNAMLEN];
static char errbuf[MAXNAMLEN+1024];
- register int cnt, fd, left, wret;
+ size_t cnt, left;
+ ssize_t wret;
struct iovec localiov[6];
- int forked = 0, errsv;
+ int fd, forked = 0, errsv;
if (iovcnt > sizeof(localiov) / sizeof(localiov[0]))
return (_("too many iov's (change code in wall/ttymsg.c)"));
@@ -106,7 +107,7 @@ ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
for (;;) {
wret = writev(fd, iov, iovcnt);
- if (wret >= left)
+ if (wret >= (ssize_t) left)
break;
if (wret >= 0) {
left -= wret;
@@ -115,13 +116,13 @@ ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
iovcnt * sizeof(struct iovec));
iov = localiov;
}
- for (cnt = 0; wret >= iov->iov_len; ++cnt) {
+ for (cnt = 0; wret >= (ssize_t) iov->iov_len; ++cnt) {
wret -= iov->iov_len;
++iov;
--iovcnt;
}
if (wret) {
- iov->iov_base += wret;
+ iov->iov_base = (char *) iov->iov_base + wret;
iov->iov_len -= wret;
}
continue;
@@ -132,7 +133,7 @@ ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
if (forked) {
(void) close(fd);
- _exit(1);
+ _exit(EXIT_FAILURE);
}
cpid = fork();
if (cpid < 0) {
@@ -169,7 +170,7 @@ ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
break;
(void) close(fd);
if (forked)
- _exit(1);
+ _exit(EXIT_FAILURE);
if (strlen(strerror(errno)) > 1000)
(void) sprintf(errbuf, _("%s: BAD ERROR, message is "
"far too long"), device);
@@ -184,6 +185,6 @@ ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
(void) close(fd);
if (forked)
- _exit(0);
+ _exit(EXIT_SUCCESS);
return (NULL);
}