From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Gabriele Monaco <gmonaco@redhat.com>
Cc: Nam Cao <namcao@linutronix.de>,
Thomas Weissschuh <thomas.weissschuh@linutronix.de>,
Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
Wen Yang <wen.yang@linux.dev>
Subject: [PATCH v5 02/17] tools/rv: Fix exit status when monitor execution fails
Date: Thu, 23 Jul 2026 09:45:19 +0200 [thread overview]
Message-ID: <20260723074534.43521-3-gmonaco@redhat.com> (raw)
In-Reply-To: <20260723074534.43521-1-gmonaco@redhat.com>
When running "rv mon" on a monitor that is already enabled, the tool
fails to start but incorrectly exits with a success status (0).
Fix the exit condition to ensure it returns a failure code on any
execution error. Also use the standard EXIT_SUCCESS/EXIT_FAILURE macros
throughout the file.
Reviewed-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
tools/verification/rv/src/rv.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/verification/rv/src/rv.c b/tools/verification/rv/src/rv.c
index b8fe24a87d97..09e0d8598619 100644
--- a/tools/verification/rv/src/rv.c
+++ b/tools/verification/rv/src/rv.c
@@ -50,23 +50,23 @@ static void rv_list(int argc, char **argv)
" [container]: list only monitors in this container",
NULL,
};
- int i, print_help = 0, retval = 0;
+ int i, print_help = 0, retval = EXIT_SUCCESS;
char *container = NULL;
if (argc == 2) {
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
print_help = 1;
- retval = 0;
+ retval = EXIT_SUCCESS;
} else if (argv[1][0] == '-') {
/* assume invalid option */
print_help = 1;
- retval = 1;
+ retval = EXIT_FAILURE;
} else
container = argv[1];
} else if (argc > 2) {
/* more than 2 is always usage */
print_help = 1;
- retval = 1;
+ retval = EXIT_FAILURE;
}
if (print_help) {
fprintf(stderr, "rv version %s\n", VERSION);
@@ -77,7 +77,7 @@ static void rv_list(int argc, char **argv)
ikm_list_monitors(container);
- exit(0);
+ exit(EXIT_SUCCESS);
}
/*
@@ -108,14 +108,14 @@ static void rv_mon(int argc, char **argv)
for (i = 0; usage[i]; i++)
fprintf(stderr, "%s\n", usage[i]);
- exit(1);
+ exit(EXIT_FAILURE);
} else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
fprintf(stderr, "rv version %s\n", VERSION);
for (i = 0; usage[i]; i++)
fprintf(stderr, "%s\n", usage[i]);
- exit(0);
+ exit(EXIT_SUCCESS);
}
monitor_name = argv[1];
@@ -127,7 +127,7 @@ static void rv_mon(int argc, char **argv)
if (!run)
err_msg("rv: monitor %s does not exist\n", monitor_name);
- exit(!run);
+ exit(run > 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
static void usage(int exit_val, const char *fmt, ...)
@@ -174,13 +174,13 @@ static void usage(int exit_val, const char *fmt, ...)
int main(int argc, char **argv)
{
if (geteuid())
- usage(1, "%s needs root permission", argv[0]);
+ usage(EXIT_FAILURE, "%s needs root permission", argv[0]);
if (argc <= 1)
- usage(1, "%s requires a command", argv[0]);
+ usage(EXIT_FAILURE, "%s requires a command", argv[0]);
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
- usage(0, "help");
+ usage(EXIT_SUCCESS, "help");
if (!strcmp(argv[1], "list"))
rv_list(--argc, &argv[1]);
@@ -197,5 +197,5 @@ int main(int argc, char **argv)
}
/* invalid sub-command */
- usage(1, "%s does not know the %s command, old version?", argv[0], argv[1]);
+ usage(EXIT_FAILURE, "%s does not know the %s command, old version?", argv[0], argv[1]);
}
--
2.55.0
next prev parent reply other threads:[~2026-07-23 7:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 7:45 [PATCH v5 00/17] rv: Add selftests to tools and KUnit tests Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 01/17] rv: Use generic rv_this for the rv_monitor variable in LTL Gabriele Monaco
2026-07-23 7:45 ` Gabriele Monaco [this message]
2026-07-23 7:45 ` [PATCH v5 03/17] verification/rvgen: Improve rv_dir discovery in RVGenerator Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 04/17] verification/rvgen: Use pathlib instead of os.path Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 05/17] verification/rvgen: Improve consistency in template files Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 06/17] tools/rv: Add selftests Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 07/17] verification/rvgen: Add golden and spec folders for tests Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 08/17] verification/rvgen: Add selftests Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 09/17] verification/rvgen: Add the rvgen kunit subcommand Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 10/17] verification/rvgen: Add selftests for rvgen kunit Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 11/17] rv: Export task monitor slot and react symbols Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 12/17] rv: Add KUnit tests for some DA/HA monitors Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 13/17] rv: Add KUnit mock for current Gabriele Monaco
2026-07-29 18:17 ` Wen Yang
2026-07-30 5:13 ` Gabriele Monaco
2026-07-31 10:59 ` Nam Cao
2026-07-23 7:45 ` [PATCH v5 14/17] rv: Add KUnit tests for some LTL monitors Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 15/17] selftests/verification: Fix wrong errexit assumption Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 16/17] selftests/verification: Rearrange the wwnr_printk test Gabriele Monaco
2026-07-23 7:45 ` [PATCH v5 17/17] selftests/verification: Add selftests for deadline and stall monitors Gabriele Monaco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260723074534.43521-3-gmonaco@redhat.com \
--to=gmonaco@redhat.com \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.com \
--cc=thomas.weissschuh@linutronix.de \
--cc=wen.yang@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.