From: Francis Deslauriers Date: Fri, 9 Feb 2018 20:15:24 +0000 (-0500) Subject: Rename lttng_ust_enum_get to lttng_ust_enum_get_from_desc X-Git-Tag: v2.11.0-rc1~21 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b33b46f7161604cb9168e9bbc854413cf18269be;p=lttng-ust.git Rename lttng_ust_enum_get to lttng_ust_enum_get_from_desc Change the prototype to take a descriptor instead of a char *. Now that provider names can have duplicates enum names are not necessarily unique. Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 019b0ebb..86733503 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -731,8 +731,9 @@ int lttng_session_active(void); typedef int (*t_statedump_func_ptr)(struct lttng_session *session); void lttng_handle_pending_statedump(void *owner); struct cds_list_head *_lttng_get_sessions(void); -struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session, - const char *enum_name); + +struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session, + const struct lttng_enum_desc *enum_desc); void lttng_ust_dl_update(void *ip); void lttng_ust_fixup_fd_tracker_tls(void); diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index 3d1c6503..679b40e6 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -911,8 +911,7 @@ int serialize_basic_type(struct lttng_session *session, if (session) { const struct lttng_enum *_enum; - _enum = lttng_ust_enum_get(session, - lbt->enumeration.desc->name); + _enum = lttng_ust_enum_get_from_desc(session, lbt->enumeration.desc); if (!_enum) return -EINVAL; ubt->enumeration.id = _enum->id; diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 57eb6f7f..e130ec62 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -257,21 +257,19 @@ int lttng_enum_create(const struct lttng_enum_desc *desc, const char *enum_name = desc->name; struct lttng_enum *_enum; struct cds_hlist_head *head; - struct cds_hlist_node *node; int ret = 0; size_t name_len = strlen(enum_name); uint32_t hash; int notify_socket; + /* Check if this enum is already registered for this session. */ hash = jhash(enum_name, name_len, 0); head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)]; - cds_hlist_for_each_entry(_enum, node, head, hlist) { - assert(_enum->desc); - if (!strncmp(_enum->desc->name, desc->name, - LTTNG_UST_SYM_NAME_LEN - 1)) { - ret = -EEXIST; - goto exist; - } + + _enum = lttng_ust_enum_get_from_desc(session, desc); + if (_enum) { + ret = -EEXIST; + goto exist; } notify_socket = lttng_get_notify_socket(session->owner); diff --git a/liblttng-ust/ust-core.c b/liblttng-ust/ust-core.c index 5355f5c1..76f729a6 100644 --- a/liblttng-ust/ust-core.c +++ b/liblttng-ust/ust-core.c @@ -63,21 +63,20 @@ void lttng_transport_unregister(struct lttng_transport *transport) /* * Needed by comm layer. */ -struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session, - const char *enum_name) +struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session, + const struct lttng_enum_desc *enum_desc) { struct lttng_enum *_enum; struct cds_hlist_head *head; struct cds_hlist_node *node; - size_t name_len = strlen(enum_name); + size_t name_len = strlen(enum_desc->name); uint32_t hash; - hash = jhash(enum_name, name_len, 0); + hash = jhash(enum_desc->name, name_len, 0); head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)]; cds_hlist_for_each_entry(_enum, node, head, hlist) { assert(_enum->desc); - if (!strncmp(_enum->desc->name, enum_name, - LTTNG_UST_SYM_NAME_LEN - 1)) + if (_enum->desc == enum_desc) return _enum; } return NULL;