Fix: add default name in snapshot add-output msg
authorDavid Goulet <dgoulet@efficios.com>
Mon, 4 Nov 2013 18:43:32 +0000 (13:43 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 4 Nov 2013 19:38:33 +0000 (14:38 -0500)
Fixes #634

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng/commands/snapshot.c

index a357730d008444d1d1b1db4ffc36dc40637bd19e..e973456b9c7786ff6abde3e9db7252759290f50d 100644 (file)
@@ -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:
This page took 0.026219 seconds and 4 git commands to generate.