Clean-up: replace uses of `int found` as bool by `bool found`
[lttng-tools.git] / src / bin / lttng / commands / help.cpp
index a9a01e7f14a65db8084e5b8cdbdaa6c0ad038c8d..57b73a6b0a94198d90fdda62c68afb58ba4c8780 100644 (file)
@@ -6,27 +6,28 @@
  */
 
 #define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/utils.hpp>
+
 #include <popt.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "../command.h"
-#include <common/utils.h>
-
 #ifdef LTTNG_EMBED_HELP
 static const char *help_msg =
 #include <lttng-help.1.h>
-;
+       ;
 #endif
 
 static const char *lttng_help_msg =
 #ifdef LTTNG_EMBED_HELP
 #include <lttng.1.h>
 #else
-NULL
+       nullptr
 #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, nullptr, OPT_HELP, nullptr, nullptr },
+       { "list-options", 0, POPT_ARG_NONE, nullptr, OPT_LIST_OPTIONS, nullptr, nullptr },
+       { nullptr, 0, 0, nullptr, 0, nullptr, nullptr }
 };
 
 /*
@@ -46,13 +47,13 @@ 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;
+       bool found = false;
        const char *cmd_argv[2];
 
-       pc = poptGetContext(NULL, argc, argv, long_options, 0);
+       pc = poptGetContext(nullptr, argc, argv, long_options, 0);
        poptReadDefaultConfig(pc, 0);
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
@@ -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 == nullptr) {
                /* 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;
        }
@@ -93,9 +93,9 @@ int cmd_help(int argc, const char **argv, const struct cmd_struct commands[])
        /* Make sure command name exists */
        cmd = &commands[0];
 
-       while (cmd->name != NULL) {
-               if (strcmp(cmd->name, cmd_name) == 0) {
-                       found = 1;
+       while (cmd->name != nullptr) {
+               if (strcmp(cmd->name, arg_cmd_name) == 0) {
+                       found = true;
                        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;
        }
This page took 0.024404 seconds and 4 git commands to generate.