X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ustd%2Fustd.c;h=e75fd9d75501a6d4d914dd19889eb8cb041e502a;hb=28c1bb4003ca120888a1d61d5ec71eac426ae490;hp=cca9520589015f255992f8fcb7da1e2b68ed605a;hpb=d159ac37826eaebf4c1d87b8db0c5e5a8ccc0b00;p=ust.git diff --git a/ustd/ustd.c b/ustd/ustd.c index cca9520..e75fd9d 100644 --- a/ustd/ustd.c +++ b/ustd/ustd.c @@ -32,7 +32,7 @@ #include #include -#include "libustd.h" +#include "ust/ustd.h" #include "usterr.h" char *sock_path=NULL; @@ -150,8 +150,7 @@ int on_read_partial_subbuffer(struct libustd_callbacks *data, struct buffer_info /* pad with empty bytes */ pad_size = PAGE_ALIGN(valid_length)-valid_length; if(pad_size) { - tmp = malloc(pad_size); - memset(tmp, 0, pad_size); + tmp = zmalloc(pad_size); result = patient_write(buf_local->file_fd, tmp, pad_size); if(result == -1) { ERR("Error writing to buffer file"); @@ -168,7 +167,7 @@ int on_open_buffer(struct libustd_callbacks *data, struct buffer_info *buf) int result; int fd; struct buffer_info_local *buf_local = - malloc(sizeof(struct buffer_info_local)); + zmalloc(sizeof(struct buffer_info_local)); if(!buf_local) { ERR("could not allocate buffer_info_local struct"); @@ -192,7 +191,11 @@ int on_open_buffer(struct libustd_callbacks *data, struct buffer_info *buf) trace_path = USTD_DEFAULT_TRACE_PATH; } - asprintf(&tmp, "%s/%u_%lld", trace_path, buf->pid, buf->pidunique); + if (asprintf(&tmp, "%s/%u_%lld", trace_path, buf->pid, buf->pidunique) < 0) { + ERR("on_open_buffer : asprintf failed (%s/%u_%lld)", + trace_path, buf->pid, buf->pidunique); + return 1; + } result = create_dir_if_needed(tmp); if(result == -1) { ERR("could not create directory %s", tmp); @@ -201,7 +204,11 @@ int on_open_buffer(struct libustd_callbacks *data, struct buffer_info *buf) } free(tmp); - asprintf(&tmp, "%s/%u_%lld/%s", trace_path, buf->pid, buf->pidunique, buf->name); + if (asprintf(&tmp, "%s/%u_%lld/%s", trace_path, buf->pid, buf->pidunique, buf->name) < 0) { + ERR("on_open_buffer : asprintf failed (%s/%u_%lld/%s)", + trace_path, buf->pid, buf->pidunique, buf->name); + return 1; + } result = fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 00600); if(result == -1) { PERROR("open"); @@ -233,7 +240,7 @@ int on_put_error(struct libustd_callbacks *data, struct buffer_info *buf) struct libustd_callbacks *new_callbacks() { struct libustd_callbacks *callbacks = - malloc(sizeof(struct libustd_callbacks)); + zmalloc(sizeof(struct libustd_callbacks)); if(!callbacks) return NULL; @@ -343,11 +350,9 @@ void sigterm_handler(int sig) int start_ustd(int fd) { - struct ustcomm_ustd ustd; int result; sigset_t sigset; struct sigaction sa; - int timeout = -1; struct libustd_callbacks *callbacks = new_callbacks(); if(!callbacks) {