From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdpzH-0000aW-1a for qemu-devel@nongnu.org; Wed, 28 Nov 2012 17:20:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdpzG-00058C-2Y for qemu-devel@nongnu.org; Wed, 28 Nov 2012 17:20:10 -0500 Received: from mail-ie0-f173.google.com ([209.85.223.173]:61890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdpzF-00057w-Pl for qemu-devel@nongnu.org; Wed, 28 Nov 2012 17:20:09 -0500 Received: by mail-ie0-f173.google.com with SMTP id e13so10389813iej.4 for ; Wed, 28 Nov 2012 14:20:08 -0800 (PST) Sender: fluxion Date: Wed, 28 Nov 2012 16:17:43 -0600 From: mdroth Message-ID: <20121128221743.GO8690@vm> References: <20121128173155.7612b1a4@doriath.home> <1778936997.15910323.1354137989662.JavaMail.root@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1778936997.15910323.1354137989662.JavaMail.root@redhat.com> Subject: Re: [Qemu-devel] [PATCH 03/10] qemu-ga: qmp_guest_file_*: improve error reporting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Luiz Capitulino On Wed, Nov 28, 2012 at 04:26:29PM -0500, Eric Blake wrote: > > > > > 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). Well, if it's primarilly an issue with windows, then I think we're okay relying on it for anything in qga/commands-posix.c at least, as those implementations get swapped out for the implementations in qga/commands-win32.o for win32/mingw builds. We'll need to be wary of this in the future if we end up sharing more code with the win32 port becomes more feature-full though. The comment elsewhere about setmntent() might still apply however. > > > 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 :) >