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>
Sat, 11 Apr 2020 14:04:09 +0000 (10:04 -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>
(cherry picked from commit c16fb81a23dcfa6ab8331efe1c98a86e4444040d)
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3361
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/text/dmesg/dmesg.c

index 199dbf925db862fac3288dcc4e10cb0e8905ce8f..1d31c3db599ea307a5dd2a577b97fabf90a7abc8 100644 (file)
@@ -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;
 }
This page took 0.025493 seconds and 4 git commands to generate.