fix: g_hash_table_insert prior to glib 2.40 returns void
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 3 May 2019 19:06:45 +0000 (15:06 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 4 May 2019 01:51:07 +0000 (21:51 -0400)
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 <mjeanson@efficios.com>
Change-Id: I5512c921ce220bf8a956c61f594d6a27e6ceb41e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1247
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
compat/compat_mman.c
fd-cache/fd-cache.c

index bbca82cadbed9e39ba6bce70e3fa63805284fab2..6b0229e38ea4f65481f8a55d5204c2e21294e822 100644 (file)
@@ -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();
 
index 5dad8dad3712ed38a0ac919e53ccaac81d2f798f..c0b6859bb1077a93682be38cfb8241381e2a27f6 100644 (file)
@@ -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);
This page took 0.02562 seconds and 4 git commands to generate.