]> git.puffer.fish Git - mirror/frr.git/commitdiff
ldpd: redundant condition (cppcheck) 2485/head
authorpaco <paco@voltanet.io>
Mon, 18 Jun 2018 15:25:20 +0000 (17:25 +0200)
committerpaco <paco@voltanet.io>
Mon, 18 Jun 2018 17:40:39 +0000 (19:40 +0200)
Signed-off-by: F. Aragon <paco@voltanet.io>
ldpd/ldpd.c

index 255febeb60344b676093a3eb6ad561e665940456..b265c98dae3d43d990d246807035a576f8016d03 100644 (file)
@@ -406,16 +406,32 @@ ldpd_shutdown(void)
        free(vty_conf);
 
        log_debug("waiting for children to terminate");
-       do {
+
+       while (true) {
+               /* Wait for child process. */
                pid = wait(&status);
                if (pid == -1) {
-                       if (errno != EINTR && errno != ECHILD)
-                               fatal("wait");
-               } else if (WIFSIGNALED(status))
+                       /* We got interrupted, try again. */
+                       if (errno == EINTR)
+                               continue;
+                       /* No more processes were found. */
+                       if (errno != ECHILD)
+                               break;
+
+                       /* Unhandled errno condition. */
+                       fatal("wait");
+                       /* UNREACHABLE */
+               }
+
+               /* We found something, lets announce it. */
+               if (WIFSIGNALED(status))
                        log_warnx("%s terminated; signal %d",
-                           (pid == lde_pid) ? "label decision engine" :
-                           "ldp engine", WTERMSIG(status));
-       } while (pid != -1 || (pid == -1 && errno == EINTR));
+                                 (pid == lde_pid ? "label decision engine"
+                                                 : "ldp engine"),
+                                 WTERMSIG(status));
+
+               /* Repeat until there are no more child processes. */
+       }
 
        free(iev_ldpe);
        free(iev_lde);