Fix: lttng: enable-rotation: leak of command parameter
[lttng-tools.git] / src / bin / lttng / commands / enable_rotation.c
index 85dae5681f251b398752cd204928116d32560983..f540d285234d9d314a546694fcd7f4d9d8cd91d2 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #define _LGPL_SOURCE
@@ -31,7 +21,7 @@
 #include <common/utils.h>
 
 #include "../command.h"
-#include <lttng/rotation.h>
+#include <lttng/lttng.h>
 
 static char *opt_session_name;
 static struct mi_writer *writer;
@@ -118,8 +108,8 @@ static enum cmd_error_code add_schedule(const char *session_name,
                ret = CMD_SUCCESS;
                switch (schedule_type) {
                case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
-                       MSG("Enabled %s rotations every %" PRIu64 " ยตs on session %s",
-                                       schedule_type_name, value, session_name);
+                       MSG("Enabled %s rotations every %" PRIu64 " %s on session %s",
+                                       schedule_type_name, value, USEC_UNIT, session_name);
                        break;
                case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
                        MSG("Enabled %s rotations every %" PRIu64 " bytes written on session %s",
@@ -189,6 +179,10 @@ int cmd_enable_rotation(int argc, const char **argv)
        }
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
+               if (opt_arg) {
+                       free(opt_arg);
+                       opt_arg = NULL;
+               }
                switch (opt) {
                case OPT_HELP:
                        SHOW_HELP();
@@ -343,6 +337,7 @@ end:
        if (free_session_name) {
                free(session_name);
        }
+       free(opt_arg);
        return cmd_ret;
 
 error:
This page took 0.024041 seconds and 4 git commands to generate.