From: Heikki Orsila <heikki.orsila@iki.fi>
To: git@vger.kernel.org
Subject: [RFC] Make read_in_full() and write_in_full() consistent with xread() and xwrite()
Date: Sun, 27 Apr 2008 21:21:58 +0300 [thread overview]
Message-ID: <20080427182158.GA29232@zakalwe.fi> (raw)
Requesting comments on the following patch.
xread() and xwrite() return ssize_t values as their native POSIX
counterparts. To be consistent, read_in_full() and write_in_full()
should also return ssize_t values.
Should we make file APIs more consistent?
---
cache.h | 4 ++--
path.c | 3 ++-
refs.c | 3 ++-
write_or_die.c | 4 ++--
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/cache.h b/cache.h
index 3fcc283..5a28ddd 100644
--- a/cache.h
+++ b/cache.h
@@ -726,8 +726,8 @@ extern const char *git_log_output_encoding;
extern void maybe_flush_or_die(FILE *, const char *);
extern int copy_fd(int ifd, int ofd);
extern int copy_file(const char *dst, const char *src, int mode);
-extern int read_in_full(int fd, void *buf, size_t count);
-extern int write_in_full(int fd, const void *buf, size_t count);
+extern ssize_t read_in_full(int fd, void *buf, size_t count);
+extern ssize_t write_in_full(int fd, const void *buf, size_t count);
extern void write_or_die(int fd, const void *buf, size_t count);
extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
diff --git a/path.c b/path.c
index 2ae7cd9..b7c24a2 100644
--- a/path.c
+++ b/path.c
@@ -91,7 +91,8 @@ int validate_headref(const char *path)
struct stat st;
char *buf, buffer[256];
unsigned char sha1[20];
- int len, fd;
+ int fd;
+ ssize_t len;
if (lstat(path, &st) < 0)
return -1;
diff --git a/refs.c b/refs.c
index 1b0050e..4db73ed 100644
--- a/refs.c
+++ b/refs.c
@@ -368,7 +368,8 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *flag)
{
- int depth = MAXDEPTH, len;
+ int depth = MAXDEPTH;
+ ssize_t len;
char buffer[256];
static char ref_buffer[256];
diff --git a/write_or_die.c b/write_or_die.c
index e125e11..32f9914 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -40,7 +40,7 @@ void maybe_flush_or_die(FILE *f, const char *desc)
}
}
-int read_in_full(int fd, void *buf, size_t count)
+ssize_t read_in_full(int fd, void *buf, size_t count)
{
char *p = buf;
ssize_t total = 0;
@@ -57,7 +57,7 @@ int read_in_full(int fd, void *buf, size_t count)
return total;
}
-int write_in_full(int fd, const void *buf, size_t count)
+ssize_t write_in_full(int fd, const void *buf, size_t count)
{
const char *p = buf;
ssize_t total = 0;
--
1.5.4.4
next reply other threads:[~2008-04-27 18:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-27 18:21 Heikki Orsila [this message]
2008-04-30 9:23 ` [RFC] Make read_in_full() and write_in_full() consistent with xread() and xwrite() Junio C Hamano
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=20080427182158.GA29232@zakalwe.fi \
--to=heikki.orsila@iki.fi \
--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).