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.richard...@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.