Fix: src.text.dmesg: add missing assignment of `status` on error path
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 9 Apr 2020 18:27:39 +0000 (14:27 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 10 Apr 2020 19:18:19 +0000 (15:18 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3384
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/text/dmesg/dmesg.c

index 188cff895b23cc104c1e0cc2b43a56adbb239a0c..88acb52b7294503a44eadaa3fe0749cdc046d83f 100644 (file)
@@ -709,8 +709,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;
@@ -735,8 +734,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 */
@@ -749,8 +750,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);
@@ -774,6 +773,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;
        }
 
@@ -805,8 +805,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;
 }
This page took 0.025437 seconds and 4 git commands to generate.