From: Simon Marchi Date: Thu, 9 Apr 2020 18:27:39 +0000 (-0400) Subject: Fix: src.text.dmesg: add missing assignment of `status` on error path X-Git-Tag: v2.0.3~9 X-Git-Url: https://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=33f24144e8e35a09395866c2f02dc085d125f355 Fix: src.text.dmesg: add missing assignment of `status` on error path The error path under `if (!*msg)`, originally at line 789, is missing assigning an error status to the `status` variable, fix it. Change-Id: I2b47c6ce7c6099a6db68c4da108d7c0886c7177e Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/3384 Reviewed-by: Philippe Proulx (cherry picked from commit c16fb81a23dcfa6ab8331efe1c98a86e4444040d) Reviewed-on: https://review.lttng.org/c/babeltrace/+/3361 CI-Build: Philippe Proulx Tested-by: jenkins --- diff --git a/src/plugins/text/dmesg/dmesg.c b/src/plugins/text/dmesg/dmesg.c index 199dbf92..1d31c3db 100644 --- a/src/plugins/text/dmesg/dmesg.c +++ b/src/plugins/text/dmesg/dmesg.c @@ -725,8 +725,7 @@ bt_message_iterator_class_next_method_status dmesg_msg_iter_next_one( { ssize_t len; struct dmesg_component *dmesg_comp; - bt_message_iterator_class_next_method_status status = - BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status; BT_ASSERT_DBG(dmesg_msg_iter); dmesg_comp = dmesg_msg_iter->dmesg_comp; @@ -751,8 +750,10 @@ bt_message_iterator_class_next_method_status dmesg_msg_iter_next_one( if (len < 0) { if (errno == EINVAL) { status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; + goto end; } else if (errno == ENOMEM) { status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; + goto end; } else { if (dmesg_msg_iter->state == STATE_EMIT_STREAM_BEGINNING) { /* Stream did not even begin */ @@ -765,8 +766,6 @@ bt_message_iterator_class_next_method_status dmesg_msg_iter_next_one( goto handle_state; } } - - goto end; } BT_ASSERT_DBG(dmesg_msg_iter->linebuf); @@ -790,6 +789,7 @@ bt_message_iterator_class_next_method_status dmesg_msg_iter_next_one( BT_COMP_LOGE("Cannot create event message from line: " "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp, dmesg_msg_iter->linebuf); + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -821,8 +821,10 @@ handle_state: BT_COMP_LOGE("Cannot create message: dmesg-comp-addr=%p", dmesg_comp); status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; + goto end; } + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; end: return status; }