X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.c;h=f6f2c64ae9895958af62592b15cccee9b42527ff;hp=397a2dfab29b5f2106f1a235a4ce1a7bfb7f0a7b;hb=37f1c23617e54ba79c11ff6dc4c4ce7ad07f7be9;hpb=030a66fa43d2f6666afa9e4a90ca755eb5670555 diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 397a2dfab..f6f2c64ae 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -378,6 +378,28 @@ error: return NULL; } +/* + * Allocate and initialize a UST app stream. + * + * Return newly allocated stream pointer or NULL on error. + */ +static struct ust_app_stream *alloc_ust_app_stream(void) +{ + struct ust_app_stream *stream = NULL; + + stream = zmalloc(sizeof(*stream)); + if (stream == NULL) { + PERROR("zmalloc ust app stream"); + goto error; + } + + /* Zero could be a valid value for a handle so flag it to -1. */ + stream->handle = -1; + +error: + return stream; +} + /* * Alloc new UST app event. */ @@ -2362,9 +2384,8 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) /* Create all streams */ while (1) { /* Create UST stream */ - ustream = zmalloc(sizeof(*ustream)); + ustream = alloc_ust_app_stream(); if (ustream == NULL) { - PERROR("zmalloc ust stream"); goto error_rcu_unlock; }