src.ctf.lttng-live: viewer-connection.cpp: remove goto error-handling
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Mar 2024 19:47:31 +0000 (15:47 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I87b05835a268fef92f906c16bb35a84c1df0a27f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8485
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12395
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/lttng-live/viewer-connection.cpp

index f829d07dcc65b5496aa1a4780f31fdd260cfc2a5..46cfd2c4378a21298f697e1eb695d1d93b5a1de7 100644 (file)
@@ -104,7 +104,6 @@ lttng_live_recv(struct live_viewer_connection *viewer_connection, void *buf, siz
     ssize_t received;
     size_t total_received = 0, to_receive = len;
     struct lttng_live_msg_iter *lttng_live_msg_iter = viewer_connection->lttng_live_msg_iter;
     ssize_t received;
     size_t total_received = 0, to_receive = len;
     struct lttng_live_msg_iter *lttng_live_msg_iter = viewer_connection->lttng_live_msg_iter;
-    enum lttng_live_viewer_status status;
     BT_SOCKET sock = viewer_connection->control_sock;
 
     /*
     BT_SOCKET sock = viewer_connection->control_sock;
 
     /*
@@ -120,9 +119,8 @@ lttng_live_recv(struct live_viewer_connection *viewer_connection, void *buf, siz
                      * SIGINT and the graph is being torn
                      * down.
                      */
                      * SIGINT and the graph is being torn
                      * down.
                      */
-                    status = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED;
                     lttng_live_msg_iter->was_interrupted = true;
                     lttng_live_msg_iter->was_interrupted = true;
-                    goto end;
+                    return LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED;
                 } else {
                     /*
                      * A signal was received, but the graph
                 } else {
                     /*
                      * A signal was received, but the graph
@@ -138,8 +136,7 @@ lttng_live_recv(struct live_viewer_connection *viewer_connection, void *buf, siz
                 LTTNG_LIVE_CPPLOGE_APPEND_CAUSE_ERRNO("Error receiving from Relay", ".");
 
                 viewer_connection_close_socket(viewer_connection);
                 LTTNG_LIVE_CPPLOGE_APPEND_CAUSE_ERRNO("Error receiving from Relay", ".");
 
                 viewer_connection_close_socket(viewer_connection);
-                status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-                goto end;
+                return LTTNG_LIVE_VIEWER_STATUS_ERROR;
             }
         } else if (received == 0) {
             /*
             }
         } else if (received == 0) {
             /*
@@ -152,8 +149,7 @@ lttng_live_recv(struct live_viewer_connection *viewer_connection, void *buf, siz
             BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                          "Remote side has closed connection");
             viewer_connection_close_socket(viewer_connection);
             BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                          "Remote side has closed connection");
             viewer_connection_close_socket(viewer_connection);
-            status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-            goto end;
+            return LTTNG_LIVE_VIEWER_STATUS_ERROR;
         }
 
         BT_ASSERT(received <= to_receive);
         }
 
         BT_ASSERT(received <= to_receive);
@@ -163,10 +159,7 @@ lttng_live_recv(struct live_viewer_connection *viewer_connection, void *buf, siz
     } while (to_receive > 0);
 
     BT_ASSERT(total_received == len);
     } while (to_receive > 0);
 
     BT_ASSERT(total_received == len);
-    status = LTTNG_LIVE_VIEWER_STATUS_OK;
-
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 /*
 }
 
 /*
@@ -178,7 +171,6 @@ end:
 static enum lttng_live_viewer_status
 lttng_live_send(struct live_viewer_connection *viewer_connection, const void *buf, size_t len)
 {
 static enum lttng_live_viewer_status
 lttng_live_send(struct live_viewer_connection *viewer_connection, const void *buf, size_t len)
 {
-    enum lttng_live_viewer_status status;
     struct lttng_live_msg_iter *lttng_live_msg_iter = viewer_connection->lttng_live_msg_iter;
     BT_SOCKET sock = viewer_connection->control_sock;
     size_t to_send = len;
     struct lttng_live_msg_iter *lttng_live_msg_iter = viewer_connection->lttng_live_msg_iter;
     BT_SOCKET sock = viewer_connection->control_sock;
     size_t to_send = len;
@@ -193,9 +185,8 @@ lttng_live_send(struct live_viewer_connection *viewer_connection, const void *bu
                      * This interruption was a SIGINT and
                      * the graph is being teared down.
                      */
                      * This interruption was a SIGINT and
                      * the graph is being teared down.
                      */
-                    status = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED;
                     lttng_live_msg_iter->was_interrupted = true;
                     lttng_live_msg_iter->was_interrupted = true;
-                    goto end;
+                    return LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED;
                 } else {
                     /*
                      * A signal was received, but the graph
                 } else {
                     /*
                      * A signal was received, but the graph
@@ -211,8 +202,7 @@ lttng_live_send(struct live_viewer_connection *viewer_connection, const void *bu
                 LTTNG_LIVE_CPPLOGE_APPEND_CAUSE_ERRNO("Error sending to Relay", ".");
 
                 viewer_connection_close_socket(viewer_connection);
                 LTTNG_LIVE_CPPLOGE_APPEND_CAUSE_ERRNO("Error sending to Relay", ".");
 
                 viewer_connection_close_socket(viewer_connection);
-                status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-                goto end;
+                return LTTNG_LIVE_VIEWER_STATUS_ERROR;
             }
         }
 
             }
         }
 
@@ -223,10 +213,7 @@ lttng_live_send(struct live_viewer_connection *viewer_connection, const void *bu
     } while (to_send > 0);
 
     BT_ASSERT(total_sent == len);
     } while (to_send > 0);
 
     BT_ASSERT(total_sent == len);
-    status = LTTNG_LIVE_VIEWER_STATUS_OK;
-
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 static int parse_url(struct live_viewer_connection *viewer_connection)
 }
 
 static int parse_url(struct live_viewer_connection *viewer_connection)
@@ -234,10 +221,9 @@ static int parse_url(struct live_viewer_connection *viewer_connection)
     char error_buf[256] = {0};
     struct bt_common_lttng_live_url_parts lttng_live_url_parts = {};
     bt_common_lttng_live_url_parts_deleter partsDeleter {lttng_live_url_parts};
     char error_buf[256] = {0};
     struct bt_common_lttng_live_url_parts lttng_live_url_parts = {};
     bt_common_lttng_live_url_parts_deleter partsDeleter {lttng_live_url_parts};
-    int ret = -1;
 
     if (viewer_connection->url.empty()) {
 
     if (viewer_connection->url.empty()) {
-        goto end;
+        return -1;
     }
 
     lttng_live_url_parts = bt_common_parse_lttng_live_url(viewer_connection->url.c_str(), error_buf,
     }
 
     lttng_live_url_parts = bt_common_parse_lttng_live_url(viewer_connection->url.c_str(), error_buf,
@@ -245,7 +231,7 @@ static int parse_url(struct live_viewer_connection *viewer_connection)
     if (!lttng_live_url_parts.proto) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Invalid LTTng live URL format: {}",
                                      error_buf);
     if (!lttng_live_url_parts.proto) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Invalid LTTng live URL format: {}",
                                      error_buf);
-        goto end;
+        return -1;
     }
     viewer_connection->proto.reset(lttng_live_url_parts.proto);
     lttng_live_url_parts.proto = NULL;
     }
     viewer_connection->proto.reset(lttng_live_url_parts.proto);
     lttng_live_url_parts.proto = NULL;
@@ -267,10 +253,7 @@ static int parse_url(struct live_viewer_connection *viewer_connection)
         lttng_live_url_parts.session_name = NULL;
     }
 
         lttng_live_url_parts.session_name = NULL;
     }
 
-    ret = 0;
-
-end:
-    return ret;
+    return 0;
 }
 
 static enum lttng_live_viewer_status
 }
 
 static enum lttng_live_viewer_status
@@ -306,13 +289,13 @@ lttng_live_handshake(struct live_viewer_connection *viewer_connection)
     status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "viewer connect command");
     status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "viewer connect command");
-        goto end;
+        return status;
     }
 
     status = lttng_live_recv(viewer_connection, &connect, sizeof(connect));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "viewer connect reply");
     }
 
     status = lttng_live_recv(viewer_connection, &connect, sizeof(connect));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "viewer connect reply");
-        goto end;
+        return status;
     }
 
     BT_CPPLOGI_SPEC(viewer_connection->logger, "Received viewer session ID : {}",
     }
 
     BT_CPPLOGI_SPEC(viewer_connection->logger, "Received viewer session ID : {}",
@@ -323,8 +306,7 @@ lttng_live_handshake(struct live_viewer_connection *viewer_connection)
     if (LTTNG_LIVE_MAJOR != be32toh(connect.major)) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Incompatible lttng-relayd protocol");
     if (LTTNG_LIVE_MAJOR != be32toh(connect.major)) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Incompatible lttng-relayd protocol");
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
     /* Use the smallest protocol version implemented. */
     if (LTTNG_LIVE_MINOR > be32toh(connect.minor)) {
     }
     /* Use the smallest protocol version implemented. */
     if (LTTNG_LIVE_MINOR > be32toh(connect.minor)) {
@@ -334,12 +316,7 @@ lttng_live_handshake(struct live_viewer_connection *viewer_connection)
     }
     viewer_connection->major = LTTNG_LIVE_MAJOR;
 
     }
     viewer_connection->major = LTTNG_LIVE_MAJOR;
 
-    status = LTTNG_LIVE_VIEWER_STATUS_OK;
-
-    goto end;
-
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 static enum lttng_live_viewer_status
 }
 
 static enum lttng_live_viewer_status
@@ -351,8 +328,7 @@ lttng_live_connect_viewer(struct live_viewer_connection *viewer_connection)
 
     if (parse_url(viewer_connection)) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Failed to parse URL");
 
     if (parse_url(viewer_connection)) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Failed to parse URL");
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto error;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
 
     BT_CPPLOGD_SPEC(
     }
 
     BT_CPPLOGD_SPEC(
@@ -368,15 +344,13 @@ lttng_live_connect_viewer(struct live_viewer_connection *viewer_connection)
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Cannot lookup hostname: hostname=\"{}\"",
                                      viewer_connection->relay_hostname->str);
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Cannot lookup hostname: hostname=\"{}\"",
                                      viewer_connection->relay_hostname->str);
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto error;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
 
     if ((viewer_connection->control_sock = socket(AF_INET, SOCK_STREAM, 0)) == BT_INVALID_SOCKET) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Socket creation failed: {}",
                                      bt_socket_errormsg());
     }
 
     if ((viewer_connection->control_sock = socket(AF_INET, SOCK_STREAM, 0)) == BT_INVALID_SOCKET) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Socket creation failed: {}",
                                      bt_socket_errormsg());
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto error;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
 
     server_addr.sin_family = AF_INET;
     }
 
     server_addr.sin_family = AF_INET;
@@ -388,8 +362,8 @@ lttng_live_connect_viewer(struct live_viewer_connection *viewer_connection)
                 sizeof(struct sockaddr)) == BT_SOCKET_ERROR) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Connection failed: {}",
                                      bt_socket_errormsg());
                 sizeof(struct sockaddr)) == BT_SOCKET_ERROR) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Connection failed: {}",
                                      bt_socket_errormsg());
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto error;
+        viewer_connection_close_socket(viewer_connection);
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
 
     status = lttng_live_handshake(viewer_connection);
     }
 
     status = lttng_live_handshake(viewer_connection);
@@ -400,18 +374,13 @@ lttng_live_connect_viewer(struct live_viewer_connection *viewer_connection)
      */
     if (status == LTTNG_LIVE_VIEWER_STATUS_ERROR) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Viewer handshake failed");
      */
     if (status == LTTNG_LIVE_VIEWER_STATUS_ERROR) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Viewer handshake failed");
-        goto error;
+        viewer_connection_close_socket(viewer_connection);
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     } else if (status == LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED) {
     } else if (status == LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED) {
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED;
     }
 
     }
 
-    goto end;
-
-error:
-    viewer_connection_close_socket(viewer_connection);
-
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 static int list_update_session(const bt2::ArrayValue results,
 }
 
 static int list_update_session(const bt2::ArrayValue results,
@@ -675,13 +644,13 @@ lttng_live_query_session_ids(struct lttng_live_msg_iter *lttng_live_msg_iter)
     status = lttng_live_send(viewer_connection, &cmd, sizeof(cmd));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "list sessions command");
     status = lttng_live_send(viewer_connection, &cmd, sizeof(cmd));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "list sessions command");
-        goto end;
+        return status;
     }
 
     status = lttng_live_recv(viewer_connection, &list, sizeof(list));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "session list reply");
     }
 
     status = lttng_live_recv(viewer_connection, &list, sizeof(list));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "session list reply");
-        goto end;
+        return status;
     }
 
     sessions_count = be32toh(list.sessions_count);
     }
 
     sessions_count = be32toh(list.sessions_count);
@@ -689,7 +658,7 @@ lttng_live_query_session_ids(struct lttng_live_msg_iter *lttng_live_msg_iter)
         status = lttng_live_recv(viewer_connection, &lsession, sizeof(lsession));
         if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
             viewer_handle_recv_status(status, "session reply");
         status = lttng_live_recv(viewer_connection, &lsession, sizeof(lsession));
         if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
             viewer_handle_recv_status(status, "session reply");
-            goto end;
+            return status;
         }
         lsession.hostname[LTTNG_VIEWER_HOST_NAME_MAX - 1] = '\0';
         lsession.session_name[LTTNG_VIEWER_NAME_MAX - 1] = '\0';
         }
         lsession.hostname[LTTNG_VIEWER_HOST_NAME_MAX - 1] = '\0';
         lsession.session_name[LTTNG_VIEWER_NAME_MAX - 1] = '\0';
@@ -708,16 +677,12 @@ lttng_live_query_session_ids(struct lttng_live_msg_iter *lttng_live_msg_iter)
                                        lsession.session_name)) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                              "Failed to add live session");
                                        lsession.session_name)) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                              "Failed to add live session");
-                status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-                goto end;
+                return LTTNG_LIVE_VIEWER_STATUS_ERROR;
             }
         }
     }
 
             }
         }
     }
 
-    status = LTTNG_LIVE_VIEWER_STATUS_OK;
-
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 enum lttng_live_viewer_status
 }
 
 enum lttng_live_viewer_status
@@ -738,32 +703,30 @@ lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter
     status = lttng_live_send(viewer_connection, &cmd, sizeof(cmd));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "create session command");
     status = lttng_live_send(viewer_connection, &cmd, sizeof(cmd));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "create session command");
-        goto end;
+        return status;
     }
 
     status = lttng_live_recv(viewer_connection, &resp, sizeof(resp));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "create session reply");
     }
 
     status = lttng_live_recv(viewer_connection, &resp, sizeof(resp));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "create session reply");
-        goto end;
+        return status;
     }
 
     if (be32toh(resp.status) != LTTNG_VIEWER_CREATE_SESSION_OK) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Error creating viewer session");
     }
 
     if (be32toh(resp.status) != LTTNG_VIEWER_CREATE_SESSION_OK) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Error creating viewer session");
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
 
     status = lttng_live_query_session_ids(lttng_live_msg_iter);
     if (status == LTTNG_LIVE_VIEWER_STATUS_ERROR) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Failed to query live viewer session ids");
     }
 
     status = lttng_live_query_session_ids(lttng_live_msg_iter);
     if (status == LTTNG_LIVE_VIEWER_STATUS_ERROR) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Failed to query live viewer session ids");
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     } else if (status == LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED) {
     } else if (status == LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED) {
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED;
     }
 
     }
 
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 static enum lttng_live_viewer_status receive_streams(struct lttng_live_session *session,
 }
 
 static enum lttng_live_viewer_status receive_streams(struct lttng_live_session *session,
@@ -785,7 +748,7 @@ static enum lttng_live_viewer_status receive_streams(struct lttng_live_session *
         status = lttng_live_recv(viewer_connection, &stream, sizeof(stream));
         if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
             viewer_handle_recv_status(status, "stream reply");
         status = lttng_live_recv(viewer_connection, &stream, sizeof(stream));
         if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
             viewer_handle_recv_status(status, "stream reply");
-            goto end;
+            return status;
         }
         stream.path_name[LTTNG_VIEWER_PATH_MAX - 1] = '\0';
         stream.channel_name[LTTNG_VIEWER_NAME_MAX - 1] = '\0';
         }
         stream.path_name[LTTNG_VIEWER_PATH_MAX - 1] = '\0';
         stream.channel_name[LTTNG_VIEWER_NAME_MAX - 1] = '\0';
@@ -798,8 +761,7 @@ static enum lttng_live_viewer_status receive_streams(struct lttng_live_session *
             if (lttng_live_metadata_create_stream(session, ctf_trace_id, stream_id)) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                              "Error creating metadata stream");
             if (lttng_live_metadata_create_stream(session, ctf_trace_id, stream_id)) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                              "Error creating metadata stream");
-                status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-                goto end;
+                return LTTNG_LIVE_VIEWER_STATUS_ERROR;
             }
             session->lazy_stream_msg_init = true;
         } else {
             }
             session->lazy_stream_msg_init = true;
         } else {
@@ -809,15 +771,12 @@ static enum lttng_live_viewer_status receive_streams(struct lttng_live_session *
                 lttng_live_stream_iterator_create(session, ctf_trace_id, stream_id, self_msg_iter);
             if (!live_stream) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Error creating stream");
                 lttng_live_stream_iterator_create(session, ctf_trace_id, stream_id, self_msg_iter);
             if (!live_stream) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Error creating stream");
-                status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-                goto end;
+                return LTTNG_LIVE_VIEWER_STATUS_ERROR;
             }
         }
     }
             }
         }
     }
-    status = LTTNG_LIVE_VIEWER_STATUS_OK;
 
 
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 enum lttng_live_viewer_status lttng_live_session_attach(struct lttng_live_session *session,
 }
 
 enum lttng_live_viewer_status lttng_live_session_attach(struct lttng_live_session *session,
@@ -858,13 +817,13 @@ enum lttng_live_viewer_status lttng_live_session_attach(struct lttng_live_sessio
     status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "attach session command");
     status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "attach session command");
-        goto end;
+        return status;
     }
 
     status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "attach session reply");
     }
 
     status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "attach session reply");
-        goto end;
+        return status;
     }
 
     streams_count = be32toh(rp.streams_count);
     }
 
     streams_count = be32toh(rp.streams_count);
@@ -874,26 +833,21 @@ enum lttng_live_viewer_status lttng_live_session_attach(struct lttng_live_sessio
     case LTTNG_VIEWER_ATTACH_UNK:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Session id {} is unknown",
                                      session_id);
     case LTTNG_VIEWER_ATTACH_UNK:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Session id {} is unknown",
                                      session_id);
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     case LTTNG_VIEWER_ATTACH_ALREADY:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "There is already a viewer attached to this session");
     case LTTNG_VIEWER_ATTACH_ALREADY:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "There is already a viewer attached to this session");
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     case LTTNG_VIEWER_ATTACH_NOT_LIVE:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Not a live session");
     case LTTNG_VIEWER_ATTACH_NOT_LIVE:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Not a live session");
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     case LTTNG_VIEWER_ATTACH_SEEK_ERR:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Wrong seek parameter");
     case LTTNG_VIEWER_ATTACH_SEEK_ERR:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Wrong seek parameter");
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Unknown attach return code {}",
                                      be32toh(rp.status));
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Unknown attach return code {}",
                                      be32toh(rp.status));
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
 
     /* We receive the initial list of streams. */
     }
 
     /* We receive the initial list of streams. */
@@ -902,10 +856,10 @@ enum lttng_live_viewer_status lttng_live_session_attach(struct lttng_live_sessio
     case LTTNG_LIVE_VIEWER_STATUS_OK:
         break;
     case LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED:
     case LTTNG_LIVE_VIEWER_STATUS_OK:
         break;
     case LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED:
-        goto end;
+        return status;
     case LTTNG_LIVE_VIEWER_STATUS_ERROR:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Error receiving streams");
     case LTTNG_LIVE_VIEWER_STATUS_ERROR:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Error receiving streams");
-        goto end;
+        return status;
     default:
         bt_common_abort();
     }
     default:
         bt_common_abort();
     }
@@ -913,8 +867,7 @@ enum lttng_live_viewer_status lttng_live_session_attach(struct lttng_live_sessio
     session->attached = true;
     session->new_streams_needed = false;
 
     session->attached = true;
     session->new_streams_needed = false;
 
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 enum lttng_live_viewer_status lttng_live_session_detach(struct lttng_live_session *session)
 }
 
 enum lttng_live_viewer_status lttng_live_session_detach(struct lttng_live_session *session)
@@ -958,13 +911,13 @@ enum lttng_live_viewer_status lttng_live_session_detach(struct lttng_live_sessio
     status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "detach session command");
     status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(status, "detach session command");
-        goto end;
+        return status;
     }
 
     status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "detach session reply");
     }
 
     status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(status, "detach session reply");
-        goto end;
+        return status;
     }
 
     switch (be32toh(rp.status)) {
     }
 
     switch (be32toh(rp.status)) {
@@ -972,32 +925,25 @@ enum lttng_live_viewer_status lttng_live_session_detach(struct lttng_live_sessio
         break;
     case LTTNG_VIEWER_DETACH_SESSION_UNK:
         BT_CPPLOGW_SPEC(viewer_connection->logger, "Session id {} is unknown", session_id);
         break;
     case LTTNG_VIEWER_DETACH_SESSION_UNK:
         BT_CPPLOGW_SPEC(viewer_connection->logger, "Session id {} is unknown", session_id);
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     case LTTNG_VIEWER_DETACH_SESSION_ERR:
         BT_CPPLOGW_SPEC(viewer_connection->logger, "Error detaching session id {}", session_id);
     case LTTNG_VIEWER_DETACH_SESSION_ERR:
         BT_CPPLOGW_SPEC(viewer_connection->logger, "Error detaching session id {}", session_id);
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     default:
         BT_CPPLOGE_SPEC(viewer_connection->logger, "Unknown detach return code {}",
                         be32toh(rp.status));
     default:
         BT_CPPLOGE_SPEC(viewer_connection->logger, "Unknown detach return code {}",
                         be32toh(rp.status));
-        status = LTTNG_LIVE_VIEWER_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_VIEWER_STATUS_ERROR;
     }
 
     session->attached = false;
 
     }
 
     session->attached = false;
 
-    status = LTTNG_LIVE_VIEWER_STATUS_OK;
-
-end:
-    return status;
+    return LTTNG_LIVE_VIEWER_STATUS_OK;
 }
 
 enum lttng_live_get_one_metadata_status
 lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<char>& buf)
 {
     uint64_t len = 0;
 }
 
 enum lttng_live_get_one_metadata_status
 lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<char>& buf)
 {
     uint64_t len = 0;
-    enum lttng_live_get_one_metadata_status status;
     enum lttng_live_viewer_status viewer_status;
     struct lttng_viewer_cmd cmd;
     struct lttng_viewer_get_metadata rq;
     enum lttng_live_viewer_status viewer_status;
     struct lttng_viewer_cmd cmd;
     struct lttng_viewer_get_metadata rq;
@@ -1030,15 +976,13 @@ lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<c
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get metadata command");
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get metadata command");
-        status = (enum lttng_live_get_one_metadata_status) viewer_status;
-        goto end;
+        return (lttng_live_get_one_metadata_status) viewer_status;
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get metadata reply");
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get metadata reply");
-        status = (enum lttng_live_get_one_metadata_status) viewer_status;
-        goto end;
+        return (lttng_live_get_one_metadata_status) viewer_status;
     }
 
     switch (be32toh(rp.status)) {
     }
 
     switch (be32toh(rp.status)) {
@@ -1047,8 +991,7 @@ lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<c
         break;
     case LTTNG_VIEWER_NO_NEW_METADATA:
         BT_CPPLOGD_SPEC(viewer_connection->logger, "Received get_metadata response: no new");
         break;
     case LTTNG_VIEWER_NO_NEW_METADATA:
         BT_CPPLOGD_SPEC(viewer_connection->logger, "Received get_metadata response: no new");
-        status = LTTNG_LIVE_GET_ONE_METADATA_STATUS_END;
-        goto end;
+        return LTTNG_LIVE_GET_ONE_METADATA_STATUS_END;
     case LTTNG_VIEWER_METADATA_ERR:
         /*
              * The Relayd cannot find this stream id. Maybe its
     case LTTNG_VIEWER_METADATA_ERR:
         /*
              * The Relayd cannot find this stream id. Maybe its
@@ -1056,13 +999,11 @@ lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<c
              * in a per-pid session.
              */
         BT_CPPLOGD_SPEC(viewer_connection->logger, "Received get_metadata response: error");
              * in a per-pid session.
              */
         BT_CPPLOGD_SPEC(viewer_connection->logger, "Received get_metadata response: error");
-        status = LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED;
-        goto end;
+        return LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED;
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Received get_metadata response: unknown");
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Received get_metadata response: unknown");
-        status = LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR;
     }
 
     len = be64toh(rp.len);
     }
 
     len = be64toh(rp.len);
@@ -1075,14 +1016,13 @@ lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<c
         BT_CPPLOGD_SPEC(
             viewer_connection->logger,
             "Expecting a metadata packet of size 0. Retry to get a packet from the relay.");
         BT_CPPLOGD_SPEC(
             viewer_connection->logger,
             "Expecting a metadata packet of size 0. Retry to get a packet from the relay.");
-        goto empty_metadata_packet_retry;
+        return LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK;
     }
 
     BT_CPPLOGD_SPEC(viewer_connection->logger, "Writing {} bytes to metadata", len);
     if (len <= 0) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Erroneous response length");
     }
 
     BT_CPPLOGD_SPEC(viewer_connection->logger, "Writing {} bytes to metadata", len);
     if (len <= 0) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger, "Erroneous response length");
-        status = LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR;
     }
 
     data.resize(len);
     }
 
     data.resize(len);
@@ -1090,8 +1030,7 @@ lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<c
     viewer_status = lttng_live_recv(viewer_connection, data.data(), len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get metadata packet");
     viewer_status = lttng_live_recv(viewer_connection, data.data(), len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get metadata packet");
-        status = (enum lttng_live_get_one_metadata_status) viewer_status;
-        goto end;
+        return (lttng_live_get_one_metadata_status) viewer_status;
     }
 
     /*
     }
 
     /*
@@ -1099,11 +1038,7 @@ lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, std::vector<c
      */
     buf.insert(buf.end(), data.begin(), data.end());
 
      */
     buf.insert(buf.end(), data.begin(), data.end());
 
-empty_metadata_packet_retry:
-    status = LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK;
-
-end:
-    return status;
+    return LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK;
 }
 
 /*
 }
 
 /*
@@ -1142,7 +1077,6 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
     struct lttng_viewer_get_next_index rq;
     enum lttng_live_viewer_status viewer_status;
     struct lttng_viewer_index rp;
     struct lttng_viewer_get_next_index rq;
     enum lttng_live_viewer_status viewer_status;
     struct lttng_viewer_index rp;
-    enum lttng_live_iterator_status status;
     live_viewer_connection *viewer_connection = lttng_live_msg_iter->viewer_connection.get();
     struct lttng_live_trace *trace = stream->trace;
     const size_t cmd_buf_len = sizeof(cmd) + sizeof(rq);
     live_viewer_connection *viewer_connection = lttng_live_msg_iter->viewer_connection.get();
     struct lttng_live_trace *trace = stream->trace;
     const size_t cmd_buf_len = sizeof(cmd) + sizeof(rq);
@@ -1171,13 +1105,13 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get next index command");
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get next index command");
-        goto error;
+        return viewer_status_to_live_iterator_status(viewer_status);
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get next index reply");
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get next index reply");
-        goto error;
+        return viewer_status_to_live_iterator_status(viewer_status);
     }
 
     flags = be32toh(rp.flags);
     }
 
     flags = be32toh(rp.flags);
@@ -1211,8 +1145,7 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
             stream->ctf_stream_class_id.is_set = true;
         }
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_QUIESCENT);
             stream->ctf_stream_class_id.is_set = true;
         }
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_QUIESCENT);
-        status = LTTNG_LIVE_ITERATOR_STATUS_OK;
-        break;
+        return LTTNG_LIVE_ITERATOR_STATUS_OK;
     }
     case LTTNG_VIEWER_INDEX_OK:
     {
     }
     case LTTNG_VIEWER_INDEX_OK:
     {
@@ -1235,41 +1168,30 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
                             static_cast<lttng_viewer_next_index_return_code>(rp_status), trace->id);
             trace->metadata_stream_state = LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
         }
                             static_cast<lttng_viewer_next_index_return_code>(rp_status), trace->id);
             trace->metadata_stream_state = LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
         }
-        status = LTTNG_LIVE_ITERATOR_STATUS_OK;
+        return LTTNG_LIVE_ITERATOR_STATUS_OK;
         break;
     }
     case LTTNG_VIEWER_INDEX_RETRY:
         memset(index, 0, sizeof(struct packet_index));
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_NO_DATA);
         break;
     }
     case LTTNG_VIEWER_INDEX_RETRY:
         memset(index, 0, sizeof(struct packet_index));
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_NO_DATA);
-        status = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
     case LTTNG_VIEWER_INDEX_HUP:
         memset(index, 0, sizeof(struct packet_index));
         index->offset = EOF;
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_EOF);
         stream->has_stream_hung_up = true;
     case LTTNG_VIEWER_INDEX_HUP:
         memset(index, 0, sizeof(struct packet_index));
         index->offset = EOF;
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_EOF);
         stream->has_stream_hung_up = true;
-        status = LTTNG_LIVE_ITERATOR_STATUS_END;
-        break;
+        return LTTNG_LIVE_ITERATOR_STATUS_END;
     case LTTNG_VIEWER_INDEX_ERR:
         memset(index, 0, sizeof(struct packet_index));
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_NO_DATA);
     case LTTNG_VIEWER_INDEX_ERR:
         memset(index, 0, sizeof(struct packet_index));
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_NO_DATA);
-        status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_ERROR;
     default:
         BT_CPPLOGD_SPEC(viewer_connection->logger,
                         "Received get_next_index response: unknown value");
         memset(index, 0, sizeof(struct packet_index));
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_NO_DATA);
     default:
         BT_CPPLOGD_SPEC(viewer_connection->logger,
                         "Received get_next_index response: unknown value");
         memset(index, 0, sizeof(struct packet_index));
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_NO_DATA);
-        status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_ERROR;
     }
     }
-
-    goto end;
-
-error:
-    status = viewer_status_to_live_iterator_status(viewer_status);
-end:
-    return status;
 }
 
 enum ctf_msg_iter_medium_status
 }
 
 enum ctf_msg_iter_medium_status
@@ -1277,7 +1199,6 @@ lttng_live_get_stream_bytes(struct lttng_live_msg_iter *lttng_live_msg_iter,
                             struct lttng_live_stream_iterator *stream, uint8_t *buf,
                             uint64_t offset, uint64_t req_len, uint64_t *recv_len)
 {
                             struct lttng_live_stream_iterator *stream, uint8_t *buf,
                             uint64_t offset, uint64_t req_len, uint64_t *recv_len)
 {
-    enum ctf_msg_iter_medium_status status;
     enum lttng_live_viewer_status viewer_status;
     struct lttng_viewer_trace_packet rp;
     struct lttng_viewer_cmd cmd;
     enum lttng_live_viewer_status viewer_status;
     struct lttng_viewer_trace_packet rp;
     struct lttng_viewer_cmd cmd;
@@ -1313,13 +1234,13 @@ lttng_live_get_stream_bytes(struct lttng_live_msg_iter *lttng_live_msg_iter,
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get data packet command");
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get data packet command");
-        goto error_convert_status;
+        return viewer_status_to_ctf_msg_iter_medium_status(viewer_status);
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get data packet reply");
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get data packet reply");
-        goto error_convert_status;
+        return viewer_status_to_ctf_msg_iter_medium_status(viewer_status);
     }
 
     flags = be32toh(rp.flags);
     }
 
     flags = be32toh(rp.flags);
@@ -1337,8 +1258,7 @@ lttng_live_get_stream_bytes(struct lttng_live_msg_iter *lttng_live_msg_iter,
         break;
     case LTTNG_VIEWER_GET_PACKET_RETRY:
         /* Unimplemented by relay daemon */
         break;
     case LTTNG_VIEWER_GET_PACKET_RETRY:
         /* Unimplemented by relay daemon */
-        status = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
-        goto end;
+        return CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
     case LTTNG_VIEWER_GET_PACKET_ERR:
         if (flags & LTTNG_VIEWER_FLAG_NEW_METADATA) {
             BT_CPPLOGD_SPEC(viewer_connection->logger,
     case LTTNG_VIEWER_GET_PACKET_ERR:
         if (flags & LTTNG_VIEWER_FLAG_NEW_METADATA) {
             BT_CPPLOGD_SPEC(viewer_connection->logger,
@@ -1355,45 +1275,34 @@ lttng_live_get_stream_bytes(struct lttng_live_msg_iter *lttng_live_msg_iter,
             lttng_live_need_new_streams(lttng_live_msg_iter);
         }
         if (flags & (LTTNG_VIEWER_FLAG_NEW_METADATA | LTTNG_VIEWER_FLAG_NEW_STREAM)) {
             lttng_live_need_new_streams(lttng_live_msg_iter);
         }
         if (flags & (LTTNG_VIEWER_FLAG_NEW_METADATA | LTTNG_VIEWER_FLAG_NEW_STREAM)) {
-            status = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
             BT_CPPLOGD_SPEC(viewer_connection->logger,
                             "Reply with any one flags set means we should retry: response={}",
                             static_cast<lttng_viewer_get_packet_return_code>(rp_status));
             BT_CPPLOGD_SPEC(viewer_connection->logger,
                             "Reply with any one flags set means we should retry: response={}",
                             static_cast<lttng_viewer_get_packet_return_code>(rp_status));
-            goto end;
+            return CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
         }
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Received get_data_packet response: error");
         }
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Received get_data_packet response: error");
-        status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
-        goto end;
+        return CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
     case LTTNG_VIEWER_GET_PACKET_EOF:
     case LTTNG_VIEWER_GET_PACKET_EOF:
-        status = CTF_MSG_ITER_MEDIUM_STATUS_EOF;
-        goto end;
+        return CTF_MSG_ITER_MEDIUM_STATUS_EOF;
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Received get_data_packet response: unknown ({})", rp_status);
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
                                      "Received get_data_packet response: unknown ({})", rp_status);
-        status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
-        goto end;
+        return CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
     }
 
     if (req_len == 0) {
     }
 
     if (req_len == 0) {
-        status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
-        goto end;
+        return CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
     }
 
     viewer_status = lttng_live_recv(viewer_connection, buf, req_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get data packet");
     }
 
     viewer_status = lttng_live_recv(viewer_connection, buf, req_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get data packet");
-        goto error_convert_status;
+        return viewer_status_to_ctf_msg_iter_medium_status(viewer_status);
     }
     *recv_len = req_len;
 
     }
     *recv_len = req_len;
 
-    status = CTF_MSG_ITER_MEDIUM_STATUS_OK;
-    goto end;
-
-error_convert_status:
-    status = viewer_status_to_ctf_msg_iter_medium_status(viewer_status);
-end:
-    return status;
+    return CTF_MSG_ITER_MEDIUM_STATUS_OK;
 }
 
 /*
 }
 
 /*
@@ -1403,7 +1312,6 @@ enum lttng_live_iterator_status
 lttng_live_session_get_new_streams(struct lttng_live_session *session,
                                    bt_self_message_iterator *self_msg_iter)
 {
 lttng_live_session_get_new_streams(struct lttng_live_session *session,
                                    bt_self_message_iterator *self_msg_iter)
 {
-    enum lttng_live_iterator_status status = LTTNG_LIVE_ITERATOR_STATUS_OK;
     struct lttng_viewer_cmd cmd;
     struct lttng_viewer_new_streams_request rq;
     struct lttng_viewer_new_streams_response rp;
     struct lttng_viewer_cmd cmd;
     struct lttng_viewer_new_streams_request rq;
     struct lttng_viewer_new_streams_response rp;
@@ -1415,8 +1323,7 @@ lttng_live_session_get_new_streams(struct lttng_live_session *session,
     char cmd_buf[cmd_buf_len];
 
     if (!session->new_streams_needed) {
     char cmd_buf[cmd_buf_len];
 
     if (!session->new_streams_needed) {
-        status = LTTNG_LIVE_ITERATOR_STATUS_OK;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_OK;
     }
 
     BT_CPPLOGD_SPEC(viewer_connection->logger,
     }
 
     BT_CPPLOGD_SPEC(viewer_connection->logger,
@@ -1441,15 +1348,13 @@ lttng_live_session_get_new_streams(struct lttng_live_session *session,
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get new streams command");
     viewer_status = lttng_live_send(viewer_connection, &cmd_buf, cmd_buf_len);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_send_status(viewer_status, "get new streams command");
-        status = viewer_status_to_live_iterator_status(viewer_status);
-        goto end;
+        return viewer_status_to_live_iterator_status(viewer_status);
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get new streams reply");
     }
 
     viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp));
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "get new streams reply");
-        status = viewer_status_to_live_iterator_status(viewer_status);
-        goto end;
+        return viewer_status_to_live_iterator_status(viewer_status);
     }
 
     streams_count = be32toh(rp.streams_count);
     }
 
     streams_count = be32toh(rp.streams_count);
@@ -1460,35 +1365,28 @@ lttng_live_session_get_new_streams(struct lttng_live_session *session,
         break;
     case LTTNG_VIEWER_NEW_STREAMS_NO_NEW:
         session->new_streams_needed = false;
         break;
     case LTTNG_VIEWER_NEW_STREAMS_NO_NEW:
         session->new_streams_needed = false;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_OK;
     case LTTNG_VIEWER_NEW_STREAMS_HUP:
         session->new_streams_needed = false;
         session->closed = true;
     case LTTNG_VIEWER_NEW_STREAMS_HUP:
         session->new_streams_needed = false;
         session->closed = true;
-        status = LTTNG_LIVE_ITERATOR_STATUS_END;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_END;
     case LTTNG_VIEWER_NEW_STREAMS_ERR:
         BT_CPPLOGD_SPEC(viewer_connection->logger, "Received get_new_streams response: error");
     case LTTNG_VIEWER_NEW_STREAMS_ERR:
         BT_CPPLOGD_SPEC(viewer_connection->logger, "Received get_new_streams response: error");
-        status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_ERROR;
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
     default:
         BT_CPPLOGE_APPEND_CAUSE_SPEC(viewer_connection->logger,
-                                     "Received get_new_streams response: Unknown:"
-                                     "return code {}",
+                                     "Received get_new_streams response: Unknown return code {}",
                                      be32toh(rp.status));
                                      be32toh(rp.status));
-        status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
-        goto end;
+        return LTTNG_LIVE_ITERATOR_STATUS_ERROR;
     }
 
     viewer_status = receive_streams(session, streams_count, self_msg_iter);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "new streams");
     }
 
     viewer_status = receive_streams(session, streams_count, self_msg_iter);
     if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
         viewer_handle_recv_status(viewer_status, "new streams");
-        status = viewer_status_to_live_iterator_status(viewer_status);
-        goto end;
+        return viewer_status_to_live_iterator_status(viewer_status);
     }
 
     }
 
-    status = LTTNG_LIVE_ITERATOR_STATUS_OK;
-end:
-    return status;
+    return LTTNG_LIVE_ITERATOR_STATUS_OK;
 }
 
 enum lttng_live_viewer_status
 }
 
 enum lttng_live_viewer_status
This page took 0.037193 seconds and 4 git commands to generate.