diff mbox series

[pseudo,21/34] pseudo: Fix the -k severity option

Message ID 1794370862-30908-22-git-send-email-mark.hatle@kernel.crashing.org
State New
Headers show
Series Various fixes | expand

Commit Message

Mark Hatle Nov. 11, 2026, 4:20 a.m. UTC
From: Mark Hatle <mark.hatle@amd.com>

-k was declared to getopt() without an argument, so the severities that
followed it were taken as the command to run, and the flags were set
from a NULL string, turning off pseudo_info() and pseudo_warning().
It was also never stored in PSEUDO_SEVERITY, so programs started by
pseudo didn't inherit it, unlike -x and PSEUDO_DEBUG.

Make -k take an argument, store the result in PSEUDO_SEVERITY after
the options are processed, and list it in the usage message.

AI-Generated: Uses GitHub Copilot
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
---
 pseudo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/pseudo.c b/pseudo.c
index 11112dd..4cd0993 100644
--- a/pseudo.c
+++ b/pseudo.c
@@ -47,7 +47,7 @@  static int pseudo_db_check(int fix);
 void
 usage(int status) {
 	FILE *f = status ? stderr : stdout;
-	fputs("Usage: pseudo [-dflv] [-x flags] [-P prefix] [-rR root] [-t timeout] [command]\n", f);
+	fputs("Usage: pseudo [-dflv] [-x flags] [-k severities] [-P prefix] [-rR root] [-t timeout] [command]\n", f);
 	fputs("       pseudo -h\n", f);
 	fputs("       pseudo [-dflv] [-x flags] [-P prefix] [-BC] -i path\n", f);
 	fputs("       pseudo [-dflv] [-x flags] [-P prefix] [-BC] -m from -M to\n", f);
@@ -134,7 +134,7 @@  main(int argc, char *argv[]) {
 	 * wrong.  The + suppresses this annoying behavior, but may not
 	 * be compatible with sane option libraries.
 	 */
-	while ((o = getopt(argc, argv, "+BCdfhi:klm:M:p:P:r:R:St:vVx:")) != -1) {
+	while ((o = getopt(argc, argv, "+BCdfhi:k:lm:M:p:P:r:R:St:vVx:")) != -1) {
 		switch (o) {
 		case 'B': /* rebuild database */
 			opt_B = 1;
@@ -245,6 +245,7 @@  main(int argc, char *argv[]) {
 		}
 	}
 	pseudo_debug_flags_finalize();
+	pseudo_severity_flags_finalize();
 	/* Options are processed, preserve them... */
 	pseudo_set_value("PSEUDO_OPTS", opts);