From: Youngjae Cho Date: Thu, 5 Dec 2024 06:57:23 +0000 (+0900) Subject: common: Fix module_hash hash operations from direct to string X-Git-Tag: accepted/tizen/9.0/unified/20250118.074051~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=568e37c5b27362720bfeaef060aa5b6fa32ea447;p=platform%2Fhal%2Fapi%2Fcommon.git common: Fix module_hash hash operations from direct to string It matters when it comes to unittest. The unittest code below may cause an unintended result. > char *library_name = g_strdup_printf("libhal-backend-%s-user-specific.so", > info.backend_module_name_); > int ret = hal_common_get_backend_with_library_name(info.module_, (void **)&backend_module_data, library_name); Over the instantiated testcases, the g_strdup_printf() sometimes returns same address containing different string. In this case, if the hash and equal function are g_direct_hash() and g_direct_equal(), then it tests those different string as equal because both strings are held by the same address. Therefore, it is not enough to compare the starting address but needs to compare the entire string. Change-Id: Ifecbac1db3d03d61137e31b74e356ba0370c345d Signed-off-by: Youngjae Cho --- diff --git a/src/hal-api-conf.c b/src/hal-api-conf.c index 8e57d8a..5aff07a 100644 --- a/src/hal-api-conf.c +++ b/src/hal-api-conf.c @@ -153,7 +153,7 @@ int _hal_api_conf_init(void) if (_usage_count++ > 0) return 0; - _module_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _destroy_module_info); + _module_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, _destroy_module_info); return 0; }