From e2530e2ba1980b76aa76ae1c8746ce8f40f232da Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Wed, 20 Jan 2021 16:18:09 -0500 Subject: [PATCH] Cleanup: add `lttng_ht_type_str()` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: I1f7d9ae029f11a454cbda6b05eb22457d6b0be74 --- src/common/hashtable/hashtable.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/common/hashtable/hashtable.c b/src/common/hashtable/hashtable.c index f449fab8b..af16676cc 100644 --- a/src/common/hashtable/hashtable.c +++ b/src/common/hashtable/hashtable.c @@ -76,6 +76,24 @@ static int match_two_u64(struct cds_lfht_node *node, const void *key) return hash_match_key_two_u64((void *) &match_node->key, (void *) key); } +static inline +const char *lttng_ht_type_str(enum lttng_ht_type type) +{ + switch (type) { + case LTTNG_HT_TYPE_STRING: + return "STRING"; + case LTTNG_HT_TYPE_ULONG: + return "ULONG"; + case LTTNG_HT_TYPE_U64: + return "U64"; + case LTTNG_HT_TYPE_TWO_U64: + return "TWO_U64"; + default: + ERR("Unknown lttng hashtable type %d", type); + abort(); + } +} + /* * Return an allocated lttng hashtable. */ @@ -132,7 +150,8 @@ struct lttng_ht *lttng_ht_new(unsigned long size, int type) goto error; } - DBG3("Created hashtable size %lu at %p of type %d", size, ht->ht, type); + DBG3("Created hashtable size %lu at %p of type %s", size, ht->ht, + lttng_ht_type_str(type)); return ht; -- 2.34.1