]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: reformat the flow to make a bit more sense
authorMartin Kletzander <mkletzan@redhat.com>
Sun, 7 Sep 2014 15:08:57 +0000 (17:08 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 15 Sep 2014 07:49:33 +0000 (09:49 +0200)
Just remove useless "else".  Best viewed with '-w'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/rpc/virnetsocket.c

index 2192dc8d1c72fe2bb5e1904dc12ba2b86ee0ba8e..80aeddff037a42fda0fb2308b9603e5d03bad7b5 100644 (file)
@@ -571,66 +571,66 @@ int virNetSocketNewConnectUNIX(const char *path,
 
  retry:
     if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
+        int status = 0;
+        pid_t pid = 0;
+
         if (!spawnDaemon) {
             virReportSystemError(errno, _("Failed to connect socket to '%s'"),
                                  path);
             goto error;
-        } else {
-            int status = 0;
-            pid_t pid = 0;
-
-            if ((passfd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
-                virReportSystemError(errno, "%s", _("Failed to create socket"));
-                goto error;
-            }
+        }
 
-            /*
-             * We have to fork() here, because umask() is set
-             * per-process, chmod() is racy and fchmod() has undefined
-             * behaviour on sockets according to POSIX, so it doesn't
-             * work outside Linux.
-             */
-            if ((pid = virFork()) < 0)
-                goto error;
+        if ((passfd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
+            virReportSystemError(errno, "%s", _("Failed to create socket"));
+            goto error;
+        }
 
-            if (pid == 0) {
-                umask(0077);
-                if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0)
-                    _exit(EXIT_FAILURE);
+        /*
+         * We have to fork() here, because umask() is set
+         * per-process, chmod() is racy and fchmod() has undefined
+         * behaviour on sockets according to POSIX, so it doesn't
+         * work outside Linux.
+         */
+        if ((pid = virFork()) < 0)
+            goto error;
 
-                _exit(EXIT_SUCCESS);
-            }
+        if (pid == 0) {
+            umask(0077);
+            if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0)
+                _exit(EXIT_FAILURE);
 
-            if (virProcessWait(pid, &status, false) < 0)
-                goto error;
+            _exit(EXIT_SUCCESS);
+        }
 
-            if (status != EXIT_SUCCESS) {
-                /*
-                 * OK, so the subprocces failed to bind() the socket.  This may mean
-                 * that another daemon was starting at the same time and succeeded
-                 * with its bind().  So we'll try connecting again, but this time
-                 * without spawning the daemon.
-                 */
-                spawnDaemon = false;
-                goto retry;
-            }
+        if (virProcessWait(pid, &status, false) < 0)
+            goto error;
 
-            if (listen(passfd, 0) < 0) {
-                virReportSystemError(errno, "%s",
-                                     _("Failed to listen on socket that's about "
-                                       "to be passed to the daemon"));
-                goto error;
-            }
+        if (status != EXIT_SUCCESS) {
+            /*
+             * OK, so the subprocces failed to bind() the socket.  This may mean
+             * that another daemon was starting at the same time and succeeded
+             * with its bind().  So we'll try connecting again, but this time
+             * without spawning the daemon.
+             */
+            spawnDaemon = false;
+            goto retry;
+        }
 
-            if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
-                virReportSystemError(errno, _("Failed to connect socket to '%s'"),
-                                     path);
-                goto error;
-            }
+        if (listen(passfd, 0) < 0) {
+            virReportSystemError(errno, "%s",
+                                 _("Failed to listen on socket that's about "
+                                   "to be passed to the daemon"));
+            goto error;
+        }
 
-            if (virNetSocketForkDaemon(binary, passfd) < 0)
-                goto error;
+        if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
+            virReportSystemError(errno, _("Failed to connect socket to '%s'"),
+                                 path);
+            goto error;
         }
+
+        if (virNetSocketForkDaemon(binary, passfd) < 0)
+            goto error;
     }
 
     localAddr.len = sizeof(localAddr.data);