X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fstop.cpp;h=a6d3d6711acc9ad083a1ccaa10348cddf0797a1b;hb=ff01a57416330247403e58bf4e28d4771a46ce35;hp=ed235bc2989c2c72feb46b31417cacf4e4a4fc4f;hpb=5b915816f16e7cb3134dd7279abad79b31c2486c;p=lttng-tools.git diff --git a/src/bin/lttng/commands/stop.cpp b/src/bin/lttng/commands/stop.cpp index ed235bc29..a6d3d6711 100644 --- a/src/bin/lttng/commands/stop.cpp +++ b/src/bin/lttng/commands/stop.cpp @@ -6,6 +6,11 @@ */ #define _LGPL_SOURCE +#include "../command.hpp" + +#include +#include + #include #include #include @@ -14,18 +19,13 @@ #include #include -#include -#include - -#include "../command.hpp" - static int opt_no_wait; static struct mi_writer *writer; #ifdef LTTNG_EMBED_HELP static const char help_msg[] = #include -; + ; #endif enum { @@ -35,10 +35,10 @@ 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}, - {"no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0}, - {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 }, + { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, nullptr, nullptr }, + { nullptr, 0, 0, nullptr, 0, nullptr, nullptr } }; /* @@ -57,15 +57,13 @@ static int mi_print_session(char *session_name, int enabled) } /* Print session name element */ - ret = mi_lttng_writer_write_element_string(writer, config_element_name, - session_name); + ret = mi_lttng_writer_write_element_string(writer, config_element_name, session_name); if (ret) { goto end; } /* Is enabled ? */ - ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, - enabled); + ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, enabled); if (ret) { goto end; } @@ -85,16 +83,16 @@ static int stop_tracing(const char *arg_session_name) int ret; char *session_name; - if (arg_session_name == NULL) { + if (arg_session_name == nullptr) { session_name = get_session_name(); } else { session_name = strdup(arg_session_name); - if (session_name == NULL) { + if (session_name == nullptr) { PERROR("Failed to copy session name"); } } - if (session_name == NULL) { + if (session_name == nullptr) { ret = CMD_ERROR; goto error; } @@ -162,10 +160,10 @@ int cmd_stop(int argc, const char **argv) { int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1; static poptContext pc; - const char *arg_session_name = NULL; - const char *leftover = NULL; + const char *arg_session_name = nullptr; + const char *leftover = nullptr; - pc = poptGetContext(NULL, argc, argv, long_options, 0); + pc = poptGetContext(nullptr, argc, argv, long_options, 0); poptReadDefaultConfig(pc, 0); while ((opt = poptGetNextOpt(pc)) != -1) { @@ -191,16 +189,14 @@ int cmd_stop(int argc, const char **argv) } /* Open command element */ - ret = mi_lttng_writer_command_open(writer, - mi_lttng_element_command_stop); + ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_stop); if (ret) { ret = CMD_ERROR; goto end; } /* Open output element */ - ret = mi_lttng_writer_open_element(writer, - mi_lttng_element_command_output); + ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output); if (ret) { ret = CMD_ERROR; goto end; @@ -210,8 +206,7 @@ int cmd_stop(int argc, const char **argv) * Open sessions element * For validation */ - ret = mi_lttng_writer_open_element(writer, - config_element_sessions); + ret = mi_lttng_writer_open_element(writer, config_element_sessions); if (ret) { ret = CMD_ERROR; goto end; @@ -242,8 +237,8 @@ int cmd_stop(int argc, const char **argv) } /* Success ? */ - ret = mi_lttng_writer_write_element_bool(writer, - mi_lttng_element_command_success, success); + ret = mi_lttng_writer_write_element_bool( + writer, mi_lttng_element_command_success, success); if (ret) { ret = CMD_ERROR; goto end;