diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-06-23 14:44:54 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-06-23 14:44:54 +0000 |
commit | 56066894b7d14f71aeba8379f0d6e5961dee733e (patch) | |
tree | d2ad93979e0ca63acdadfdc03384d4f1fc106d53 /src/libstddjb/buffer_get.c | |
parent | 7a9e5888e9b721452869e35b83e74b36844d3cfd (diff) | |
download | skalibs-56066894b7d14f71aeba8379f0d6e5961dee733e.tar.xz |
Apply fixes suggested by jjk
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/buffer_get.c')
-rw-r--r-- | src/libstddjb/buffer_get.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstddjb/buffer_get.c b/src/libstddjb/buffer_get.c index fbc0de3..6fe394d 100644 --- a/src/libstddjb/buffer_get.c +++ b/src/libstddjb/buffer_get.c @@ -1,12 +1,13 @@ /* ISC license. */ -#include <errno.h> +#include <stddef.h> + +#include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> ssize_t buffer_get (buffer *b, char *s, size_t len) { size_t w = 0 ; - int r = buffer_getall(b, s, len, &w) ; - return r == -1 ? errno == EPIPE ? (errno = 0, w) : -1 : - !r ? (errno = EWOULDBLOCK, -1) : w ; + ssize_t r = unsanitize_read(buffer_getall(b, s, len, &w)) ; + return r < 0 ? r : w ; } |