> From: Andy Wingo <wi...@pobox.com> > Cc: Eli Zaretskii <e...@gnu.org>, egg...@cs.ucla.edu, bug-gnulib@gnu.org > Date: Thu, 21 Feb 2013 17:47:43 +0100 > > On Thu 21 Feb 2013 17:29, Paolo Bonzini <bonz...@gnu.org> writes: > > > Il 20/02/2013 20:58, Andy Wingo ha scritto: > >> > >> if (full_read (fd, cookie, sizeof cookie) != sizeof cookie > >> || full_read (fd, SCM_BYTEVECTOR_CONTENTS (bv), > >> SCM_BYTEVECTOR_LENGTH (bv)) != SCM_BYTEVECTOR_LENGTH > >> (bv)) > >> { > >> int errno_save = errno; > >> (void) close (fd); > >> errno = errno_save; > >> if (errno) > >> SCM_SYSERROR; > >> scm_misc_error (FUNC_NAME, "file truncated while reading", > >> SCM_EOL); > >> } > > > > Doesn't it need to set errno to zero before calling full_read? > > Not sure! If full_read requires that errno be 0 going in, then yes, we > should. Is this a requirement?
AFAIK, you cannot rely on tests that compare errno with zero, unless you reset it to zero before the operation that might set it. > Otherwise, full_read sets errno to 0 if it returns a length less than > the length we asked for Where does it do that? I don't think I see this. Maybe I'm blind.