Move to kernel style SPDX license identifiers
[lttng-tools.git] / src / bin / lttng / commands / metadata.c
index a5776ac141ad96b859e7b950c23b71e0ed195d8b..f36be65fd3b66a76a31d1a3cc74486d30f8159ba 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2015 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2015 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
@@ -33,6 +23,12 @@ static char *session_name = NULL;
 
 static int metadata_regenerate(int argc, const char **argv);
 
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-metadata.1.h>
+;
+#endif
+
 enum {
        OPT_HELP = 1,
        OPT_LIST_OPTIONS,
@@ -75,10 +71,18 @@ static int metadata_regenerate(int argc, const char **argv)
 {
        int ret;
 
-       ret = lttng_metadata_regenerate(session_name);
+       if (argc > 1) {
+               ret = CMD_UNDEFINED;
+               goto end;
+       }
+       ret = lttng_regenerate_metadata(session_name);
        if (ret == 0) {
                MSG("Metadata successfully regenerated for session %s", session_name);
+       } else {
+               ERR("%s", lttng_strerror(ret));
        }
+
+end:
        return ret;
 }
 
@@ -88,12 +92,13 @@ static int handle_command(const char **argv)
        int ret = CMD_SUCCESS, i = 0, argc, command_ret = CMD_SUCCESS;
 
        if (argv == NULL) {
-               SHOW_HELP();
-               command_ret = CMD_ERROR;
+               ERR("No action specified for metadata command.");
+               ret = CMD_ERROR;
                goto end;
        }
 
        argc = count_arguments(argv);
+       assert(argc >= 1);
 
        cmd = &actions[i];
        while (cmd->func != NULL) {
@@ -209,12 +214,7 @@ int cmd_metadata(int argc, const char **argv)
 
        command_ret = handle_command(poptGetArgs(pc));
        if (command_ret) {
-               switch (-command_ret) {
-               default:
-                       ERR("%s", lttng_strerror(command_ret));
-                       success = 0;
-                       break;
-               }
+               success = 0;
        }
 
        if (lttng_opt_mi) {
This page took 0.027974 seconds and 5 git commands to generate.