All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Andryuk <jandryuk@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	marmarek@invisiblethingslab.com, Wei Liu <wl@xen.org>,
	Jason Andryuk <jandryuk@gmail.com>
Subject: [PATCH 3/8] vchan-socket-proxy: Unify main return value
Date: Sun, 24 May 2020 22:49:50 -0400	[thread overview]
Message-ID: <20200525024955.225415-4-jandryuk@gmail.com> (raw)
In-Reply-To: <20200525024955.225415-1-jandryuk@gmail.com>

Introduce 'ret' for main's return value and remove direct returns.  This
is in preparation for a unified exit path with resource cleanup.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/libvchan/vchan-socket-proxy.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/libvchan/vchan-socket-proxy.c b/tools/libvchan/vchan-socket-proxy.c
index bd12632311..d85e24ee93 100644
--- a/tools/libvchan/vchan-socket-proxy.c
+++ b/tools/libvchan/vchan-socket-proxy.c
@@ -381,6 +381,7 @@ int main(int argc, char **argv)
     const char *vchan_path;
     const char *state_path = NULL;
     int opt;
+    int ret;
 
     while ((opt = getopt_long(argc, argv, "m:vs:", options, NULL)) != -1) {
         switch (opt) {
@@ -447,6 +448,8 @@ int main(int argc, char **argv)
         xs_close(xs);
     }
 
+    ret = 0;
+
     for (;;) {
         if (is_server) {
             /* wait for vchan connection */
@@ -461,7 +464,8 @@ int main(int argc, char **argv)
             }
             if (input_fd == -1) {
                 perror("connect socket");
-                return 1;
+                ret = 1;
+                break;
             }
             if (data_loop(ctrl, input_fd, output_fd) != 0)
                 break;
@@ -474,14 +478,16 @@ int main(int argc, char **argv)
                 input_fd = output_fd = accept(socket_fd, NULL, NULL);
             if (input_fd == -1) {
                 perror("accept");
-                return 1;
+                ret = 1;
+                break;
             }
             set_nonblocking(input_fd, 1);
             set_nonblocking(output_fd, 1);
             ctrl = connect_vchan(domid, vchan_path);
             if (!ctrl) {
                 perror("vchan client init");
-                return 1;
+                ret = 1;
+                break;
             }
             if (data_loop(ctrl, input_fd, output_fd) != 0)
                 break;
@@ -493,5 +499,6 @@ int main(int argc, char **argv)
             ctrl = NULL;
         }
     }
-    return 0;
+
+    return ret;
 }
-- 
2.25.1



  parent reply	other threads:[~2020-05-25  2:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  2:49 [PATCH 0/8] Coverity fixes for vchan-socket-proxy Jason Andryuk
2020-05-25  2:49 ` [PATCH 1/8] vchan-socket-proxy: Ensure UNIX path NUL terminated Jason Andryuk
2020-06-13 12:40   ` Marek Marczykowski-Górecki
2020-05-25  2:49 ` [PATCH 2/8] vchan-socket-proxy: Check xs_watch return value Jason Andryuk
2020-05-25  2:49 ` Jason Andryuk [this message]
2020-05-25  2:49 ` [PATCH 4/8] vchan-socket-proxy: Use a struct to store state Jason Andryuk
2020-05-25  2:49 ` [PATCH 5/8] vchan-socket-proxy: Switch data_loop() to take state Jason Andryuk
2020-05-25  2:49 ` [PATCH 6/8] vchan-socket-proxy: Set closed FDs to -1 Jason Andryuk
2020-05-25  2:49 ` [PATCH 7/8] vchan-socket-proxy: Cleanup resources on exit Jason Andryuk
2020-05-25  2:49 ` [PATCH 8/8] vchan-socket-proxy: Handle closing shared input/output_fd Jason Andryuk
2020-05-25 22:36 ` [PATCH 0/8] Coverity fixes for vchan-socket-proxy Jason Andryuk
2020-05-28  2:59   ` Jason Andryuk
2020-06-13 12:40     ` Marek Marczykowski-Górecki
2020-06-14 14:05       ` Jason Andryuk

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=20200525024955.225415-4-jandryuk@gmail.com \
    --to=jandryuk@gmail.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=marmarek@invisiblethingslab.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.