From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8BD4543C12; Thu, 7 Mar 2024 18:58:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D88A402BA; Thu, 7 Mar 2024 18:58:39 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 06CA740272 for ; Thu, 7 Mar 2024 18:58:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709834316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2DDRPZ1s3XNtos/JwHB48gZwiu0w86aDfVR87tfxDlA=; b=QzhWodl9FPPnIWLaaFvQIiiwTAR/9osjRfgudqGRCuXYbqR4KnHTIJ83qmA642+Uh5EYgQ ABbaeuteuy0+Pc3rWj0gaq9IJxIehG0kfyneXTZJZuBfY8RgyXfVeSVIYOM8pbFFrfHKQX SMs+IDpqYrWpX7knIivSd0YrltsSzXk= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-9xzImsnmM0mCnFJXcdmDKQ-1; Thu, 07 Mar 2024 12:58:34 -0500 X-MC-Unique: 9xzImsnmM0mCnFJXcdmDKQ-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5135cb04b9fso1428102e87.3 for ; Thu, 07 Mar 2024 09:58:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709834313; x=1710439113; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2DDRPZ1s3XNtos/JwHB48gZwiu0w86aDfVR87tfxDlA=; b=p+057qIH8J5HY3e38oaq5gchEzLOgCHAly+S5nt0h5lon/kxX3XQqx6cwuKqvIi7sz LKx/GKaHDKtEeewz/uccxtKC2XJUPfUDlPoz5IzG2bVR/jdkAhwPeEcyQvUU+GVOVzZc 8ax/xaGZ+g8RJH2eXP0nKz3W1WhrQlrPRe42AnVYGoaGxaAQ3Zzn/LXafKl/d0VU/JTb zGNm8heWJ6LA/GnRjILThF0NGdtWPDNobdY0PsSqSgmNq/WekFbQjoMl5sPHMVROJK0Q F83CsasuA02DPGjMBSrHwuWnUailhPrx9rcPpH+4N1lWUi88/jMe4DnJaBKXYebxxpRO F6Ng== X-Forwarded-Encrypted: i=1; AJvYcCVHpiYZsYDF7XgwiCySTqX4Ync/E+srxpIh/vkkPI/gZ3aPqXa/eWyyiXlFjCJVcUWJgUfFXzVBo9t7/90= X-Gm-Message-State: AOJu0YwpVtDeD14tkRNLrgG+HOHu7HYLl7t56yt+H+v1LOwE3uGw3UTR IAm6UTqZgPnpqUUx/I9DzXYXmqbdg4Xvw9+x8nNLQ8JGMwb2NgznujCIgr8aKy6vOTpvOUAFyEV VDWf49Vt+DwMQ/naU3WHohjQIY1Dv0LRdlob3RJHfSpV7SbY/oQSsE50lanCkItdQzwFmO4Ik04 PLNg65ufKYTjMx0ro= X-Received: by 2002:ac2:5e35:0:b0:513:5c64:3a8a with SMTP id o21-20020ac25e35000000b005135c643a8amr2026362lfg.16.1709834313411; Thu, 07 Mar 2024 09:58:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmagL3sSfAlbwuqBKixp5fb51BvB7xjk6ZegIbxa0zre7l2hKcavg9cUVG+oBvSOIC7IT061Ry/XaIgYD/rc8= X-Received: by 2002:ac2:5e35:0:b0:513:5c64:3a8a with SMTP id o21-20020ac25e35000000b005135c643a8amr2026350lfg.16.1709834313041; Thu, 07 Mar 2024 09:58:33 -0800 (PST) MIME-Version: 1.0 References: <20240220131502.47510-1-fengchengwen@huawei.com> <20240307130742.5578-1-fengchengwen@huawei.com> <20240307130742.5578-4-fengchengwen@huawei.com> <20240307174300.GA14353@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> In-Reply-To: <20240307174300.GA14353@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> From: David Marchand Date: Thu, 7 Mar 2024 18:58:20 +0100 Message-ID: Subject: Re: [PATCH v2 3/5] argparse: replace flag enum with marco To: Tyler Retzlaff Cc: Chengwen Feng , thomas@monjalon.net, dev@dpdk.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Mar 7, 2024 at 6:43=E2=80=AFPM Tyler Retzlaff 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 > > --- > > 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)) --=20 David Marchand