[PATCH] Fix type confusion in pkt-line

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

 



From: Rogan Dawes <rogan@xxxxxxxxxxxx>

We were using unsigend and signed int when we should have been
using size_t and ssize_t.

Signed-off-by: Rogan Dawes <rogan@xxxxxxxxxxxx>
---
 pkt-line.c |   10 +++++-----
 pkt-line.h |    2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pkt-line.c b/pkt-line.c
index b4cb7e2..559a944 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -63,12 +63,12 @@ void packet_write(int fd, const char *fmt, ...)
 	safe_write(fd, buffer, n);
 }
 
-static void safe_read(int fd, void *buffer, unsigned size)
+static void safe_read(int fd, void *buffer, size_t size)
 {
-	int n = 0;
+	size_t n = 0;
 
 	while (n < size) {
-		int ret = xread(fd, (char *) buffer + n, size - n);
+		ssize_t ret = xread(fd, (char *) buffer + n, size - n);
 		if (ret < 0)
 			die("read error (%s)", strerror(errno));
 		if (!ret)
@@ -77,10 +77,10 @@ static void safe_read(int fd, void *buffer, unsigned size)
 	}
 }
 
-int packet_read_line(int fd, char *buffer, unsigned size)
+ssize_t packet_read_line(int fd, char *buffer, size_t size)
 {
 	int n;
-	unsigned len;
+	size_t len;
 	char linelen[4];
 
 	safe_read(fd, linelen, 4);
diff --git a/pkt-line.h b/pkt-line.h
index 9df653f..073fcd4 100644
--- a/pkt-line.h
+++ b/pkt-line.h
@@ -9,7 +9,7 @@
 void packet_flush(int fd);
 void packet_write(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
 
-int packet_read_line(int fd, char *buffer, unsigned size);
+ssize_t packet_read_line(int fd, char *buffer, size_t size);
 ssize_t safe_write(int, const void *, ssize_t);
 
 #endif
-- 
1.5.0.3

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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]