From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH 4/6] cmdline: add explicit help function for bool type
Date: Thu, 7 May 2026 15:59:47 +0100 [thread overview]
Message-ID: <20260507145950.197753-5-bruce.richardson@intel.com> (raw)
In-Reply-To: <20260507145950.197753-1-bruce.richardson@intel.com>
Rather than using the string help output, have a specific boolean help
output that prints out on|off as the options.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/cmdline/cmdline_parse_bool.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/lib/cmdline/cmdline_parse_bool.c b/lib/cmdline/cmdline_parse_bool.c
index a3f7adab58..d5d5499531 100644
--- a/lib/cmdline/cmdline_parse_bool.c
+++ b/lib/cmdline/cmdline_parse_bool.c
@@ -13,13 +13,17 @@
#include "cmdline_parse.h"
#include "cmdline_parse_bool.h"
+static int
+cmdline_get_help_bool(cmdline_parse_token_hdr_t *tk, char *dstbuf,
+ unsigned int size);
+
RTE_EXPORT_EXPERIMENTAL_SYMBOL(cmdline_token_bool_ops, 25.03)
struct cmdline_token_ops cmdline_token_bool_ops = {
.parse = cmdline_parse_bool,
.complete_get_nb = NULL,
.complete_get_elt = NULL,
- .get_help = cmdline_get_help_string,
+ .get_help = cmdline_get_help_bool,
};
static cmdline_parse_token_string_t cmd_parse_token_bool = {
@@ -32,6 +36,18 @@ static cmdline_parse_token_string_t cmd_parse_token_bool = {
}
};
+/* get help for bool token */
+static int
+cmdline_get_help_bool(__rte_unused cmdline_parse_token_hdr_t *tk,
+ char *dstbuf, unsigned int size)
+{
+ if (dstbuf == NULL || size == 0)
+ return -1;
+
+ strlcpy(dstbuf, "on|off", size);
+ return 0;
+}
+
/* parse string to bool */
int
cmdline_parse_bool(__rte_unused cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res,
--
2.51.0
next prev parent reply other threads:[~2026-05-07 15:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 14:59 [PATCH 0/6] add hardening checks to cmdline and cfgfile libs Bruce Richardson
2026-05-07 14:59 ` [PATCH 1/6] cfgfile: add null checks to public APIs Bruce Richardson
2026-05-07 14:59 ` [PATCH 2/6] cfgfile: prevent issues with overflow on resize Bruce Richardson
2026-05-07 14:59 ` [PATCH 3/6] cmdline: harden parser result buffer handling Bruce Richardson
2026-05-07 14:59 ` Bruce Richardson [this message]
2026-05-07 14:59 ` [PATCH 5/6] cmdline: guard zero-size destination buffers Bruce Richardson
2026-05-07 14:59 ` [PATCH 6/6] cmdline: add null checks for invalid input Bruce Richardson
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=20260507145950.197753-5-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox