*/
#define _LGPL_SOURCE
-#include <assert.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#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>
*
* 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)
{
{
int ret;
- assert(len > 0);
+ LTTNG_ASSERT(len > 0);
if (!connected) {
ret = -LTTNG_ERR_NO_SESSIOND;
*
* If yes return 1, else return -1.
*/
-LTTNG_HIDDEN
int lttng_check_tracing_group(void)
{
gid_t *grp_list, tracing_gid;
*
* On success, return the socket's file descriptor. On error, return -1.
*/
-LTTNG_HIDDEN int connect_sessiond(void)
+int connect_sessiond(void)
{
int ret;
*
* 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,
return ret;
}
-LTTNG_HIDDEN
int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
struct lttng_payload *reply)
{
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) {
int err;
char *agent_filter = NULL;
- assert(ev);
+ LTTNG_ASSERT(ev);
/* Don't add filter for the '*' event. */
if (strcmp(ev->name, "*") != 0) {
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);
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);
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);
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;
}
}
/* 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;
*/
int lttng_set_tracing_group(const char *name)
{
+ int ret = 0;
+ char *new_group;
+
if (name == NULL) {
- return -LTTNG_ERR_INVALID;
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
}
- if (asprintf(&tracing_group, "%s", name) < 0) {
- return -LTTNG_ERR_FATAL;
+ new_group = strdup(name);
+ if (!new_group) {
+ ret = -LTTNG_ERR_FATAL;
+ goto end;
}
- return 0;
+ free(tracing_group);
+ tracing_group = new_group;
+ new_group = NULL;
+
+end:
+ return ret;
}
int lttng_calibrate(struct lttng_handle *handle,
* No socket path set. Weird error which means the constructor
* was not called.
*/
- assert(0);
+ abort();
}
ret = try_connect_sessiond(sessiond_sock_path);