diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-05 19:29:17 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-05 19:29:17 +0000 |
commit | 35bef7fefd6e8fabf759da7c54d8003210661896 (patch) | |
tree | dff4684b0a630849c27a36dd33b847923baddc85 /src/common/util.c | |
parent | ad6971d3b372ef2fd0727a0665ea29fd9c6862e0 (diff) | |
download | tor-35bef7fefd6e8fabf759da7c54d8003210661896.tar.gz tor-35bef7fefd6e8fabf759da7c54d8003210661896.zip |
make read_all and write_all return ssize_t.
svn:r17194
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/common/util.c b/src/common/util.c index 640239f972..71f899c616 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1357,12 +1357,12 @@ ftime_definitely_before(time_t now, time_t when) * must be 1 if fd was returned by socket() or accept(), and 0 if fd * was returned by open(). Return the number of bytes written, or -1 * on error. Only use if fd is a blocking fd. */ -int +ssize_t write_all(int fd, const char *buf, size_t count, int isSocket) { size_t written = 0; ssize_t result; - tor_assert(count < INT_MAX); /*XXXX021 make returnval an ssize_t */ + tor_assert(count < SSIZE_T_MAX); while (written != count) { if (isSocket) @@ -1373,7 +1373,7 @@ write_all(int fd, const char *buf, size_t count, int isSocket) return -1; written += result; } - return (int)count; + return (ssize_t)count; } /** Read from <b>fd</b> to <b>buf</b>, until we get <b>count</b> bytes @@ -1381,14 +1381,13 @@ write_all(int fd, const char *buf, size_t count, int isSocket) * was returned by socket() or accept(), and 0 if fd was returned by * open(). Return the number of bytes read, or -1 on error. Only use * if fd is a blocking fd. */ -int +ssize_t read_all(int fd, char *buf, size_t count, int isSocket) { - /*XXXX021 return ssize_t. */ size_t numread = 0; ssize_t result; - if (count > SIZE_T_CEILING || count > INT_MAX) + if (count > SIZE_T_CEILING || count > SSIZE_T_MAX) return -1; while (numread != count) { @@ -1402,7 +1401,7 @@ read_all(int fd, char *buf, size_t count, int isSocket) break; numread += result; } - return (int)numread; + return (ssize_t)numread; } /* |