From: Simon Marchi Date: Mon, 31 Jan 2022 15:38:11 +0000 (-0500) Subject: Fix: src.ctf.lttng-live: return correct error status in lttng_live_msg_iter_init X-Git-Url: https://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=10265ebe457aa6633556c604e27e865e66d14f0b;hp=aac10c5d685a31ceeec5600a0f39b7f4a415ab18 Fix: src.ctf.lttng-live: return correct error status in lttng_live_msg_iter_init Fix this clang-tidy warning: /home/simark/src/babeltrace/src/plugins/ctf/lttng-live/lttng-live.cpp:1802:9: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores] status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Indeed, we set status to MEMORY_ERROR here, but overwrite it to ERROR at the error label. Remove the assignment at the error label, add assignments to all points where we go to the error label. Change-Id: I5a81210609d913854f7b7d1b1be5bd54fffa02b2 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/7195 Reviewed-by: Philippe Proulx --- diff --git a/src/plugins/ctf/lttng-live/lttng-live.cpp b/src/plugins/ctf/lttng-live/lttng-live.cpp index 67ea8297..63fc173f 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.cpp +++ b/src/plugins/ctf/lttng-live/lttng-live.cpp @@ -1797,8 +1797,8 @@ lttng_live_msg_iter_init(bt_self_message_iterator *self_msg_it, lttng_live_msg_iter = lttng_live_msg_iter_create(lttng_live, self_msg_it); if (!lttng_live_msg_iter) { - status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to create lttng_live_msg_iter"); + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -1815,6 +1815,8 @@ lttng_live_msg_iter_init(bt_self_message_iterator *self_msg_it, */ BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Interrupted while creating viewer connection"); } + + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; goto error; } @@ -1829,6 +1831,8 @@ lttng_live_msg_iter_init(bt_self_message_iterator *self_msg_it, */ BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Interrupted when creating viewer session"); } + + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; goto error; } @@ -1848,6 +1852,7 @@ lttng_live_msg_iter_init(bt_self_message_iterator *self_msg_it, "component parameter: url =\"%s\"", SESS_NOT_FOUND_ACTION_PARAM, SESS_NOT_FOUND_ACTION_FAIL_STR, lttng_live->params.url->str); + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; goto error; case SESSION_NOT_FOUND_ACTION_END: BT_COMP_LOGI( @@ -1867,7 +1872,6 @@ lttng_live_msg_iter_init(bt_self_message_iterator *self_msg_it, goto end; error: - status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; lttng_live_msg_iter_destroy(lttng_live_msg_iter); end: return status;