From 95dc9c849ed229971f663b54841d8729c7495f47 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Fri, 3 May 2019 15:06:45 -0400 Subject: [PATCH] fix: g_hash_table_insert prior to glib 2.40 returns void Even the post glib 2.40 version will only return false if the value is already present in the hashtable but will not fail to add it. The old value will be handled according to the configuration of the hashtable which should not be an error. Signed-off-by: Michael Jeanson Change-Id: I5512c921ce220bf8a956c61f594d6a27e6ceb41e Reviewed-on: https://review.lttng.org/c/babeltrace/+/1247 Tested-by: jenkins Reviewed-by: Philippe Proulx --- compat/compat_mman.c | 5 +---- fd-cache/fd-cache.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/compat/compat_mman.c b/compat/compat_mman.c index bbca82ca..6b0229e3 100644 --- a/compat/compat_mman.c +++ b/compat/compat_mman.c @@ -244,10 +244,7 @@ void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, } /* Add the new mapping to the hashtable. */ - if (!g_hash_table_insert(mmap_mappings, mapping_addr, mapping)) { - BT_LOGF_STR("Failed to insert mapping in the hashtable."); - abort(); - } + g_hash_table_insert(mmap_mappings, mapping_addr, mapping); mmap_unlock(); diff --git a/fd-cache/fd-cache.c b/fd-cache/fd-cache.c index 5dad8dad..c0b6859b 100644 --- a/fd-cache/fd-cache.c +++ b/fd-cache/fd-cache.c @@ -154,7 +154,6 @@ struct bt_fd_cache_handle *bt_fd_cache_get_handle(struct bt_fd_cache *fdc, fd_internal = g_hash_table_lookup(fdc->cache, &fk); if (!fd_internal) { - gboolean ret; struct file_key *file_key; int fd = open(path, O_RDONLY); @@ -182,9 +181,7 @@ struct bt_fd_cache_handle *bt_fd_cache_get_handle(struct bt_fd_cache *fdc, fd_internal->key = file_key; /* Insert the newly created fd handle. */ - ret = g_hash_table_insert(fdc->cache, fd_internal->key, - fd_internal); - BT_ASSERT(ret); + g_hash_table_insert(fdc->cache, fd_internal->key, fd_internal); } BT_ASSERT(fd_internal->ref_count >= 0); -- 2.34.1