X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fhelp.cpp;h=5f6d86685b0892bdaf059140fe5bb27bbf7f50a0;hb=28ab034a2c3582d07d3423d2d746731f87d3969f;hp=74b64964443aa184eb8ac7762491f4cac2e37037;hpb=c9e313bc594f40a86eed237dce222c0fc99c957f;p=lttng-tools.git diff --git a/src/bin/lttng/commands/help.cpp b/src/bin/lttng/commands/help.cpp index 74b649644..5f6d86685 100644 --- a/src/bin/lttng/commands/help.cpp +++ b/src/bin/lttng/commands/help.cpp @@ -6,27 +6,28 @@ */ #define _LGPL_SOURCE +#include "../command.hpp" + +#include + #include #include #include #include -#include "../command.hpp" -#include - #ifdef LTTNG_EMBED_HELP static const char *help_msg = #include -; + ; #endif static const char *lttng_help_msg = #ifdef LTTNG_EMBED_HELP #include #else -NULL + NULL #endif -; + ; enum { OPT_HELP = 1, @@ -35,9 +36,9 @@ enum { static struct poptOption long_options[] = { /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ - {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, - {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, - {0, 0, 0, 0, 0, 0, 0} + { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 }, + { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL }, + { 0, 0, 0, 0, 0, 0, 0 } }; /* @@ -46,7 +47,7 @@ static struct poptOption long_options[] = { int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) { int opt, ret = CMD_SUCCESS; - char *cmd_name; + const char *arg_cmd_name; static poptContext pc; const struct cmd_struct *cmd; int found = 0; @@ -70,9 +71,8 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) } /* Get command name */ - cmd_name = (char *) poptGetArg(pc); - - if (cmd_name == NULL) { + arg_cmd_name = poptGetArg(pc); + if (arg_cmd_name == NULL) { /* Fall back to lttng(1) */ ret = utils_show_help(1, "lttng", lttng_help_msg); if (ret) { @@ -85,7 +85,7 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) } /* Help about help? */ - if (strcmp(cmd_name, "help") == 0) { + if (strcmp(arg_cmd_name, "help") == 0) { SHOW_HELP(); goto end; } @@ -94,7 +94,7 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) cmd = &commands[0]; while (cmd->name != NULL) { - if (strcmp(cmd->name, cmd_name) == 0) { + if (strcmp(cmd->name, arg_cmd_name) == 0) { found = 1; break; } @@ -103,7 +103,7 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[]) } if (!found) { - ERR("Unknown command \"%s\"", cmd_name); + ERR("Unknown command \"%s\"", arg_cmd_name); ret = CMD_ERROR; goto end; }