Welcome to little lamb

Code » limb » commit 05edaae

doc: Fix buffer_get() description on error

author Olivier Brunel
2023-07-29 07:43:57 UTC
committer Olivier Brunel
2023-08-10 12:54:14 UTC
parent 5fafae761e4cadd439b9ffbcc82019cd00a94160

doc: Fix buffer_get() description on error

It does /not/ return the amount of data copied on error to fill the
buffer, but -1. The amount of data copied is then unknown.
It only returns less than requested on EOF.

(Only using buffer_getall does one get to know how much was copied, even
on error.)

src/doc/buffer.h/buffer_get.3.md +2 -8

diff --git a/src/doc/buffer.h/buffer_get.3.md b/src/doc/buffer.h/buffer_get.3.md
index fa4ae0d..50845e4 100644
--- a/src/doc/buffer.h/buffer_get.3.md
+++ b/src/doc/buffer.h/buffer_get.3.md
@@ -30,13 +30,7 @@ int buffer_getvallnofill(buffer *<em>buf</em>, const struct iovec *<em>v</em>, u
 The `buffer_get`() function will copy into the memory pointed by `dst` of length
 `dlen` data from the buffer pointed by `buf`. It will try to put as much data as
 possible, i.e. place `dlen` bytes, filing the buffer if needed. It might copy
-less in case of failure to fill the buffer or when end-of-file was reached.
-
-Note that when an error occurs trying to read from the associated file
-descriptor to fill the buffer, it will return the amount of data copied if any
-(including from the buffer's internal memory), and only return -1 if an error
-occurred whilst no data was copied (i.e. the buffer is empty and no data could
-be read from the file descriptor).
+less if end-of-file was reached.
 
 Any data copied from the buffer is then "removed" from it, i.e. the
 corresponding space in the buffer's internal memory becomes available.
@@ -74,7 +68,7 @@ of length `vlen`.
 
 The `buffer_get`() and `buffer_getv`() functions return the size of data read
 from the buffer (and copied into the specified location(s)) on success, which
-may be less than requested.
+may be less than requested if end-of-file was reached.
 Otherwise they return -1 and set `errno` to indicate the error.
 
 The `buffer_getall`() and `buffer_getvall`() functions return 1 when all