From 6efe784e2cb20c6698205d5f408bfc173e1cdc57 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 4 Nov 2013 13:43:32 -0500 Subject: [PATCH] Fix: add default name in snapshot add-output msg Fixes #634 Signed-off-by: David Goulet --- src/bin/lttng/commands/snapshot.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng/commands/snapshot.c b/src/bin/lttng/commands/snapshot.c index a357730d0..e973456b9 100644 --- a/src/bin/lttng/commands/snapshot.c +++ b/src/bin/lttng/commands/snapshot.c @@ -264,6 +264,8 @@ static int add_output(const char *url) { int ret; struct lttng_snapshot_output *output = NULL; + char name[NAME_MAX]; + const char *n_ptr; if (!url && (!opt_data_url || !opt_ctrl_url)) { ret = CMD_ERROR; @@ -282,11 +284,21 @@ static int add_output(const char *url) goto error; } + n_ptr = lttng_snapshot_output_get_name(output); + if (*n_ptr == '\0') { + int pret; + pret = snprintf(name, sizeof(name), DEFAULT_SNAPSHOT_NAME "-%" PRIu32, + lttng_snapshot_output_get_id(output)); + if (pret < 0) { + PERROR("snprintf add output name"); + } + n_ptr = name; + } + MSG("Snapshot output successfully added for session %s", current_session_name); MSG(" [%" PRIu32 "] %s: %s (max-size: %" PRId64 ")", - lttng_snapshot_output_get_id(output), - lttng_snapshot_output_get_name(output), + lttng_snapshot_output_get_id(output), n_ptr, lttng_snapshot_output_get_ctrl_url(output), lttng_snapshot_output_get_maxsize(output)); error: -- 2.34.1