From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 7300D4369B;
	Thu,  7 Dec 2023 20:32:51 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 41E1642F04;
	Thu,  7 Dec 2023 20:32:51 +0100 (CET)
Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182])
 by mails.dpdk.org (Postfix) with ESMTP id 38E7742E7B
 for <dev@dpdk.org>; Thu,  7 Dec 2023 20:32:50 +0100 (CET)
Received: by linux.microsoft.com (Postfix, from userid 1086)
 id 68E4820B74C0; Thu,  7 Dec 2023 11:32:49 -0800 (PST)
DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 68E4820B74C0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;
 s=default; t=1701977569;
 bh=MpRGqL+Xr3Mat7OFL7YUfrnTfvIv42qP6jdXdV8crdE=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
 b=a9siFI/6rgqFKFoR6HOpeEODb6gq8uvMKCYgYLFwf292ExFTfaioMNV5Scfn44pGX
 vt/HRMf1rO6w/eJKnSBeYH+JX4lkMhvpkAPZV702lhgIlA5YIU/5zL0pbSYwSrr+jm
 pkMuMGvogiam28B1dFT/MBRcDMn/NeqCo/6ndYPU=
Date: Thu, 7 Dec 2023 11:32:49 -0800
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: Euan Bourke <euan.bourke@intel.com>
Cc: dev@dpdk.org, Thomas Monjalon <thomas@monjalon.net>,
 Bruce Richardson <bruce.richardson@intel.com>
Subject: Re: [PATCH v3 1/8] arg_parser: new library for command line parsing
Message-ID: <20231207193249.GA17449@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
References: <20231207161818.2590661-1-euan.bourke@intel.com>
 <20231207161818.2590661-2-euan.bourke@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20231207161818.2590661-2-euan.bourke@intel.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Thu, Dec 07, 2023 at 04:18:11PM +0000, Euan Bourke wrote:
> Add a new library to make it easier for eal and other libraries to parse
> command line arguments.
> 
> The first function in this library is one to parse a corelist string
> into an array of individual core ids. The function will then return the
> total number of cores described in the corelist.
> 
> Signed-off-by: Euan Bourke <euan.bourke@intel.com>
> ---
>  .mailmap                        |   1 +
>  MAINTAINERS                     |   4 ++
>  doc/api/doxy-api-index.md       |   3 +-
>  doc/api/doxy-api.conf.in        |   1 +
>  lib/arg_parser/arg_parser.c     | 108 ++++++++++++++++++++++++++++++++
>  lib/arg_parser/meson.build      |   7 +++
>  lib/arg_parser/rte_arg_parser.h |  66 +++++++++++++++++++
>  lib/arg_parser/version.map      |  10 +++
>  lib/meson.build                 |   2 +
>  9 files changed, 201 insertions(+), 1 deletion(-)
>  create mode 100644 lib/arg_parser/arg_parser.c
>  create mode 100644 lib/arg_parser/meson.build
>  create mode 100644 lib/arg_parser/rte_arg_parser.h
>  create mode 100644 lib/arg_parser/version.map
> 
> diff --git a/.mailmap b/.mailmap
> index ab0742a382..528bc68a30 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -379,6 +379,7 @@ Eric Zhang <eric.zhang@windriver.com>
>  Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
>  Erik Ziegenbalg <eziegenb@brocade.com>
>  Erlu Chen <erlu.chen@intel.com>
> +Euan Bourke <euan.bourke@intel.com>
>  Eugenio Pérez <eperezma@redhat.com>
>  Eugeny Parshutin <eugeny.parshutin@linux.intel.com>
>  Evan Swanson <evan.swanson@intel.com>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0d1c8126e3..68ef5ba14b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1756,6 +1756,10 @@ M: Nithin Dabilpuram <ndabilpuram@marvell.com>
>  M: Pavan Nikhilesh <pbhagavatula@marvell.com>
>  F: lib/node/
>  
> +Argument parsing
> +M: Bruce Richardson <bruce.richardson@intel.com>
> +F: lib/arg_parser/
> +
>  
>  Test Applications
>  -----------------
> diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
> index a6a768bd7c..f711010140 100644
> --- a/doc/api/doxy-api-index.md
> +++ b/doc/api/doxy-api-index.md
> @@ -221,7 +221,8 @@ The public API headers are grouped by topics:
>    [config file](@ref rte_cfgfile.h),
>    [key/value args](@ref rte_kvargs.h),
>    [string](@ref rte_string_fns.h),
> -  [thread](@ref rte_thread.h)
> +  [thread](@ref rte_thread.h),
> +  [argument parsing](@ref rte_arg_parser.h)
>  
>  - **debug**:
>    [jobstats](@ref rte_jobstats.h),
> diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
> index e94c9e4e46..05718ba6ed 100644
> --- a/doc/api/doxy-api.conf.in
> +++ b/doc/api/doxy-api.conf.in
> @@ -28,6 +28,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \
>                            @TOPDIR@/lib/eal/include \
>                            @TOPDIR@/lib/eal/include/generic \
>                            @TOPDIR@/lib/acl \
> +                          @TOPDIR@/lib/arg_parser \
>                            @TOPDIR@/lib/bbdev \
>                            @TOPDIR@/lib/bitratestats \
>                            @TOPDIR@/lib/bpf \
> diff --git a/lib/arg_parser/arg_parser.c b/lib/arg_parser/arg_parser.c
> new file mode 100644
> index 0000000000..240f63d8e1
> --- /dev/null
> +++ b/lib/arg_parser/arg_parser.c
> @@ -0,0 +1,108 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2023 Intel Corporation
> + */
> +
> +#include "errno.h"
> +#include "stdlib.h"
> +#include "ctype.h"
> +#include "string.h"
> +#include "stdbool.h"

should be <> not "" quotes for system or standard library headers includes.

> +
> +#include <rte_arg_parser.h>
> +#include <rte_common.h>
> +
> +
> +struct core_bits {
> +	uint8_t bits[(UINT16_MAX + 1) / CHAR_BIT];
> +	uint16_t max_bit_set;
> +	uint16_t min_bit_set;
> +	uint32_t total_bits_set;
> +};
> +
> +static inline bool
> +get_core_bit(struct core_bits *mask, uint16_t idx)

nit: use size_t typed parameters for things that are used as an offset /
subscript value. applies to all instances in the series.