From: David Goulet Date: Mon, 4 Nov 2013 18:43:32 +0000 (-0500) Subject: Fix: add default name in snapshot add-output msg X-Git-Tag: v2.4.0-rc1~84 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=6efe784e2cb20c6698205d5f408bfc173e1cdc57 Fix: add default name in snapshot add-output msg Fixes #634 Signed-off-by: David Goulet --- 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: