[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Fix return value of tor_fd_seekend.
commit 7c61d10c6c09b32a4b8acd2553aa05c4fbc06611
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed Aug 20 13:48:17 2014 -0400
Fix return value of tor_fd_seekend.
Previously, we had documented it to return -1 or 0, when in fact
lseek returns -1 or the new position in the file.
This is harmless, since we were only checking for negative values
when we used tor_fd_seekend.
---
src/common/compat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/common/compat.c b/src/common/compat.c
index eb9a70f..278e5c5 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -990,14 +990,14 @@ tor_fd_seekend(int fd)
#ifdef _WIN32
return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
#else
- int rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
+ off_t rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
#ifdef ESPIPE
/* If we get an error and ESPIPE, then it's a pipe or a socket of a fifo:
* no need to worry. */
if (rc < 0 && errno == ESPIPE)
rc = 0;
#endif
- return rc;
+ return (rc < 0) ? -1 : 0;
#endif
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits