X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-kernel.c;h=7748b891faef7b35add6d9c6e8e2da2e52f24f96;hp=c0239d4bb8230aacd8901b3881c41c1498577cc3;hb=a4b92340642035d1eafeb1eead0ad01f64d2007d;hpb=eb4a2943f0cf59f2f33627c4fa6ed79300119328 diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index c0239d4bb..7748b891f 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -86,13 +86,13 @@ error: struct ltt_kernel_session *trace_kernel_create_session(char *path) { int ret; - struct ltt_kernel_session *lks; + struct ltt_kernel_session *lks = NULL; /* Allocate a new ltt kernel session */ lks = zmalloc(sizeof(struct ltt_kernel_session)); if (lks == NULL) { PERROR("create kernel session zmalloc"); - goto error; + goto alloc_error; } /* Init data structure */ @@ -103,7 +103,6 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path) lks->metadata = NULL; CDS_INIT_LIST_HEAD(&lks->channel_list.head); - /* Create default consumer output object */ lks->consumer = consumer_create_output(CONSUMER_DST_LOCAL); if (lks->consumer == NULL) { goto error; @@ -117,23 +116,29 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path) */ lks->tmp_consumer = NULL; - /* Use the default consumer output which is the tracing session path. */ - ret = snprintf(lks->consumer->dst.trace_path, PATH_MAX, "%s/kernel", path); - if (ret < 0) { - PERROR("snprintf consumer trace path"); - goto error; - } + if (path && strlen(path) > 0) { + /* 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); + if (ret < 0) { + PERROR("snprintf consumer trace path"); + goto error; + } - /* Set session path */ - ret = asprintf(&lks->trace_path, "%s/kernel", path); - if (ret < 0) { - PERROR("asprintf kernel traces path"); - goto error; + /* Set session path */ + ret = asprintf(&lks->trace_path, "%s" DEFAULT_KERNEL_TRACE_DIR, path); + if (ret < 0) { + PERROR("asprintf kernel traces path"); + goto error; + } } return lks; error: + free(lks); + +alloc_error: return NULL; } @@ -253,7 +258,7 @@ error: * * Return pointer to structure or NULL. */ -struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path) +struct ltt_kernel_metadata *trace_kernel_create_metadata(void) { struct ltt_kernel_metadata *lkm; struct lttng_channel *chan;