From bc1f87ff76fb31839ce8e4fd224d451bd368c21b Mon Sep 17 00:00:00 2001 From: Olivier Dion Date: Wed, 22 Feb 2023 16:45:27 -0500 Subject: [PATCH] Fix: lttng remove-trigger -h fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/remove_trigger.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/lttng/commands/remove_trigger.c b/src/bin/lttng/commands/remove_trigger.c index 48b91bf48..439ae4a3a 100644 --- a/src/bin/lttng/commands/remove_trigger.c +++ b/src/bin/lttng/commands/remove_trigger.c @@ -73,6 +73,7 @@ int cmd_remove_trigger(int argc, const char **argv) char *owner_uid = NULL; long long uid; struct mi_writer *mi_writer = NULL; + const char **args; if (lttng_opt_mi) { mi_writer = mi_lttng_writer_create( @@ -99,10 +100,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; @@ -111,8 +111,8 @@ int cmd_remove_trigger(int argc, const char **argv) while (true) { enum parse_next_item_status status; - status = parse_next_item(argpar_iter, &argpar_item, 1, argv, - true, NULL, NULL); + status = parse_next_item(argpar_iter, &argpar_item, 1, args, + true, NULL, NULL); if (status == PARSE_NEXT_ITEM_STATUS_ERROR || status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) { goto error; -- 2.34.1