Fix: variable declaration shadows previously declared variable
[babeltrace.git] / plugins / ctf / common / notif-iter / notif-iter.c
index 8bb79db8f3ba64980b5081fcd0066b9280dfa9f0..a5d9e5c8aeaf1235510ccf70ac9f238f4f53b64c 100644 (file)
@@ -489,6 +489,8 @@ enum bt_ctf_notif_iter_status request_medium_bytes(
                BT_LOGV_MEM(buffer_addr, buffer_sz, "Returned bytes at %p:",
                        buffer_addr);
        } else if (m_status == BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF) {
+               struct bt_ctf_field_type *ph_ft =
+                       bt_ctf_trace_get_packet_header_type(notit->meta.trace);
                struct bt_ctf_field_type *eh_ft = NULL;
                struct bt_ctf_field_type *sec_ft = NULL;
                struct bt_ctf_field_type *ec_ft = NULL;
@@ -507,6 +509,16 @@ enum bt_ctf_notif_iter_status request_medium_bytes(
                        goto bad_state;
                }
 
+               if (notit->state == STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN) {
+                       /*
+                        * Beginning of packet context context is only
+                        * valid if there's no packet header.
+                        */
+                       if (!ph_ft) {
+                               goto good_state;
+                       }
+               }
+
                eh_ft = bt_ctf_stream_class_get_event_header_type(
                        notit->meta.stream_class);
                sec_ft = bt_ctf_stream_class_get_event_context_type(
@@ -580,6 +592,7 @@ bad_state:
                m_status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_ERROR;
 
 good_state:
+               bt_put(ph_ft);
                bt_put(eh_ft);
                bt_put(sec_ft);
                bt_put(ec_ft);
@@ -1409,7 +1422,7 @@ end_v_field_type:
        if (id_field_type && event_id == -1ULL) {
                /* Check "id" field */
                struct bt_ctf_field *id_field = NULL;
-               int ret = 0;
+               int ret_get_value = 0;
 
                // TODO: optimalize!
                id_field = bt_ctf_field_structure_get_field(
@@ -1419,7 +1432,7 @@ end_v_field_type:
                }
 
                if (bt_ctf_field_is_integer(id_field)) {
-                       ret = bt_ctf_field_unsigned_integer_get_value(
+                       ret_get_value = bt_ctf_field_unsigned_integer_get_value(
                                id_field, &event_id);
                } else if (bt_ctf_field_is_enumeration(id_field)) {
                        struct bt_ctf_field *container;
@@ -1427,12 +1440,12 @@ end_v_field_type:
                        container = bt_ctf_field_enumeration_get_container(
                                id_field);
                        assert(container);
-                       ret = bt_ctf_field_unsigned_integer_get_value(
+                       ret_get_value = bt_ctf_field_unsigned_integer_get_value(
                                container, &event_id);
                        BT_PUT(container);
                }
 
-               assert(ret == 0);
+               assert(ret_get_value == 0);
                BT_PUT(id_field);
        }
 
This page took 0.023949 seconds and 4 git commands to generate.