X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Ffwrite.c;h=7a567b2c55a94b30288444bd93f6fc48fff7e433;hb=c9ebff4736128186121424364c1c62224b02aee3;hp=d5f6542d6bebe32ec6dac9ac319e8eaf430dfcd4;hpb=c6d441e3a246370d9c459396ec22b096db93850e;p=musl diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index d5f6542d..7a567b2c 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -13,8 +13,8 @@ size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) /* Match /^(.*\n|)/ */ for (i=l; i && s[i-1] != '\n'; i--); if (i) { - if (f->write(f, s, i) < i) - return i; + size_t n = f->write(f, s, i); + if (n < i) return n; s += i; l -= i; } @@ -28,7 +28,7 @@ size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) size_t fwrite(const void *restrict src, size_t size, size_t nmemb, FILE *restrict f) { size_t k, l = size*nmemb; - if (!l) return l; + if (!size) nmemb = 0; FLOCK(f); k = __fwritex(src, l, f); FUNLOCK(f);