qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, lersek@redhat.com,
	armbru@redhat.com
Subject: [Qemu-devel] [RFC PATCH] qemu-socket: Use local error variable
Date: Thu, 14 Mar 2013 15:57:37 +0100	[thread overview]
Message-ID: <1363273057-25850-1-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <87a9qg5xjf.fsf@blackfin.pond.sub.org>

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
After rebasing this I saw that Anthony already committed a fix that is
very close to my v1. I don't intend to actually change that code, but as
I've already done this, just for comparison what it would look like with
error propagation. Is this what you meant? I find the result more
confusing, to be honest.
---
 util/qemu-sockets.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 3f12296..f231e9c 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -359,6 +359,7 @@ int inet_connect_opts(QemuOpts *opts, Error **errp,
     int sock = -1;
     bool in_progress;
     ConnectState *connect_state = NULL;
+    Error *local_err = NULL;
 
     res = inet_parse_connect_opts(opts, errp);
     if (!res) {
@@ -373,15 +374,17 @@ int inet_connect_opts(QemuOpts *opts, Error **errp,
     }
 
     for (e = res; e != NULL; e = e->ai_next) {
-        if (error_is_set(errp)) {
-            error_free(*errp);
-            *errp = NULL;
-        }
+
+        Error *ret_err = NULL;
+
         if (connect_state != NULL) {
             connect_state->current_addr = e;
         }
-        sock = inet_connect_addr(e, &in_progress, connect_state, errp);
-        if (in_progress) {
+        sock = inet_connect_addr(e, &in_progress, connect_state, &ret_err);
+        if (error_is_set(&ret_err)) {
+            error_propagate(&local_err, ret_err);
+        } else if (in_progress) {
+            error_free(local_err);
             return sock;
         } else if (sock >= 0) {
             /* non blocking socket immediate success, call callback */
@@ -393,6 +396,11 @@ int inet_connect_opts(QemuOpts *opts, Error **errp,
     }
     g_free(connect_state);
     freeaddrinfo(res);
+    if (sock >= 0) {
+        error_free(local_err);
+    } else {
+        error_propagate(errp, local_err);
+    }
     return sock;
 }
 
-- 
1.8.1.4

  parent reply	other threads:[~2013-03-14 14:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 10:48 [Qemu-devel] [PATCH] qemu-sockets: Fix assertion failure Kevin Wolf
2013-03-06 11:04 ` Paolo Bonzini
2013-03-06 11:11   ` Kevin Wolf
2013-03-06 14:46     ` Laszlo Ersek
2013-03-06 15:04       ` Paolo Bonzini
2013-03-06 15:19         ` Kevin Wolf
2013-03-06 15:38           ` Laszlo Ersek
2013-03-06 15:47             ` Kevin Wolf
2013-03-06 16:04               ` Laszlo Ersek
2013-03-06 15:59           ` Markus Armbruster
2013-03-06 16:43             ` Paolo Bonzini
2013-03-14 14:57             ` Kevin Wolf [this message]
2013-03-14 15:52               ` [Qemu-devel] [RFC PATCH] qemu-socket: Use local error variable Laszlo Ersek
2013-03-15  8:37                 ` Kevin Wolf
2013-03-15 16:55                   ` Laszlo Ersek
2013-03-15 17:55                     ` Kevin Wolf
2013-03-15 18:39                       ` Laszlo Ersek
2013-03-19 20:34       ` [Qemu-devel] [PATCH] qemu-sockets: Fix assertion failure Luiz Capitulino
2013-03-20  8:39         ` Kevin Wolf
2013-03-20 12:57           ` Luiz Capitulino
2013-03-20 13:37             ` Kevin Wolf
2013-03-20 13:52               ` Luiz Capitulino
2013-03-06 15:05     ` Markus Armbruster
2013-03-06 15:05 ` [Qemu-devel] Error ** parameter conventions (was: [PATCH] qemu-sockets: Fix assertion failure) Markus Armbruster

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=1363273057-25850-1-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=lersek@redhat.com \
    --cc=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).