mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
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.
This commit is contained in:
parent
a32913d5aa
commit
7c61d10c6c
@ -990,14 +990,14 @@ tor_fd_seekend(int fd)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
|
return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
|
||||||
#else
|
#else
|
||||||
int rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
|
off_t rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
|
||||||
#ifdef ESPIPE
|
#ifdef ESPIPE
|
||||||
/* If we get an error and ESPIPE, then it's a pipe or a socket of a fifo:
|
/* If we get an error and ESPIPE, then it's a pipe or a socket of a fifo:
|
||||||
* no need to worry. */
|
* no need to worry. */
|
||||||
if (rc < 0 && errno == ESPIPE)
|
if (rc < 0 && errno == ESPIPE)
|
||||||
rc = 0;
|
rc = 0;
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return (rc < 0) ? -1 : 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user