summaryrefslogtreecommitdiffstats
path: root/ldpd
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2018-06-20 13:52:37 +0200
committerGitHub <noreply@github.com>2018-06-20 13:52:37 +0200
commitcb7b0cbbf8fd41b57e0a52c2c9a2a62ecc5bead7 (patch)
tree76a059d97676e952f43ac5fce72320bd1b43595d /ldpd
parentMerge pull request #2461 from pacovn/Coverity_1399380_Untrusted_value_as_argu... (diff)
parentldpd: redundant condition (cppcheck) (diff)
downloadfrr-cb7b0cbbf8fd41b57e0a52c2c9a2a62ecc5bead7.tar.xz
frr-cb7b0cbbf8fd41b57e0a52c2c9a2a62ecc5bead7.zip
Merge pull request #2485 from pacovn/cppcheck_ldpd_redundant_condition
ldpd: redundant condition (cppcheck)
Diffstat (limited to 'ldpd')
-rw-r--r--ldpd/ldpd.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 255febeb6..b265c98da 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -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);