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 5374D43B6F; Wed, 6 Mar 2024 18:34:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1385E42DBD; Wed, 6 Mar 2024 18:34:28 +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 5786B42D96 for ; Wed, 6 Mar 2024 18:34:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709746466; 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=gYGUdJpymR7J0jxSuBfQtZ7IptgbwMieWgfhurQSejA=; b=gFurAz4pFVuD5lLchSyVjU77kAA/hNTzjI9kMIR3Kczp5sZ3CJoEeCDw6F+WoHXUzgEssi 4pLNDs7B9GA7HcenA2p956ikHRvRqkoPOnxps0cvsVnr6l5kyccB05bnl9rqkrTY5Axcpp pkgpAkAQTSCo11/GN0qQJjsl0bxiQxk= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-502-hGiiq6xXMBudgjgmkmy6Xw-1; Wed, 06 Mar 2024 12:34:25 -0500 X-MC-Unique: hGiiq6xXMBudgjgmkmy6Xw-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-51313b50f1bso752967e87.0 for ; Wed, 06 Mar 2024 09:34:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709746464; x=1710351264; 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=gYGUdJpymR7J0jxSuBfQtZ7IptgbwMieWgfhurQSejA=; b=S8cGlwf2rtPpQHsfQFnresGwDmHwTuxeAIyB6sNiNx97KzNAUX1cxXoQLlGko7aaZ6 /x71uqjv+Az77rLIX4uz9v7pl3Y86BFHaPkaQUMhkt99QSQf/4vNJT4XnVk4sFB/g13h QQKut5Diyb301Ojj0PozaNMuNdz7VTIHPfBfwg1xVOWh7SjzYDP28hpTstYpVdDxWG6c WjLyOIRnugpRK5D9WoJB+QdZVi+eni+kcntSuB3EFNnHvZWgGXXgKeq8H2CrzpxtcZDT xzc72CVKFmZ7TzhhlG8Rk0vbr5YYcs0BruTO/lTYAvCMx9Pk1K0ULrIP0ZEdlTgaeCON XYKQ== X-Forwarded-Encrypted: i=1; AJvYcCVr9R11pF95/oWqadYiwGtqkQ47x5ZSLpGsxH+ZDk6cM4DPxyvwod95O4Vj5cyhcFejQWfG1W77yDczy6U= X-Gm-Message-State: AOJu0YzIWjSXuXI5Ynk12uwjHVARaSP05RdWdqxwKJQaRPXD2uAshjBd XFOm7ohavDE37YDicWYo5g10XoSh72C+ePx30I2102PsYLe0msOjRBg6vg1sFisNgwf3QLFDO81 h7zDIAmaeqnPSZCnR65GCnMPvwjrzausWIrZoS/e5GFRkxGOLxmfYF+RIABP280AjVwj8hsa+Yv thYAvmKo5locsaQKI= X-Received: by 2002:ac2:5f0b:0:b0:513:40e4:9090 with SMTP id 11-20020ac25f0b000000b0051340e49090mr3076789lfq.28.1709746463962; Wed, 06 Mar 2024 09:34:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzeLbDObWik0AzCHkLn+Pd2ai+v7xUg84l8W+mSopaXcsacZN+bizYkmtuPtt97F4Fv46OUW4j0N81pc1wYlo= X-Received: by 2002:ac2:5f0b:0:b0:513:40e4:9090 with SMTP id 11-20020ac25f0b000000b0051340e49090mr3076781lfq.28.1709746463524; Wed, 06 Mar 2024 09:34:23 -0800 (PST) MIME-Version: 1.0 References: <20240220131502.47510-1-fengchengwen@huawei.com> <20240220131502.47510-4-fengchengwen@huawei.com> In-Reply-To: <20240220131502.47510-4-fengchengwen@huawei.com> From: David Marchand Date: Wed, 6 Mar 2024 18:34:11 +0100 Message-ID: Subject: Re: [PATCH 3/4] argparse: fix argument flags operate as uint32 type To: Chengwen Feng Cc: 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 Tue, Feb 20, 2024 at 2:16=E2=80=AFPM Chengwen Feng wrote: > > The struct rte_argparse_arg's flags was 64bit type, uint64_t should be > used instead of uint32_t where the operation happened. Something is strange. An enum in C is represented as an int. Plus, this enum type is not used anywhere: lib/argparse/rte_argparse.h:enum rte_argparse_flag { lib/argparse/rte_argparse.h: /** @see rte_argparse_flag */ I understand the flags are a bitmask. So please remove this enum and define macros instead. > > Also, the flags' bit16 was also unused, so don't test bit16 in testcase > test_argparse_invalid_arg_flags. > > Fixes: 6c5c6571601c ("argparse: verify argument config") > Fixes: 31ed9f9f43bb ("argparse: parse parameters") > > Signed-off-by: Chengwen Feng > --- > app/test/test_argparse.c | 16 ++++++++-------- > lib/argparse/rte_argparse.c | 4 ++-- > 2 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/app/test/test_argparse.c b/app/test/test_argparse.c > index c98bcee56d..708a575e16 100644 > --- a/app/test/test_argparse.c > +++ b/app/test/test_argparse.c > @@ -188,7 +188,7 @@ test_argparse_invalid_arg_help(void) > static int > test_argparse_invalid_has_val(void) > { > - uint32_t set_mask[] =3D { 0, > + uint64_t set_mask[] =3D { 0, > RTE_ARGPARSE_ARG_NO_VALUE, > RTE_ARGPARSE_ARG_OPTIONAL_VALUE > }; > @@ -197,7 +197,7 @@ test_argparse_invalid_has_val(void) > int ret; > > obj =3D test_argparse_init_obj(); > - obj->args[0].flags &=3D ~0x3u; > + obj->args[0].flags &=3D ~0x3ull; If flags is a uint64_t, use RTE_BIT64(). I don't know the argparse API, but why do we need this hardcoded (and hard to understand) ~3 value? Can it be expressed with the flags defined in the API? > ret =3D rte_argparse_parse(obj, default_argc, default_argv); > TEST_ASSERT(ret =3D=3D -EINVAL, "Argparse parse expect failed!"); > > @@ -205,7 +205,7 @@ test_argparse_invalid_has_val(void) > obj =3D test_argparse_init_obj(); > obj->args[0].name_long =3D "abc"; > obj->args[0].name_short =3D NULL; > - obj->args[0].flags &=3D ~0x3u; > + obj->args[0].flags &=3D ~0x3ull; > obj->args[0].flags |=3D set_mask[index]; > ret =3D rte_argparse_parse(obj, default_argc, default_arg= v); > TEST_ASSERT(ret =3D=3D -EINVAL, "Argparse parse expect fa= iled!"); > @@ -269,7 +269,7 @@ test_argparse_invalid_arg_flags(void) > int ret; > > obj =3D test_argparse_init_obj(); > - obj->args[0].flags |=3D ~0x107FFu; > + obj->args[0].flags |=3D ~0x7FFull; Same comments as above. --=20 David Marchand