qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH 05/11] qemu_fclose: return last_error if set
Date: Wed, 02 Nov 2011 13:15:46 +0100	[thread overview]
Message-ID: <j8rc9j$d4$1@dough.gmane.org> (raw)
In-Reply-To: <20111102115641.GE29718@otherpad.lan.raisama.net>

On 11/02/2011 12:56 PM, Eduardo Habkost wrote:
> No, if it's positive it won't be set on last_error, so we have to save
> it somewhere other than last_error (that's what the qemu_close() return
> value is used for).

Ok, I was confused by your patch 6, which basically removes the only 
case when qemu_fclose was returning a positive, nonzero value. :)  I 
guess the problem is there?

> Without a separate function and qemu_file_set_if_error(), the function
> will look like:
>
> int qemu_fclose(QEMUFile *f)
> {
>      int ret = 0;
>      qemu_fflush();
>      if (f->close) {
>          ret = f->close(f->opaque);
>      }
>      if (f->last_error) {
            ^^^^^^^^^^^^^

"if (ret >= 0 && f->last_error)" perhaps?

>          ret = f->last_error;
>      }
>      g_free(f);
>      return ret;
> }
>
>
> Now that I am looking at the resulting code, it doesn't look too bad. I
> guess I was simply too eager to encapsulate every bit of logic (in this
> case the "if (f->close) ..." part) into separate functions. I find the
> two-function version slightly easier to analyze, though.

Yes, it's the same for me too now that I actually understand what's 
going on.

Paolo

  reply	other threads:[~2011-11-02 12:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01 19:20 [Qemu-devel] [RFC PATCH 00/11] qemu_fclose() error handling fixes Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 01/11] savevm: use qemu_file_set_error() instead of setting last_error directly Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 02/11] QEMUFileCloseFunc: add return value documentation Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 03/11] exec_close(): accept any negative value as qemu_fclose() error Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 04/11] migrate_fd_cleanup: accept any negative qemu_fclose() value as error Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 05/11] qemu_fclose: return last_error if set Eduardo Habkost
2011-11-02  7:33   ` Paolo Bonzini
2011-11-02 11:56     ` Eduardo Habkost
2011-11-02 12:15       ` Paolo Bonzini [this message]
2011-11-02 12:26         ` Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 06/11] stdio_pclose: return -errno on error Eduardo Habkost
2011-11-02 12:32   ` Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 07/11] stdio_fclose: return -errno on errors Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 08/11] exec_close(): " Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 09/11] fd_close(): check for close() errors too Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 10/11] tcp_close(): " Eduardo Habkost
2011-11-01 19:20 ` [Qemu-devel] [RFC PATCH 11/11] unix_close(): " Eduardo Habkost
2011-11-02  9:50 ` [Qemu-devel] [RFC PATCH 00/11] qemu_fclose() error handling fixes Juan Quintela
2011-11-04 16:32 ` Michael Roth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='j8rc9j$d4$1@dough.gmane.org' \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).