Sebastien Marie wrote:
> When looking at fread(3) code in libc, I found that we doesn't set
> __SEOF when the FILE is unbuffered.
>
> src/lib/libc/stdio/fread.c
> 72 if ((fp->_flags & __SNBF) != 0) {
> 73 /*
> 74 * We know if we're unbuffered that our buffer is
> empty, so
> 75 * we can just read directly. This is much faster
> than the
> 76 * loop below which will perform a series of one byte
> reads.
> 77 */
> 78 while (resid > 0 && (r = (*fp->_read)(fp->_cookie, p,
> resid)) > 0) {
> 79 p += r;
> 80 resid -= r;
> 81 }
> 82 FUNLOCKFILE(fp);
> 83 return ((total - resid) / size);
> 84 }
> Is it a bug to not set the __SEOF flag or it is expected for unbuffered
> FILE ?
seems like a bug. the code above was added more recently, and must have missed
this case.