Cleanup: namespace 'align' macros
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index d9805e22288f44b7dc2df548fd1e21c18482b3ad..47887c0293645b61aa324e2164c10d86c1cc4b30 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 #define _LGPL_SOURCE
-#include <assert.h>
 #include <grp.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -19,6 +18,7 @@
 #include <unistd.h>
 
 #include <common/bytecode/bytecode.h>
+#include <common/align.h>
 #include <common/common.h>
 #include <common/compat/errno.h>
 #include <common/compat/string.h>
@@ -82,7 +82,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 +197,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 +244,6 @@ end:
  *
  * If yes return 1, else return -1.
  */
-LTTNG_HIDDEN
 int lttng_check_tracing_group(void)
 {
        gid_t *grp_list, tracing_gid;
@@ -435,7 +433,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 +532,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 +603,6 @@ end:
        return ret;
 }
 
-LTTNG_HIDDEN
 int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
        struct lttng_payload *reply)
 {
@@ -614,8 +610,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 +1017,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 +1130,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 +1200,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 +1209,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 +1275,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 +2049,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);
@@ -2451,7 +2457,7 @@ int lttng_list_events(struct lttng_handle *handle,
                        storage_req += ext_comm->nb_exclusions *
                                        LTTNG_SYMBOL_NAME_LEN;
                        /* Padding to ensure the flat probe is aligned. */
-                       storage_req = ALIGN_TO(storage_req, sizeof(uint64_t));
+                       storage_req = lttng_align_ceil(storage_req, sizeof(uint64_t));
                        storage_req += probe_storage_req;
                }
        }
@@ -2542,7 +2548,7 @@ int lttng_list_events(struct lttng_handle *handle,
 
                        /* Insert padding to align to 64-bits. */
                        ret = lttng_dynamic_buffer_set_size(&listing,
-                                       ALIGN_TO(listing.size,
+                                       lttng_align_ceil(listing.size,
                                                        sizeof(uint64_t)));
                        if (ret) {
                                ret = -LTTNG_ERR_NOMEM;
@@ -2873,7 +2879,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.026358 seconds and 4 git commands to generate.