Do not create an event which consumed 0 bits of data stream: log an
error and return without creating it. We keep the buffer position at the
beginning of the last decoded event header, and we compare to the
current buffer position: if they are the same, then we consumed 0 bits
of data. It is possible, when we compare, that notit->buf.last_eh_at is
-1ULL (reset when requesting bytes from medium): in this case, we know
we requested bytes anyway, which means we consumed something to get to
this starvation point, thus the event is not empty.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
/* Current position from addr (bits) */
size_t at;
/* Current position from addr (bits) */
size_t at;
+
+ /* Position of the last event header from addr (bits) */
+ size_t last_eh_at;
} buf;
/* Binary type reader */
} buf;
/* Binary type reader */
/* Restart at the beginning of the new medium buffer */
notit->buf.at = 0;
/* Restart at the beginning of the new medium buffer */
notit->buf.at = 0;
+ notit->buf.last_eh_at = -1ULL;
/* New medium buffer size */
notit->buf.sz = buffer_sz;
/* New medium buffer size */
notit->buf.sz = buffer_sz;
enum bt_ctf_notif_iter_status status = BT_CTF_NOTIF_ITER_STATUS_OK;
struct bt_ctf_field_type *event_header_type = NULL;
enum bt_ctf_notif_iter_status status = BT_CTF_NOTIF_ITER_STATUS_OK;
struct bt_ctf_field_type *event_header_type = NULL;
+ /* Reset the position of the last event header */
+ notit->buf.last_eh_at = notit->buf.at;
+
/* Check if we have some content left */
if (notit->cur_content_size >= 0) {
if (packet_at(notit) == notit->cur_content_size) {
/* Check if we have some content left */
if (notit->cur_content_size >= 0) {
if (packet_at(notit) == notit->cur_content_size) {
notit->buf.addr = NULL;
notit->buf.sz = 0;
notit->buf.at = 0;
notit->buf.addr = NULL;
notit->buf.sz = 0;
notit->buf.at = 0;
+ notit->buf.last_eh_at = -1ULL;
notit->buf.packet_offset = 0;
notit->state = STATE_INIT;
notit->cur_content_size = -1;
notit->buf.packet_offset = 0;
notit->state = STATE_INIT;
notit->cur_content_size = -1;
struct bt_clock_class_priority_map *cc_prio_map,
struct bt_notification **notification)
{
struct bt_clock_class_priority_map *cc_prio_map,
struct bt_notification **notification)
{
- struct bt_ctf_event *event;
+ struct bt_ctf_event *event = NULL;
struct bt_notification *ret = NULL;
struct bt_notification *ret = NULL;
+ /* Make sure that the event contains at least one bit of data */
+ if (notit->buf.at == notit->buf.last_eh_at) {
+ BT_LOGE("Cannot create empty event with 0 bits of data: "
+ "notit-addr=%p, packet-cur=%zu",
+ notit, packet_at(notit));
+ goto end;
+ }
+
/* Create event */
event = create_event(notit);
if (!event) {
/* Create event */
event = create_event(notit);
if (!event) {