X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fregenerate.c;h=0e904f8abcba1cdc6c92f6e4b5be3030ba84dac9;hb=81663f073dbfb4b61c06a0ceb8ca33c4fc41b1c5;hp=5c982c8a68752ef440c462f4f1fd5eb97790ff01;hpb=c25613651ac7525a16b9877230a682fc1a64e036;p=lttng-tools.git diff --git a/src/bin/lttng/commands/regenerate.c b/src/bin/lttng/commands/regenerate.c index 5c982c8a6..0e904f8ab 100644 --- a/src/bin/lttng/commands/regenerate.c +++ b/src/bin/lttng/commands/regenerate.c @@ -1,22 +1,11 @@ /* - * Copyright (C) 2015 - Julien Desfossez + * Copyright (C) 2015 Julien Desfossez * - * 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 -#include #include #include #include @@ -34,6 +23,12 @@ static char *session_name = NULL; static int regenerate_metadata(int argc, const char **argv); static int regenerate_statedump(int argc, const char **argv); +#ifdef LTTNG_EMBED_HELP +static const char help_msg[] = +#include +; +#endif + enum { OPT_HELP = 1, OPT_LIST_OPTIONS, @@ -64,7 +59,7 @@ static int count_arguments(const char **argv) { int i = 0; - assert(argv); + LTTNG_ASSERT(argv); while (argv[i] != NULL) { i++; @@ -78,12 +73,14 @@ static int regenerate_metadata(int argc, const char **argv) int ret; if (argc > 1) { - ret = -LTTNG_ERR_INVALID; + 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: @@ -113,12 +110,13 @@ static int handle_command(const char **argv) int ret = CMD_SUCCESS, i = 0, argc, command_ret = CMD_SUCCESS; if (argv == NULL) { - ERR("argv is null"); + ERR("No object specified for regenerate command."); command_ret = CMD_ERROR; goto end; } argc = count_arguments(argv); + LTTNG_ASSERT(argc >= 1); cmd = &actions[i]; while (cmd->func != NULL) { @@ -234,12 +232,7 @@ int cmd_regenerate(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) {