From e74dbb3322844980db73bcd994891c48c68be862 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 27 Jun 2019 16:03:55 -0400 Subject: [PATCH] lib: fix compilation for glib < 2.40 Code from commit "lib: add logic in auto-seek to recreate stream state" uses the return value of function g_hash_table_insert to validate that the inserted key did not previously exist in the hash table. This feature was introduced in glib 2.40, before that the function returned void. To avoid breaking compatibility with glib < 2.40, we can do a lookup before inserting to achieve the same result. Change-Id: Ibd5f58fb6ab8f083a3152105db9e05522893132c Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1560 Reviewed-by: Philippe Proulx --- src/lib/graph/iterator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index a53a89d8..31c4ec3f 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -25,6 +25,7 @@ #include "lib/logging.h" #include "compat/compiler.h" +#include "compat/glib.h" #include "lib/trace-ir/clock-class.h" #include "lib/trace-ir/clock-snapshot.h" #include @@ -1220,7 +1221,6 @@ skip_msg: { const struct bt_message_stream *stream_msg = (const void *) msg; struct auto_seek_stream_state *stream_state; - gboolean did_not_exist; /* Update stream's state: stream began. */ stream_state = create_auto_seek_stream_state(); @@ -1230,8 +1230,9 @@ skip_msg: } stream_state->state = AUTO_SEEK_STREAM_STATE_STREAM_BEGAN; - did_not_exist = g_hash_table_insert(stream_states, stream_msg->stream, stream_state); - BT_ASSERT(did_not_exist); + + BT_ASSERT(!bt_g_hash_table_contains(stream_states, stream_msg->stream)); + g_hash_table_insert(stream_states, stream_msg->stream, stream_state); break; } case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: -- 2.34.1