From fa2061debad0ebf5c18598c12c58d84af4304aea Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 24 Jul 2017 17:21:17 -0400 Subject: [PATCH] Fix: assert compared unsigned to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Found by Coverity: CID 1376195 (#1 of 1): Macro compares unsigned to 0 (NO_EFFECT) unsigned_compare: This greater-than-or-equal-to-zero comparison of an unsigned value is always true. event_class_id >= 0UL. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- lib/ctf-ir/stream.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ctf-ir/stream.c b/lib/ctf-ir/stream.c index f13c024a..fcd8c80e 100644 --- a/lib/ctf-ir/stream.c +++ b/lib/ctf-ir/stream.c @@ -1156,7 +1156,7 @@ static int auto_populate_event_header(struct bt_ctf_stream *stream, int ret = 0; struct bt_ctf_field *id_field = NULL, *timestamp_field = NULL; struct bt_ctf_clock_class *mapped_clock_class = NULL; - uint64_t event_class_id; + int64_t event_class_id; assert(event); @@ -1175,8 +1175,12 @@ static int auto_populate_event_header(struct bt_ctf_stream *stream, stream, bt_ctf_stream_get_name(stream), event); id_field = bt_ctf_field_structure_get_field(event->event_header, "id"); - event_class_id = (uint64_t) bt_ctf_event_class_get_id(event->event_class); - assert(event_class_id >= 0); + event_class_id = bt_ctf_event_class_get_id(event->event_class); + if (event_class_id < 0) { + BT_LOGE("Event class ID cannot be found"); + ret = -1; + goto end; + } if (id_field && bt_ctf_field_type_is_integer(id_field->type)) { ret = set_integer_field_value(id_field, event_class_id); if (ret) { -- 2.34.1