liblttng-ctl: use export list to define exported symbols
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 7a38699d9c8438cbedd423a12fd2204884dc266f..239ed8f33b9472c814937d2323f12614acbc2f8c 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 #define _LGPL_SOURCE
-#include <assert.h>
 #include <grp.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -82,7 +81,6 @@ int lttng_opt_mi;
  *
  * If domain is unknown, default domain will be the kernel.
  */
-LTTNG_HIDDEN
 void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
                struct lttng_domain *src)
 {
@@ -198,7 +196,7 @@ static int recv_data_sessiond(void *buf, size_t len)
 {
        int ret;
 
-       assert(len > 0);
+       LTTNG_ASSERT(len > 0);
 
        if (!connected) {
                ret = -LTTNG_ERR_NO_SESSIOND;
@@ -245,7 +243,6 @@ end:
  *
  * If yes return 1, else return -1.
  */
-LTTNG_HIDDEN
 int lttng_check_tracing_group(void)
 {
        gid_t *grp_list, tracing_gid;
@@ -388,7 +385,7 @@ static int set_session_daemon_path(void)
                in_tgroup = lttng_check_tracing_group();
        }
 
-       if ((uid == 0) || in_tgroup) {
+       if ((uid == 0) || in_tgroup == 1) {
                const int ret = lttng_strncpy(sessiond_sock_path,
                                DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
                                sizeof(sessiond_sock_path));
@@ -435,7 +432,7 @@ error:
  *
  * On success, return the socket's file descriptor. On error, return -1.
  */
-LTTNG_HIDDEN int connect_sessiond(void)
+int connect_sessiond(void)
 {
        int ret;
 
@@ -534,7 +531,6 @@ end:
  *
  * Return size of data (only payload, not header) or a negative error code.
  */
-LTTNG_HIDDEN
 int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
                const int *fds, size_t nb_fd, const void *vardata,
                size_t vardata_len, void **user_payload_buf,
@@ -606,7 +602,6 @@ end:
        return ret;
 }
 
-LTTNG_HIDDEN
 int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
        struct lttng_payload *reply)
 {
@@ -614,8 +609,8 @@ int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
        struct lttcomm_lttng_msg llm;
        const int fd_count = lttng_payload_view_get_fd_handle_count(message);
 
-       assert(reply->buffer.size == 0);
-       assert(lttng_dynamic_pointer_array_get_count(&reply->_fd_handles) == 0);
+       LTTNG_ASSERT(reply->buffer.size == 0);
+       LTTNG_ASSERT(lttng_dynamic_pointer_array_get_count(&reply->_fd_handles) == 0);
 
        ret = connect_sessiond();
        if (ret < 0) {
@@ -1021,7 +1016,7 @@ static char *set_agent_filter(const char *filter, struct lttng_event *ev)
        int err;
        char *agent_filter = NULL;
 
-       assert(ev);
+       LTTNG_ASSERT(ev);
 
        /* Don't add filter for the '*' event. */
        if (strcmp(ev->name, "*") != 0) {
@@ -1134,7 +1129,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
        if (ev->name[0] == '\0') {
                /* Enable all events. */
                ret = lttng_strncpy(ev->name, "*", sizeof(ev->name));
-               assert(ret == 0);
+               LTTNG_ASSERT(ret == 0);
        }
 
        COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
@@ -1204,7 +1199,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
        for (i = 0; i < exclusion_count; i++) {
                size_t exclusion_len;
 
-               exclusion_len = lttng_strnlen(*(exclusion_list + i),
+               exclusion_len = lttng_strnlen(exclusion_list[i],
                                LTTNG_SYMBOL_NAME_LEN);
                if (exclusion_len == LTTNG_SYMBOL_NAME_LEN) {
                        /* Exclusion is not NULL-terminated. */
@@ -1213,7 +1208,17 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
                }
 
                ret = lttng_dynamic_buffer_append(&payload.buffer,
-                               *(exclusion_list + i), LTTNG_SYMBOL_NAME_LEN);
+                               exclusion_list[i], exclusion_len);
+               if (ret) {
+                       goto mem_error;
+               }
+
+               /*
+                * Padding the rest of the entry with zeros. Every exclusion
+                * entries take LTTNG_SYMBOL_NAME_LEN bytes in the buffer.
+                */
+               ret = lttng_dynamic_buffer_set_size(&payload.buffer,
+                               LTTNG_SYMBOL_NAME_LEN * (i + 1));
                if (ret) {
                        goto mem_error;
                }
@@ -1269,7 +1274,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
                        goto mem_error;
                }
 
-               assert(fd_count == 0 || fd_count == 1);
+               LTTNG_ASSERT(fd_count == 0 || fd_count == 1);
                if (fd_count == 1) {
                        struct fd_handle *h =
                                        lttng_payload_view_pop_fd_handle(&view);
@@ -2043,7 +2048,7 @@ int lttng_destroy_session(const char *session_name)
                ret = (int) -ret_code;
                goto end;
        }
-       assert(handle);
+       LTTNG_ASSERT(handle);
 
        /* Block until the completion of the destruction of the session. */
        status = lttng_destruction_handle_wait_for_completion(handle, -1);
@@ -2873,7 +2878,7 @@ int lttng_session_daemon_alive(void)
                 * No socket path set. Weird error which means the constructor
                 * was not called.
                 */
-               assert(0);
+               abort();
        }
 
        ret = try_connect_sessiond(sessiond_sock_path);
This page took 0.02676 seconds and 4 git commands to generate.