* [PATCH] Fix type confusion in pkt-line
@ 2007-03-27 10:54 rogan
0 siblings, 0 replies; only message in thread
From: rogan @ 2007-03-27 10:54 UTC (permalink / raw)
To: git; +Cc: Rogan Dawes
From: Rogan Dawes <rogan@dawes.za.net>
We were using unsigend and signed int when we should have been
using size_t and ssize_t.
Signed-off-by: Rogan Dawes <rogan@dawes.za.net>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-03-27 11:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-27 10:54 [PATCH] Fix type confusion in pkt-line rogan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).