From: rogan@dawes.za.net
To: git@vger.kernel.org
Cc: Rogan Dawes <rogan@dawes.za.net>
Subject: [PATCH] Fix type confusion in pkt-line
Date: Tue, 27 Mar 2007 03:54:07 -0700 [thread overview]
Message-ID: <1174992847659-git-send-email-rogan@dawes.za.net> (raw)
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
reply other threads:[~2007-03-27 11:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1174992847659-git-send-email-rogan@dawes.za.net \
--to=rogan@dawes.za.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).