if (data_buffer_size < data_size) {
/* In case the realloc fails, we can free the memory */
- char *tmp_data_ptr = data_buffer;
- data_buffer = realloc(data_buffer, data_size);
- if (!data_buffer) {
+ char *tmp_data_ptr;
+
+ tmp_data_ptr = realloc(data_buffer, data_size);
+ if (!tmp_data_ptr) {
ERR("Allocating data buffer");
- free(tmp_data_ptr);
+ free(data_buffer);
ret = -1;
goto end;
}
+ data_buffer = tmp_data_ptr;
data_buffer_size = data_size;
}
memset(data_buffer, 0, data_size);
* structure considering that the other side will adapt.
*/
- ret = sscanf(VERSION, "%u.%u", &reply.major, &reply.minor);
+ ret = sscanf(VERSION, "%10u.%10u", &reply.major, &reply.minor);
if (ret < 2) {
ERR("Error in scanning version");
ret = -1;
data_size = be32toh(data_hdr.data_size);
if (data_buffer_size < data_size) {
- char *tmp_data_ptr = data_buffer;
- data_buffer = realloc(data_buffer, data_size);
- if (!data_buffer) {
+ char *tmp_data_ptr;
+
+ tmp_data_ptr = realloc(data_buffer, data_size);
+ if (!tmp_data_ptr) {
ERR("Allocating data buffer");
- free(tmp_data_ptr);
+ free(data_buffer);
ret = -1;
goto end_unlock;
}
+ data_buffer = tmp_data_ptr;
data_buffer_size = data_size;
}
memset(data_buffer, 0, data_size);
/* Parse arguments */
progname = argv[0];
- if ((ret = parse_args(argc, argv) < 0)) {
+ if ((ret = parse_args(argc, argv)) < 0) {
goto exit;
}
*/
void consumer_output_send_destroy_relayd(struct consumer_output *consumer)
{
- int ret;
struct lttng_ht_iter iter;
struct consumer_socket *socket;
rcu_read_lock();
cds_lfht_for_each_entry(consumer->socks->ht, &iter.iter, socket,
node.node) {
+ int ret;
+
/* Send destroy relayd command */
ret = consumer_send_destroy_relayd(socket, consumer);
if (ret < 0) {
int fd, pos, ret;
char *event;
size_t nbmem, count = 0;
- ssize_t size;
FILE *fp;
struct lttng_event *elist;
goto end;
}
- while ((size = fscanf(fp, "event { name = %m[^;]; };%n\n", &event, &pos)) == 1) {
+ while (fscanf(fp, "event { name = %m[^;]; };%n\n", &event, &pos) == 1) {
if (count >= nbmem) {
struct lttng_event *new_elist;
static int send_unix_sock(int sock, void *buf, size_t len)
{
/* Check valid length */
- if (len <= 0) {
+ if (len == 0) {
return -1;
}
static int join_consumer_thread(struct consumer_data *consumer_data)
{
void *status;
- int ret;
/* Consumer pid must be a real one. */
if (consumer_data->pid > 0) {
+ int ret;
ret = kill(consumer_data->pid, SIGTERM);
if (ret) {
ERR("Error killing consumer daemon");
*/
static int start_consumerd(struct consumer_data *consumer_data)
{
- int ret, err;
+ int ret;
/*
* Set the listen() state on the socket since there is a possible race
error:
/* Cleanup already created socket on error. */
if (consumer_data->err_sock >= 0) {
+ int err;
+
err = close(consumer_data->err_sock);
if (err < 0) {
PERROR("close consumer data error socket");
/* Parse arguments */
progname = argv[0];
- if ((ret = parse_args(argc, argv) < 0)) {
+ if ((ret = parse_args(argc, argv)) < 0) {
goto error;
}
*/
struct ltt_kernel_session *trace_kernel_create_session(char *path)
{
- int ret;
struct ltt_kernel_session *lks = NULL;
/* Allocate a new ltt kernel session */
lks->tmp_consumer = NULL;
if (path && strlen(path) > 0) {
+ int ret;
+
/* Use the default consumer output which is the tracing session path. */
ret = snprintf(lks->consumer->dst.trace_path, PATH_MAX,
"%s" DEFAULT_KERNEL_TRACE_DIR, path);
*/
void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream)
{
- int ret;
-
DBG("[trace] Closing stream fd %d", stream->fd);
/* Close kernel fd */
if (stream->fd >= 0) {
+ int ret;
+
ret = close(stream->fd);
if (ret) {
PERROR("close");
*/
void trace_kernel_destroy_event(struct ltt_kernel_event *event)
{
- int ret;
-
if (event->fd >= 0) {
+ int ret;
+
DBG("[trace] Closing event fd %d", event->fd);
/* Close kernel fd */
ret = close(event->fd);
*/
void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata)
{
- int ret;
-
DBG("[trace] Closing metadata fd %d", metadata->fd);
/* Close kernel fd */
if (metadata->fd >= 0) {
+ int ret;
+
ret = close(metadata->fd);
if (ret) {
PERROR("close");
struct ltt_ust_session *trace_ust_create_session(char *path,
unsigned int session_id, struct lttng_domain *domain)
{
- int ret;
struct ltt_ust_session *lus;
/* Allocate a new ltt ust session */
/* Use the default consumer output which is the tracing session path. */
if (path && strlen(path) > 0) {
+ int ret;
+
ret = snprintf(lus->consumer->dst.trace_path, PATH_MAX,
"%s" DEFAULT_UST_TRACE_DIR, path);
if (ret < 0) {
static struct ust_app_session *create_ust_app_session(
struct ltt_ust_session *usess, struct ust_app *app)
{
- int ret;
struct ust_app_session *ua_sess;
health_code_update(&health_thread_cmd);
health_code_update(&health_thread_cmd);
if (ua_sess->handle == -1) {
+ int ret;
+
ret = ustctl_create_session(app->sock);
if (ret < 0) {
ERR("Creating session for app pid %d", app->pid);
size_t nbmem, count = 0;
struct lttng_ht_iter iter;
struct ust_app *app;
- struct lttng_event *tmp;
+ struct lttng_event *tmp_event;
nbmem = UST_APP_EVENT_LIST_SIZE;
- tmp = zmalloc(nbmem * sizeof(struct lttng_event));
- if (tmp == NULL) {
+ tmp_event = zmalloc(nbmem * sizeof(struct lttng_event));
+ if (tmp_event == NULL) {
PERROR("zmalloc ust app events");
ret = -ENOMEM;
goto error;
health_code_update(&health_thread_cmd);
if (count >= nbmem) {
/* In case the realloc fails, we free the memory */
- void *tmp_ptr = (void *) tmp;
+ void *ptr;
+
DBG2("Reallocating event list from %zu to %zu entries", nbmem,
2 * nbmem);
nbmem *= 2;
- tmp = realloc(tmp, nbmem * sizeof(struct lttng_event));
- if (tmp == NULL) {
+ ptr = realloc(tmp_event, nbmem * sizeof(struct lttng_event));
+ if (ptr == NULL) {
PERROR("realloc ust app events");
- free(tmp_ptr);
+ free(tmp_event);
ret = -ENOMEM;
goto rcu_error;
}
+ tmp_event = ptr;
}
- memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
- tmp[count].loglevel = uiter.loglevel;
- tmp[count].type = (enum lttng_event_type) LTTNG_UST_TRACEPOINT;
- tmp[count].pid = app->pid;
- tmp[count].enabled = -1;
+ memcpy(tmp_event[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
+ tmp_event[count].loglevel = uiter.loglevel;
+ tmp_event[count].type = (enum lttng_event_type) LTTNG_UST_TRACEPOINT;
+ tmp_event[count].pid = app->pid;
+ tmp_event[count].enabled = -1;
count++;
}
}
ret = count;
- *events = tmp;
+ *events = tmp_event;
DBG2("UST app list events done (%zu events)", count);
size_t nbmem, count = 0;
struct lttng_ht_iter iter;
struct ust_app *app;
- struct lttng_event_field *tmp;
+ struct lttng_event_field *tmp_event;
nbmem = UST_APP_EVENT_LIST_SIZE;
- tmp = zmalloc(nbmem * sizeof(struct lttng_event_field));
- if (tmp == NULL) {
+ tmp_event = zmalloc(nbmem * sizeof(struct lttng_event_field));
+ if (tmp_event == NULL) {
PERROR("zmalloc ust app event fields");
ret = -ENOMEM;
goto error;
health_code_update(&health_thread_cmd);
if (count >= nbmem) {
/* In case the realloc fails, we free the memory */
- void *tmp_ptr = (void *) tmp;
+ void *ptr;
+
DBG2("Reallocating event field list from %zu to %zu entries", nbmem,
2 * nbmem);
nbmem *= 2;
- tmp = realloc(tmp, nbmem * sizeof(struct lttng_event_field));
- if (tmp == NULL) {
+ ptr = realloc(tmp_event, nbmem * sizeof(struct lttng_event_field));
+ if (ptr == NULL) {
PERROR("realloc ust app event fields");
- free(tmp_ptr);
+ free(tmp_event);
ret = -ENOMEM;
goto rcu_error;
}
+ tmp_event = ptr;
}
- memcpy(tmp[count].field_name, uiter.field_name, LTTNG_UST_SYM_NAME_LEN);
- tmp[count].type = uiter.type;
- tmp[count].nowrite = uiter.nowrite;
+ memcpy(tmp_event[count].field_name, uiter.field_name, LTTNG_UST_SYM_NAME_LEN);
+ tmp_event[count].type = uiter.type;
+ tmp_event[count].nowrite = uiter.nowrite;
- memcpy(tmp[count].event.name, uiter.event_name, LTTNG_UST_SYM_NAME_LEN);
- tmp[count].event.loglevel = uiter.loglevel;
- tmp[count].event.type = LTTNG_UST_TRACEPOINT;
- tmp[count].event.pid = app->pid;
- tmp[count].event.enabled = -1;
+ memcpy(tmp_event[count].event.name, uiter.event_name, LTTNG_UST_SYM_NAME_LEN);
+ tmp_event[count].event.loglevel = uiter.loglevel;
+ tmp_event[count].event.type = LTTNG_UST_TRACEPOINT;
+ tmp_event[count].event.pid = app->pid;
+ tmp_event[count].event.enabled = -1;
count++;
}
}
ret = count;
- *fields = tmp;
+ *fields = tmp_event;
DBG2("UST app list event fields done (%zu events)", count);
int i = 0;
char str[LTTNG_SYMBOL_NAME_LEN];
- while (inputstr[i] != '\0' && i < LTTNG_SYMBOL_NAME_LEN) {
+ while (i < LTTNG_SYMBOL_NAME_LEN && inputstr[i] != '\0') {
str[i] = toupper(inputstr[i]);
i++;
}
*/
int cmd_list(int argc, const char **argv)
{
- int opt, i, ret = CMD_SUCCESS;
- int nb_domain;
+ int opt, ret = CMD_SUCCESS;
const char *session_name;
static poptContext pc;
struct lttng_domain domain;
goto end;
}
} else {
+ int i, nb_domain;
+
/* We want all domain(s) */
nb_domain = lttng_list_domains(session_name, &domains);
if (nb_domain < 0) {
*/
static int view_trace(void)
{
- int ret, count, i, found = 0;
+ int ret;
char *session_name, *trace_path;
struct lttng_session *sessions = NULL;
DBG("Viewing trace for session %s", session_name);
if (session_name) {
+ int i, count, found = 0;
+
/* Getting all sessions */
count = lttng_list_sessions(&sessions);
if (count < 0) {
{
code = -code;
- if (code < LTTCOMM_CONSUMERD_COMMAND_SOCK_READY && code > LTTCOMM_NR) {
+ if (code < LTTCOMM_CONSUMERD_COMMAND_SOCK_READY || code > LTTCOMM_NR) {
code = LTTCOMM_NR;
}
char dummy = 0;
memset(&msg, 0, sizeof(msg));
+ memset(tmp, 0, CMSG_SPACE(sizeof_fds) * sizeof(char));
if (nb_fd > LTTCOMM_MAX_SEND_FDS)
return -EINVAL;
#endif /* __linux__ */
memset(&msg, 0, sizeof(msg));
+ memset(anc_buf, 0, CMSG_SPACE(sizeof_cred) * sizeof(char));
iov[0].iov_base = buf;
iov[0].iov_len = len;
* so we can define the control and data port.
*/
while (*purl == ':') {
- int port;
const char *port_b, *port_e;
char *port_f;
port_e = purl;
if (port_b != port_e) {
+ int port;
+
port_f = utils_strdupdelim(port_b, port_e);
if (port_f == NULL) {
goto free_error;
struct lttng_ust_shm_handle *handle;
struct lttng_ust_lib_ring_buffer *buf;
char dummy;
- ssize_t readlen;
DBG("In read_subbuffer (wait_fd: %d, stream key: %d)",
stream->wait_fd, stream->key);
/* We can consume the 1 byte written into the wait_fd by UST */
if (!stream->hangup_flush_done) {
+ ssize_t readlen;
+
do {
readlen = read(stream->wait_fd, &dummy, 1);
} while (readlen == -1 && errno == EINTR);
static ssize_t parse_str_urls_to_uri(const char *ctrl_url, const char *data_url,
struct lttng_uri **uris)
{
- int ret;
unsigned int equal = 1, idx = 0;
/* Add the "file://" size to the URL maximum size */
char url[PATH_MAX + 7];
* Check if first character is a '/' or else reject the URL.
*/
if (ctrl_url && ctrl_url[0] == '/') {
+ int ret;
+
ret = snprintf(url, sizeof(url), "file://%s", ctrl_url);
if (ret < 0) {
PERROR("snprintf file url");
*/
static int set_session_daemon_path(void)
{
- int ret;
int in_tgroup = 0; /* In tracing group */
uid_t uid;
}
if (uid != 0) {
+ int ret;
+
if (in_tgroup) {
/* Tracing group */
ret = try_connect_sessiond(sessiond_sock_path);
*/
static int set_health_socket_path(void)
{
- int ret;
int in_tgroup = 0; /* In tracing group */
uid_t uid;
const char *home;
}
if (uid != 0) {
+ int ret;
+
/*
* With GNU C < 2.1, snprintf returns -1 if the target buffer is too small;
* With GNU C >= 2.1, snprintf returns the required size (excluding closing null)
int _lttng_create_session_ext(const char *name, const char *url,
const char *datetime)
{
- int ret;
ssize_t size;
struct lttcomm_session_msg lsm;
struct lttng_uri *uris = NULL;
lsm.u.uri.size = size;
if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
+ int ret;
+
ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s-%s", name,
datetime);
if (ret < 0) {