musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/stdio/fread.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018年02月24日 10:51:16 -0500
committerRich Felker <dalias@aerifal.cx>2018年02月24日 10:51:16 -0500
commitf92804188eb464536d638548e51e835b6c49e373 (patch)
treeb5f290463be7b7adbe63d1b2ed9544102591a1a7 /src/stdio/fread.c
parent9bf9c732f9d39d691e1f8841e7204c9c26321946 (diff)
downloadmusl-f92804188eb464536d638548e51e835b6c49e373.tar.gz
consistently return number of bytes read from stdio read backend
the stdio FILE read backend's return type is size_t, not ssize_t, and all of the special (non-fd-backed) FILE types already return the number of bytes read (zero) on error or eof. only __stdio_read leaked a syscall error return into its return value. fread had a workaround for this behavior going all the way back to the original check-in. remove the workaround since it's no longer needed.
Diffstat (limited to 'src/stdio/fread.c')
-rw-r--r--src/stdio/fread.c 2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/stdio/fread.c b/src/stdio/fread.c
index aef75f73..733d3716 100644
--- a/src/stdio/fread.c
+++ b/src/stdio/fread.c
@@ -25,7 +25,7 @@ size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f)
/* Read the remainder directly */
for (; l; l-=k, dest+=k) {
k = __toread(f) ? 0 : f->read(f, dest, l);
- if (k+1<=1) {
+ if (!k) {
FUNLOCK(f);
return (len-l)/size;
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月27日 17:15:16 +0000

AltStyle によって変換されたページ (->オリジナル) /