On Wed, Feb 14, 2018 at 2:39 PM, Markus Wichmann wrote: > On Wed, Feb 14, 2018 at 04:24:16PM -0200, Geraldo Netto wrote: > > Dear Friends, > > > > I was playing with musl and I think I may have found an issue on > fwrite(): > > > > This is the original code: > > > > size_t fwrite(const void *restrict src, size_t size, size_t nmemb, > > FILE *restrict f) > > { > > size_t k, l = size*nmemb; > > if (!size) nmemb = 0; > > FLOCK(f); > > k = __fwritex(src, l, f); > > FUNLOCK(f); > > return k==l ? nmemb : k/size; > > } > > > > If size is zero, then l is zero. So __fwritex will be called with l as > zero. Which means, if you read that code, that it will have to return > zero. Why not early return if size == 0 and avoid the call to __fwritex altogether? -- Andrew Bell andrew.bell.ia@gmail.com