[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC PATCH v2 14/17] xenconsoled: deduplicate error handling



Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
---
 tools/console/daemon/io.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index c2c37dc..ea07442 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -819,9 +819,7 @@ static int console_create_ring(struct console *con)
 
        if (rc == -1) {
                err = errno;
-               xenevtchn_close(con->xce_handle);
-               con->xce_handle = NULL;
-               goto out;
+               goto err_xce;
        }
        con->local_port = rc;
        con->remote_port = remote_port;
@@ -829,11 +827,7 @@ static int console_create_ring(struct console *con)
        if (con->master_fd == -1) {
                if (!console_create_tty(con)) {
                        err = errno;
-                       xenevtchn_close(con->xce_handle);
-                       con->xce_handle = NULL;
-                       con->local_port = -1;
-                       con->remote_port = -1;
-                       goto out;
+                       goto err_xce;
                }
        }
 
@@ -843,6 +837,13 @@ static int console_create_ring(struct console *con)
        /* if everything ok, signal backend readiness, in backend tree */
        set_backend_state(con, XenbusStateConnected);
 
+ err_xce:
+       if (err) {
+               xenevtchn_close(con->xce_handle);
+               con->xce_handle = NULL;
+               con->local_port = -1;
+               con->remote_port = -1;
+       }
  out:
        return err;
 }
-- 
git-series 0.9.1

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.