_IO_wfile_underflow_mmap error/eof case

Roland McGrath roland@frob.com
Tue Jul 30 15:32:00 GMT 2002


> Roland McGrath wrote:
> > It seems to me that:
> > 
> >       fp->_flags |= _IO_EOF_SEEN;
> > 
> > in _IO_wfile_underflow_mmap is wrong.  In that case,
> > _IO_file_underflow_mmap has already set either the EOF or ERROR flag bit.
> > If there was an error rather than EOF, the EOF bit should not be set too.
> > Am I missing something or should I remove this line?
> 
> Might just be a copy&paste thing.  Is it noticeable from user code?  Or 
> the other way around: do you have code which stresses this code?

I just noticed the issue when reading over the code.  It would be
noticeable if the case I mentioned were to happen (instead of ferror(fp)=1
and feof(fp)=0 it would produce ferror(fp)=1 and feof(fp)=1).  The only way
this case comes up is if there is a failure in the lseek system call made
in _IO_file_underflow_mmap.  So I'm not sure there is a practical way to
see it in a test program (without doing something definitely bogus and
undefined/unspecified like closing the fd from under it).



More information about the Libc-hacker mailing list