From: trinity-1686a Date: Sun, 18 Feb 2024 11:37:59 +0000 (+0100) Subject: make read_file_to_str_until_eof doc more explicit X-Git-Tag: tor-0.4.9.1-alpha~54^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e913de1bc651bbe5171760ffbe6926a43650f5d0;p=thirdparty%2Ftor.git make read_file_to_str_until_eof doc more explicit the sz_out param is set to what was read (i.e not including the final NULL the function adds for convenience), but could be understood to be set to what was read+1 (including the NULL terminator) --- diff --git a/src/lib/fs/files.c b/src/lib/fs/files.c index 55f20dd49e..df59222913 100644 --- a/src/lib/fs/files.c +++ b/src/lib/fs/files.c @@ -572,9 +572,10 @@ write_bytes_to_new_file(const char *fname, const char *str, size_t len, /** * Read the contents of the open file fd presuming it is a FIFO * (or similar) file descriptor for which the size of the file isn't - * known ahead of time. Return NULL on failure, and a NUL-terminated - * string on success. On success, set sz_out to the number of - * bytes read. + * known ahead of time. + * Return NULL on failure, and a NUL-terminated string on success. + * On success, set sz_out to the number of bytes read (not including + * the final NULL, which wasn't read from fd). */ char * read_file_to_str_until_eof(int fd, size_t max_bytes_to_read, size_t *sz_out)