Fix: lttng remove-trigger -h fails
authorOlivier Dion <odion@efficios.com>
Wed, 22 Feb 2023 21:45:27 +0000 (16:45 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 28 Feb 2023 15:57:05 +0000 (10:57 -0500)
The error was that `argv' was incremented before passing it to
`argpar_iter_create'. However, the macro `SHOW_HELP' implicitly
deferences `argv[0]' to determine the command name.

Fix this by introducing a new variable `args' leaving `argv' untouched.

Change-Id: Id50fa2424550280a1e5e207429d643f5e8e00396
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/remove_trigger.cpp

index 0a10e16127c2994588feb235ba66bccbb1e4289a..08d4873f08a4cb9b9b66611eaeb51331c773ea76 100644 (file)
@@ -73,6 +73,7 @@ int cmd_remove_trigger(int argc, const char **argv)
        char *owner_uid = nullptr;
        long long uid;
        struct mi_writer *mi_writer = nullptr;
+       const char **args;
 
        if (lttng_opt_mi) {
                mi_writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
@@ -97,10 +98,9 @@ int cmd_remove_trigger(int argc, const char **argv)
                }
        }
 
-       argc--;
-       argv++;
+       args = argv + 1;
 
-       argpar_iter = argpar_iter_create(argc, argv, remove_trigger_options);
+       argpar_iter = argpar_iter_create(argc - 1, args, remove_trigger_options);
        if (!argpar_iter) {
                ERR("Failed to allocate an argpar iter.");
                goto error;
@@ -110,7 +110,7 @@ int cmd_remove_trigger(int argc, const char **argv)
                enum parse_next_item_status status;
 
                status =
-                       parse_next_item(argpar_iter, &argpar_item, 1, argv, true, nullptr, nullptr);
+                       parse_next_item(argpar_iter, &argpar_item, 1, args, true, nullptr, nullptr);
                if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
                    status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
                        goto error;
This page took 0.033654 seconds and 4 git commands to generate.