[PATCH 3/5] ttymsg: fix compiler warnings and use EXIT_

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 term-utils/ttymsg.c |   18 ++++++++++--------
 term-utils/ttymsg.h |    2 +-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/term-utils/ttymsg.c b/term-utils/ttymsg.c
index a4df59e..9484536 100644
--- a/term-utils/ttymsg.c
+++ b/term-utils/ttymsg.c
@@ -64,10 +64,12 @@
  * 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;
+	register int fd;
+	register size_t cnt, left;
+	register ssize_t wret;
 	struct iovec localiov[6];
 	int forked = 0, errsv;
 
@@ -106,7 +108,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 +117,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 +134,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 +171,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 +186,6 @@ ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout) {
 
 	(void) close(fd);
 	if (forked)
-		_exit(0);
+		_exit(EXIT_SUCCESS);
 	return (NULL);
 }
diff --git a/term-utils/ttymsg.h b/term-utils/ttymsg.h
index 5d27951..2cfa730 100644
--- a/term-utils/ttymsg.h
+++ b/term-utils/ttymsg.h
@@ -1,2 +1,2 @@
-char *ttymsg(struct iovec *iov, int iovcnt, char *line, int tmout);
+char *ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout);
 
-- 
1.7.4.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux