From 253fffe7fb699c39c34d6c13f3b9fed93f95a07a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 16 Jan 2025 15:15:47 +0100 Subject: [PATCH] F1AP IDs: refactor common code --- openair2/F1AP/f1ap_ids.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/openair2/F1AP/f1ap_ids.c b/openair2/F1AP/f1ap_ids.c index 64d4b0b938..7dba047a1a 100644 --- a/openair2/F1AP/f1ap_ids.c +++ b/openair2/F1AP/f1ap_ids.c @@ -29,6 +29,14 @@ #include "common/utils/assertions.h" +static f1_ue_data_t *get_hashtable_data(hash_table_t *ht, uint64_t ue_id) +{ + void *data = NULL; + hashtable_rc_t ret = hashtable_get(ht, ue_id, &data); + AssertFatal(ret == HASH_TABLE_OK && data != NULL, "element for ue_id %ld not found\n", ue_id); + return data; +} + /* we have separate versions for CU and DU, as both CU&DU might coexist in the * same process */ static hash_table_t *cu2du_ue_mapping; @@ -74,11 +82,7 @@ f1_ue_data_t cu_get_f1_ue_data(uint32_t ue_id) { pthread_mutex_lock(&cu2du_mutex); DevAssert(cu2du_ue_mapping != NULL); - uint64_t key = ue_id; - void *data = NULL; - hashtable_rc_t ret = hashtable_get(cu2du_ue_mapping, key, &data); - AssertFatal(ret == HASH_TABLE_OK && data != NULL, "element for ue_id %d not found\n", ue_id); - f1_ue_data_t ued = *(f1_ue_data_t *)data; + f1_ue_data_t ued = *get_hashtable_data(cu2du_ue_mapping, ue_id); pthread_mutex_unlock(&cu2du_mutex); return ued; } @@ -137,11 +141,7 @@ f1_ue_data_t du_get_f1_ue_data(uint32_t ue_id) { pthread_mutex_lock(&du2cu_mutex); DevAssert(du2cu_ue_mapping != NULL); - uint64_t key = ue_id; - void *data = NULL; - hashtable_rc_t ret = hashtable_get(du2cu_ue_mapping, key, &data); - AssertFatal(ret == HASH_TABLE_OK && data != NULL, "element for ue_id %d not found\n", ue_id); - f1_ue_data_t ued = *(f1_ue_data_t *)data; + f1_ue_data_t ued = *get_hashtable_data(du2cu_ue_mapping, ue_id); pthread_mutex_unlock(&du2cu_mutex); return ued; }