From: David Goulet Date: Tue, 15 Nov 2011 20:39:37 +0000 (-0500) Subject: Change malloc to zmalloc in lttng-sessiond code X-Git-Tag: v2.0-pre15~112 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ba7f0ae55f6209514025bb538c6fe3faefc32f4b;p=lttng-tools.git Change malloc to zmalloc in lttng-sessiond code Signed-off-by: David Goulet --- diff --git a/lttng-sessiond/channel.c b/lttng-sessiond/channel.c index 14fdfdcae..2dd9840d4 100644 --- a/lttng-sessiond/channel.c +++ b/lttng-sessiond/channel.c @@ -37,7 +37,7 @@ struct lttng_channel *channel_new_default_attr(int dom) chan = zmalloc(sizeof(struct lttng_channel)); if (chan == NULL) { - perror("malloc channel init"); + perror("zmalloc channel init"); goto error_alloc; } @@ -88,9 +88,9 @@ int channel_ust_copy(struct ltt_ust_channel *dst, /* cds_list_for_each_entry(uevent, &src->events.head, list) { - new_uevent = malloc(sizeof(struct ltt_ust_event)); + new_uevent = zmalloc(sizeof(struct ltt_ust_event)); if (new_uevent == NULL) { - perror("malloc ltt_ust_event"); + perror("zmalloc ltt_ust_event"); goto error; } diff --git a/lttng-sessiond/compat/compat-epoll.c b/lttng-sessiond/compat/compat-epoll.c index e909b603c..aca80f331 100644 --- a/lttng-sessiond/compat/compat-epoll.c +++ b/lttng-sessiond/compat/compat-epoll.c @@ -57,7 +57,7 @@ int compat_epoll_create(struct lttng_poll_event *events, int size, int flags) /* This *must* be freed by using lttng_poll_free() */ events->events = zmalloc(size * sizeof(struct epoll_event)); if (events->events == NULL) { - perror("malloc epoll set"); + perror("zmalloc epoll set"); goto error_close; } diff --git a/lttng-sessiond/compat/compat-poll.c b/lttng-sessiond/compat/compat-poll.c index cc4bb0f97..50ef37472 100644 --- a/lttng-sessiond/compat/compat-poll.c +++ b/lttng-sessiond/compat/compat-poll.c @@ -43,7 +43,7 @@ int compat_poll_create(struct lttng_poll_event *events, int size) /* This *must* be freed by using lttng_poll_free() */ events->events = zmalloc(size * sizeof(struct pollfd)); if (events->events == NULL) { - perror("malloc struct pollfd"); + perror("zmalloc struct pollfd"); goto error; } @@ -117,7 +117,7 @@ int compat_poll_del(struct lttng_poll_event *events, int fd) new = zmalloc(new_size * sizeof(struct pollfd)); if (new == NULL) { - perror("malloc poll del"); + perror("zmalloc poll del"); goto error; } diff --git a/lttng-sessiond/kernel-ctl.c b/lttng-sessiond/kernel-ctl.c index 203c01050..52d60f004 100644 --- a/lttng-sessiond/kernel-ctl.c +++ b/lttng-sessiond/kernel-ctl.c @@ -49,9 +49,9 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan, goto error; } - chan->ctx = malloc(sizeof(struct lttng_kernel_context)); + chan->ctx = zmalloc(sizeof(struct lttng_kernel_context)); if (chan->ctx == NULL) { - perror("malloc event context"); + perror("zmalloc event context"); goto error; } @@ -78,9 +78,9 @@ int kernel_add_event_context(struct ltt_kernel_event *event, goto error; } - event->ctx = malloc(sizeof(struct lttng_kernel_context)); + event->ctx = zmalloc(sizeof(struct lttng_kernel_context)); if (event->ctx == NULL) { - perror("malloc event context"); + perror("zmalloc event context"); goto error; } @@ -574,7 +574,7 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events) * See kernel-ctl.h for explanation of this value */ nbmem = KERNEL_EVENT_LIST_SIZE; - elist = malloc(sizeof(struct lttng_event) * nbmem); + elist = zmalloc(sizeof(struct lttng_event) * nbmem); while ((size = fscanf(fp, "event { name = %m[^;]; };%n\n", &event, &pos)) == 1) { if (count > nbmem) { diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index aae9b3dfe..0c93395b4 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -588,9 +588,9 @@ static int setup_lttng_msg(struct command_ctx *cmd_ctx, size_t size) buf_size = size; - cmd_ctx->llm = malloc(sizeof(struct lttcomm_lttng_msg) + buf_size); + cmd_ctx->llm = zmalloc(sizeof(struct lttcomm_lttng_msg) + buf_size); if (cmd_ctx->llm == NULL) { - perror("malloc"); + perror("zmalloc"); ret = -ENOMEM; goto error; } @@ -1260,9 +1260,9 @@ static void *thread_registration_apps(void *data) } /* Create UST registration command for enqueuing */ - ust_cmd = malloc(sizeof(struct ust_command)); + ust_cmd = zmalloc(sizeof(struct ust_command)); if (ust_cmd == NULL) { - perror("ust command malloc"); + perror("ust command zmalloc"); goto error; } @@ -3344,16 +3344,16 @@ static void *thread_manage_clients(void *data) } /* Allocate context command to process the client request */ - cmd_ctx = malloc(sizeof(struct command_ctx)); + cmd_ctx = zmalloc(sizeof(struct command_ctx)); if (cmd_ctx == NULL) { - perror("malloc cmd_ctx"); + perror("zmalloc cmd_ctx"); goto error; } /* Allocate data buffer for reception */ - cmd_ctx->lsm = malloc(sizeof(struct lttcomm_session_msg)); + cmd_ctx->lsm = zmalloc(sizeof(struct lttcomm_session_msg)); if (cmd_ctx->lsm == NULL) { - perror("malloc cmd_ctx->lsm"); + perror("zmalloc cmd_ctx->lsm"); goto error; } @@ -3390,7 +3390,7 @@ static void *thread_manage_clients(void *data) if (ret < 0) { /* * TODO: Inform client somehow of the fatal error. At - * this point, ret < 0 means that a malloc failed + * this point, ret < 0 means that a zmalloc failed * (ENOMEM). Error detected but still accept command. */ clean_command_ctx(&cmd_ctx); diff --git a/lttng-sessiond/session.c b/lttng-sessiond/session.c index c7ce843d7..2ab49485f 100644 --- a/lttng-sessiond/session.c +++ b/lttng-sessiond/session.c @@ -175,9 +175,9 @@ int session_create(char *name, char *path) } /* Allocate session data structure */ - new_session = malloc(sizeof(struct ltt_session)); + new_session = zmalloc(sizeof(struct ltt_session)); if (new_session == NULL) { - perror("malloc"); + perror("zmalloc"); ret = LTTCOMM_FATAL; goto error_malloc; } diff --git a/lttng-sessiond/trace-kernel.c b/lttng-sessiond/trace-kernel.c index fa3ba692c..c5b81f1e0 100644 --- a/lttng-sessiond/trace-kernel.c +++ b/lttng-sessiond/trace-kernel.c @@ -88,9 +88,9 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path) struct ltt_kernel_session *lks; /* Allocate a new ltt kernel session */ - lks = malloc(sizeof(struct ltt_kernel_session)); + lks = zmalloc(sizeof(struct ltt_kernel_session)); if (lks == NULL) { - perror("create kernel session malloc"); + perror("create kernel session zmalloc"); goto error; } @@ -126,15 +126,15 @@ struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *cha int ret; struct ltt_kernel_channel *lkc; - lkc = malloc(sizeof(struct ltt_kernel_channel)); + lkc = zmalloc(sizeof(struct ltt_kernel_channel)); if (lkc == NULL) { - perror("ltt_kernel_channel malloc"); + perror("ltt_kernel_channel zmalloc"); goto error; } - lkc->channel = malloc(sizeof(struct lttng_channel)); + lkc->channel = zmalloc(sizeof(struct lttng_channel)); if (lkc->channel == NULL) { - perror("lttng_channel malloc"); + perror("lttng_channel zmalloc"); goto error; } memcpy(lkc->channel, chan, sizeof(struct lttng_channel)); @@ -170,10 +170,10 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev) struct ltt_kernel_event *lke; struct lttng_kernel_event *attr; - lke = malloc(sizeof(struct ltt_kernel_event)); - attr = malloc(sizeof(struct lttng_kernel_event)); + lke = zmalloc(sizeof(struct ltt_kernel_event)); + attr = zmalloc(sizeof(struct lttng_kernel_event)); if (lke == NULL || attr == NULL) { - perror("kernel event malloc"); + perror("kernel event zmalloc"); goto error; } @@ -242,10 +242,10 @@ struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path) struct ltt_kernel_metadata *lkm; struct lttng_channel *chan; - lkm = malloc(sizeof(struct ltt_kernel_metadata)); - chan = malloc(sizeof(struct lttng_channel)); + lkm = zmalloc(sizeof(struct ltt_kernel_metadata)); + chan = zmalloc(sizeof(struct lttng_channel)); if (lkm == NULL || chan == NULL) { - perror("kernel metadata malloc"); + perror("kernel metadata zmalloc"); goto error; } @@ -283,9 +283,9 @@ struct ltt_kernel_stream *trace_kernel_create_stream(void) { struct ltt_kernel_stream *lks; - lks = malloc(sizeof(struct ltt_kernel_stream)); + lks = zmalloc(sizeof(struct ltt_kernel_stream)); if (lks == NULL) { - perror("kernel stream malloc"); + perror("kernel stream zmalloc"); goto error; } diff --git a/lttng-sessiond/trace-ust.c b/lttng-sessiond/trace-ust.c index a0d3b1b41..4df481c12 100644 --- a/lttng-sessiond/trace-ust.c +++ b/lttng-sessiond/trace-ust.c @@ -91,9 +91,9 @@ struct ltt_ust_session *trace_ust_create_session(char *path, unsigned int uid, struct ltt_ust_session *lus; /* Allocate a new ltt ust session */ - lus = malloc(sizeof(struct ltt_ust_session)); + lus = zmalloc(sizeof(struct ltt_ust_session)); if (lus == NULL) { - PERROR("create ust session malloc"); + PERROR("create ust session zmalloc"); goto error; } @@ -139,7 +139,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, luc = zmalloc(sizeof(struct ltt_ust_channel)); if (luc == NULL) { - perror("ltt_ust_channel malloc"); + perror("ltt_ust_channel zmalloc"); goto error; } @@ -196,7 +196,7 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) lue = zmalloc(sizeof(struct ltt_ust_event)); if (lue == NULL) { - PERROR("ust event malloc"); + PERROR("ust event zmalloc"); goto error; } @@ -250,7 +250,7 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path) lum = zmalloc(sizeof(struct ltt_ust_metadata)); if (lum == NULL) { - perror("ust metadata malloc"); + perror("ust metadata zmalloc"); goto error; }