> > > if (ferror(fh)) { > > > + error_setg_errno(err, errno, "failed to read file"); > > > slog("guest-file-read failed, handle: %ld", handle); > > > - error_set(err, QERR_QGA_COMMAND_FAILED, "fread() > > > failed"); > > > } else { > > > > I'm not sure about relying on errno for FILE/f*() functions. C99 > > doesn't > > appear to require setting it for implementations
Correct that C99 doesn't require it, but POSIX _does_ require it. Windows is the biggest system out there where errno is unreliable after failure on FILE operations (but as we DO support mingw, we ARE impacted by the lameness of Microsoft's C library being C89 but not POSIX). > However, the other FILE functions seem safe to me. I'd be very > surprised > if some implementation doesn't set errno on fopen() failure for > example Then you probably haven't experimented much with mingw :)