From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLVK5-0002W3-Ob for qemu-devel@nongnu.org; Wed, 02 Nov 2011 03:33:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLVK4-0006xC-IX for qemu-devel@nongnu.org; Wed, 02 Nov 2011 03:33:21 -0400 Received: from lo.gmane.org ([80.91.229.12]:57968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLVK4-0006wu-DS for qemu-devel@nongnu.org; Wed, 02 Nov 2011 03:33:20 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RLVK0-0000Zi-UF for qemu-devel@nongnu.org; Wed, 02 Nov 2011 08:33:16 +0100 Received: from 93-34-200-62.ip51.fastwebnet.it ([93.34.200.62]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 02 Nov 2011 08:33:16 +0100 Received: from pbonzini by 93-34-200-62.ip51.fastwebnet.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 02 Nov 2011 08:33:16 +0100 From: Paolo Bonzini Date: Wed, 02 Nov 2011 08:33:05 +0100 Message-ID: References: <1320175230-27980-1-git-send-email-ehabkost@redhat.com> <1320175230-27980-6-git-send-email-ehabkost@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit In-Reply-To: <1320175230-27980-6-git-send-email-ehabkost@redhat.com> Subject: Re: [Qemu-devel] [RFC PATCH 05/11] qemu_fclose: return last_error if set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On 11/01/2011 08:20 PM, Eduardo Habkost wrote: > +/** Calls close function and set last_error if needed > + * > + * Internal function. qemu_fflush() must be called before this. > + * > + * Returns f->close() return value, or 0 if close function is not set. > + */ > +static int qemu_close(QEMUFile *f) > { > int ret = 0; > - qemu_fflush(f); > - if (f->close) > + if (f->close) { > ret = f->close(f->opaque); > + qemu_file_set_if_error(f, ret); > + } > + return ret; > +} > + > +/** Closes the file > + * > + * Returns negative error value if any error happened on previous operations or > + * while closing the file. Returns 0 or positive number on success. > + * > + * The meaning of return value on success depends on the specific backend > + * being used. > + */ > +int qemu_fclose(QEMUFile *f) > +{ > + int ret; > + qemu_fflush(f); > + ret = qemu_close(f); Isn't the return value of qemu_close useless, because if nonzero it will always be present in last_error too? With this change, I'd leave it inline. > + if (f->last_error) > + ret = f->last_error; > g_free(f); > return ret; Paolo