Rename lttng_ust_enum_get to lttng_ust_enum_get_from_desc
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 9 Feb 2018 20:15:24 +0000 (15:15 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Feb 2018 20:41:34 +0000 (15:41 -0500)
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 <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-events.h
liblttng-ust-comm/lttng-ust-comm.c
liblttng-ust/lttng-events.c
liblttng-ust/ust-core.c

index 019b0ebb02af5512c893cfe72147963eec88d3cb..867335032214d0d75f3232923e58b3851ca5a95e 100644 (file)
@@ -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);
index 3d1c65038295062559db6dd415fe2b03304d5ec2..679b40e6e40725a60bc166cfd2e4d2dc88f8d5d6 100644 (file)
@@ -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;
index 57eb6f7f3a2c745e77191f7ba9b00d1234383f71..e130ec626d35f3f6d140737d51151245acbc51a6 100644 (file)
@@ -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);
index 5355f5c117ad62104c34ee1fd7cfe2d94f67f810..76f729a6720af105a7f120780ed2da16430b8e11 100644 (file)
@@ -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;
This page took 0.027893 seconds and 4 git commands to generate.