From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: David Marchand <david.marchand@redhat.com>
Cc: Chengwen Feng <fengchengwen@huawei.com>,
thomas@monjalon.net, dev@dpdk.org
Subject: Re: [PATCH v2 3/5] argparse: replace flag enum with marco
Date: Thu, 7 Mar 2024 10:37:42 -0800 [thread overview]
Message-ID: <20240307183742.GB22674@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <CAJFAV8wwgam8JTBpYUiygfjNOdCtWu=VbvaSdA6YKmA_eOroKQ@mail.gmail.com>
On Thu, Mar 07, 2024 at 06:58:20PM +0100, David Marchand wrote:
> On Thu, Mar 7, 2024 at 6:43 PM Tyler Retzlaff
> <roretzla@linux.microsoft.com> wrote:
> >
> > On Thu, Mar 07, 2024 at 01:07:40PM +0000, Chengwen Feng wrote:
> > > The enum rte_argparse_flag's value is u64, but an enum in C is
> > > represented as an int. This commit replace these enum values with
> > > macro.
> > >
> > > Fixes: e3e579f5bab5 ("argparse: introduce argparse library")
> > > Fixes: 5357c248c960 ("argparse: parse unsigned integers")
> > >
> > > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> > > ---
> > > lib/argparse/rte_argparse.h | 78 ++++++++++++++++---------------------
> > > 1 file changed, 33 insertions(+), 45 deletions(-)
> > >
> > > diff --git a/lib/argparse/rte_argparse.h b/lib/argparse/rte_argparse.h
> > > index 47e231bef9..a6a7790cb4 100644
> > > --- a/lib/argparse/rte_argparse.h
> > > +++ b/lib/argparse/rte_argparse.h
> > > @@ -37,52 +37,40 @@
> > > extern "C" {
> > > #endif
> > >
> > > +/**@{@name Flag definition (in bitmask form) for an argument
> > > + *
> > > + * @note Bits[0~1] represent the argument whether has value,
> > > + * bits[2~9] represent the value type which used when autosave.
> > > + *
> > > + * @see struct rte_argparse_arg::flags
> > > + */
> > > +/** The argument has no value. */
> > > +#define RTE_ARGPARSE_ARG_NO_VALUE RTE_SHIFT_VAL64(1, 0)
> > > +/** The argument must have a value. */
> > > +#define RTE_ARGPARSE_ARG_REQUIRED_VALUE RTE_SHIFT_VAL64(2, 0)
> > > +/** The argument has optional value. */
> > > +#define RTE_ARGPARSE_ARG_OPTIONAL_VALUE RTE_SHIFT_VAL64(3, 0)
> > > +/** The argument's value is int type. */
> > > +#define RTE_ARGPARSE_ARG_VALUE_INT RTE_SHIFT_VAL64(1, 2)
> > > +/** The argument's value is uint8 type. */
> > > +#define RTE_ARGPARSE_ARG_VALUE_U8 RTE_SHIFT_VAL64(2, 2)
> > > +/** The argument's value is uint16 type. */
> > > +#define RTE_ARGPARSE_ARG_VALUE_U16 RTE_SHIFT_VAL64(3, 2)
> > > +/** The argument's value is uint32 type. */
> > > +#define RTE_ARGPARSE_ARG_VALUE_U32 RTE_SHIFT_VAL64(4, 2)
> > > +/** The argument's value is uint64 type. */
> > > +#define RTE_ARGPARSE_ARG_VALUE_U64 RTE_SHIFT_VAL64(5, 2)
> > > +/** Max value type. */
> > > +#define RTE_ARGPARSE_ARG_VALUE_MAX RTE_SHIFT_VAL64(6, 2)
> >
> > it was good to get rid of the enum but will the above macros expand to
> > signed or unsigned integer given the type of field could we make sure
> > they expand unsigned?
>
> Afaiu, those should expand to unsigned:
> #define RTE_SHIFT_VAL64(val, nr) (UINT64_C(val) << (nr))
Thanks for confirming!
>
>
> --
> David Marchand
next prev parent reply other threads:[~2024-03-07 18:37 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 13:14 [PATCH 0/4] refine argparse library Chengwen Feng
2024-02-20 13:14 ` [PATCH 1/4] argparse: refine error message Chengwen Feng
2024-02-20 13:15 ` [PATCH 2/4] argparse: remove dead code Chengwen Feng
2024-02-20 13:15 ` [PATCH 3/4] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-06 17:34 ` David Marchand
2024-03-07 13:14 ` fengchengwen
2024-02-20 13:15 ` [PATCH 4/4] test/argparse: refine testcases Chengwen Feng
2024-03-07 13:07 ` [PATCH v2 0/5] refine argparse library Chengwen Feng
2024-03-07 13:07 ` [PATCH v2 1/5] argparse: refine error message Chengwen Feng
2024-03-07 13:07 ` [PATCH v2 2/5] argparse: remove dead code Chengwen Feng
2024-03-07 13:07 ` [PATCH v2 3/5] argparse: replace flag enum with marco Chengwen Feng
2024-03-07 17:43 ` Tyler Retzlaff
2024-03-07 17:58 ` David Marchand
2024-03-07 18:37 ` Tyler Retzlaff [this message]
2024-03-07 13:07 ` [PATCH v2 4/5] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-18 2:31 ` Thomas Monjalon
2024-03-18 9:22 ` fengchengwen
2024-03-07 13:07 ` [PATCH v2 5/5] test/argparse: refine testcases Chengwen Feng
2024-03-18 9:18 ` [PATCH v3 0/6] refine argparse library Chengwen Feng
2024-03-18 9:18 ` [PATCH v3 1/6] argparse: refine error message Chengwen Feng
2024-03-18 9:18 ` [PATCH v3 2/6] argparse: remove dead code Chengwen Feng
2024-03-18 9:18 ` [PATCH v3 3/6] argparse: replace flag enum with marco Chengwen Feng
2024-03-18 9:18 ` [PATCH v3 4/6] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-18 9:38 ` Thomas Monjalon
2024-03-18 11:24 ` fengchengwen
2024-03-18 9:18 ` [PATCH v3 5/6] test/argparse: refine testcases Chengwen Feng
2024-03-18 9:18 ` [PATCH v3 6/6] argparse: fix doc don't display two hyphens Chengwen Feng
2024-03-18 11:18 ` [PATCH v4 0/6] refine argparse library Chengwen Feng
2024-03-18 11:18 ` [PATCH v4 1/6] argparse: refine error message Chengwen Feng
2024-03-18 11:18 ` [PATCH v4 2/6] argparse: remove dead code Chengwen Feng
2024-03-18 11:18 ` [PATCH v4 3/6] argparse: replace flag enum with marco Chengwen Feng
2024-03-18 11:18 ` [PATCH v4 4/6] argparse: fix argument flags operate as uint32 type Chengwen Feng
2024-03-18 11:18 ` [PATCH v4 5/6] test/argparse: refine testcases Chengwen Feng
2024-03-18 11:18 ` [PATCH v4 6/6] argparse: fix doc don't display two hyphens Chengwen Feng
2024-03-21 17:27 ` [PATCH v4 0/6] refine argparse library Thomas Monjalon
2024-03-22 1:24 ` fengchengwen
2024-05-08 9:10 ` 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=20240307183742.GB22674@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
--to=roretzla@linux.microsoft.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=thomas@monjalon.net \
/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).