From 9da0c6d62fc82875e7e487fd938789a4bac69634 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Thu, 17 May 2018 17:25:45 +0200 Subject: [PATCH] Problem: goto jumping backwards Solution: replace by for loop --- src/pipe.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/pipe.cpp b/src/pipe.cpp index a52ea1c4..664e1c48 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -181,20 +181,21 @@ bool zmq::pipe_t::read (msg_t *msg_) if (unlikely (state != active && state != waiting_for_delimiter)) return false; -read_message: - if (!inpipe->read (msg_)) { - in_active = false; - return false; - } + for (bool payload_read = false; !payload_read;) { + if (!inpipe->read (msg_)) { + in_active = false; + return false; + } - // If this is a credential, save a copy and receive next message. - if (unlikely (msg_->is_credential ())) { - const unsigned char *data = - static_cast (msg_->data ()); - credential.set (data, msg_->size ()); - const int rc = msg_->close (); - zmq_assert (rc == 0); - goto read_message; + // If this is a credential, save a copy and receive next message. + if (unlikely (msg_->is_credential ())) { + const unsigned char *data = + static_cast (msg_->data ()); + credential.set (data, msg_->size ()); + const int rc = msg_->close (); + zmq_assert (rc == 0); + } else + payload_read = true; } // If delimiter was read, start termination process of the pipe.