From: Mathieu Desnoyers Date: Mon, 24 Jul 2017 21:21:17 +0000 (-0400) Subject: Fix: assert compared unsigned to 0 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=fa2061debad0ebf5c18598c12c58d84af4304aea Fix: assert compared unsigned to 0 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 --- 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) {