From: Bruce Richardson <bruce.richardson@intel.com>
To: fengchengwen <fengchengwen@huawei.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH 2/3] argparse: make argparse EAL-args compatible
Date: Tue, 3 Jun 2025 16:33:29 +0100 [thread overview]
Message-ID: <aD8VyfsBPl3rd9-K@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <b58d1963-c4ca-4049-95d6-11293dc85e67@huawei.com>
On Tue, Jun 03, 2025 at 04:44:42PM +0800, fengchengwen wrote:
> On 2025/5/27 17:21, Bruce Richardson wrote:
> > The argparse library was missing two key features which made it
> > unsuitable for use by EAL or any program wanting similar behaviour.
> >
> > 1. It didn't stop parsing arguments when it hit a "--" character
> > 2. It never returned the number of arguments parsed
> >
> > Fix both these issues - the latter is a change to the ABI, since we now
> > return >= 0 rather than == 0 on success. However, the ABI is still
> > experimental so we can make exactly these sorts of tweaks to it.
> >
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> > app/test/test_argparse.c | 46 +++++++++++++-------------
> > doc/guides/rel_notes/release_25_07.rst | 9 +++++
> > lib/argparse/rte_argparse.c | 12 +++++--
> > lib/argparse/rte_argparse.h | 3 +-
> > 4 files changed, 43 insertions(+), 27 deletions(-)
> >
> > diff --git a/app/test/test_argparse.c b/app/test/test_argparse.c
> > index 6b0d1524b5..a907fbe53f 100644
> > --- a/app/test/test_argparse.c
> > +++ b/app/test/test_argparse.c
> > @@ -360,14 +360,14 @@ test_argparse_opt_autosave_parse_int_of_no_val(void)
> > argv[0] = test_strdup(obj->prog_name);
> > argv[1] = test_strdup("--test-long");
> > ret = rte_argparse_parse(obj, 2, argv);
> > - TEST_ASSERT(ret == 0, "Argparse parse expect success!");
> > + TEST_ASSERT(ret >= 0, "Argparse parse expect success!");
>
> Please compared with specific number, eg. TEST_ASSERT(ret == 2, "xxx");
>
> ...
>
> >
> > @@ -780,7 +780,7 @@ test_argparse_parse_type(void)
> > ret = rte_argparse_parse_type(str_invalid, RTE_ARGPARSE_ARG_VALUE_INT, &val_int);
> > TEST_ASSERT(ret != 0, "Argparse parse type expect failed!");
> > ret = rte_argparse_parse_type(str_ok, RTE_ARGPARSE_ARG_VALUE_INT, &val_int);
> > - TEST_ASSERT(ret == 0, "Argparse parse type expect failed!");
> > + TEST_ASSERT(ret >= 0, "Argparse parse type expect failed!");
>
> No need for rte_argparse_parse_type() API, this API still return 0 if success.
>
> ...
>
> > diff --git a/lib/argparse/rte_argparse.h b/lib/argparse/rte_argparse.h
> > index 332184302e..8cdb3195cb 100644
> > --- a/lib/argparse/rte_argparse.h
> > +++ b/lib/argparse/rte_argparse.h
> > @@ -183,7 +183,8 @@ struct rte_argparse {
> > * Array of parameters points.
> > *
> > * @return
> > - * 0 on success. Otherwise negative value is returned.
> > + * number of arguments parsed (>= 0) on success.
> > + * Otherwise negative error code is returned.
>
> Please add note for "stops processing arguments when a ``--`` argument is encountered".
>
Thanks for the review. All 3 comments fixed in v2 patchset.
next prev parent reply other threads:[~2025-06-03 15:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 9:21 [PATCH 0/3] argparse additions and rework Bruce Richardson
2025-05-27 9:21 ` [PATCH 1/3] argparse: add support for string and boolean args Bruce Richardson
2025-06-03 8:36 ` fengchengwen
2025-05-27 9:21 ` [PATCH 2/3] argparse: make argparse EAL-args compatible Bruce Richardson
2025-06-03 8:44 ` fengchengwen
2025-06-03 15:33 ` Bruce Richardson [this message]
2025-05-27 9:21 ` [PATCH 3/3] argparse: use enums to remove max-value defines in lists Bruce Richardson
2025-06-04 1:22 ` fengchengwen
2025-05-29 15:09 ` [PATCH 0/3] argparse additions and rework Bruce Richardson
2025-06-03 15:32 ` [PATCH v2 " Bruce Richardson
2025-06-03 15:32 ` [PATCH v2 1/3] argparse: add support for string and boolean args Bruce Richardson
2025-06-03 15:32 ` [PATCH v2 2/3] argparse: make argparse EAL-args compatible Bruce Richardson
2025-06-03 15:32 ` [PATCH v2 3/3] argparse: use enums to remove max-value defines in lists Bruce Richardson
2025-06-04 1:37 ` [PATCH v2 0/3] argparse additions and rework fengchengwen
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=aD8VyfsBPl3rd9-K@bricha3-mobl1.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).