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 CC7C343C94; Tue, 12 Mar 2024 18:03:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5FC5740EE2; Tue, 12 Mar 2024 18:03:07 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) by mails.dpdk.org (Postfix) with ESMTP id EE26C40ED9 for ; Tue, 12 Mar 2024 18:03:05 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cAtFc0zq7Hz6zKgcwAokM+1BCo22HPvRn3+3XkhCJxAAlufDR2NFdJ/iFlnwpuekFFxKIwpWvynCWNtd/lG1rbKtGhafZhhpRwVTQRPg4U9BGo1OzAkPidqe21N6MOvitm6t8XPwX+3I7YMrgjnnHjkqB3GIjqQpxjusTp1a7NuhexOn01K0voWueFqjNaavJF8EI/RowgD2c41m8gpezZAyxs79x3Re485fsefedg/NiH1KJ7JJrv2EEW671lna/wPqPMycYiZdeSZJ7huRYW7K99mfciopdXkdG03OAm449baLp4QUEu4mpGS3UvCf4MEqW+dhCJ+9x6VyN6rUDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ui/oKgJ+3fosH3dfYEuB5WyQ+jzW678BkkguidAr/pw=; b=LBV0jQhKWATytEbbVgRxAhzj8Mk1PQ6W6frjkGZJ76lKLRWyiJNSmybiM8m/w6euaW9chlZaqkM6lfaFrB3cQcOUciMlKUzPBNdOxpKvc75JJsUclE5knBr/MIbts2OK9RvZcYE5nGmQG4fEMmbBBHruav0WY04uMYsRysMusBOjIvFPDOQDA6J+QyztUanJ/3mdjci0Lh/Ft/slTLVX631y2RAA+FlVQgpPohY2Nb+O84/2c0qsCitgJyD2DMfTcpI4P03c/oQuAFfA/fNtR4pMvQlQ8v9WmgS16aux2acJupFBD0sGrHZAHXYZj8g+c0qnL8ThhkEMG0O73Zqq+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ui/oKgJ+3fosH3dfYEuB5WyQ+jzW678BkkguidAr/pw=; b=4XrHJK67RFXdSDWL/4Pv3Ird8xLxrjdD/6WHChIHngNmURxqBm3nrzLnSAn/mGzUD7ALH7T2wxP9i0JG4heZZ2K5VIzN3xBerTkAY7RyChwNb4G7zxilbA7IUyjnCU9wVZelhY6ED3AlkSlpQLBMYCE589MYBFESwrrdICWaFWo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by SN7PR12MB8147.namprd12.prod.outlook.com (2603:10b6:806:32e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Tue, 12 Mar 2024 17:03:04 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::3ec7:6339:1c14:c529]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::3ec7:6339:1c14:c529%5]) with mapi id 15.20.7362.035; Tue, 12 Mar 2024 17:03:04 +0000 Message-ID: <25bb9521-97fb-4466-8aca-237060d738ca@amd.com> Date: Tue, 12 Mar 2024 17:03:00 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] app/testpmd: enhance getopt_long usage Content-Language: en-US To: David Marchand , dev@dpdk.org Cc: Aman Singh , Yuying Zhang References: <20240308144841.3615262-1-david.marchand@redhat.com> <20240308144841.3615262-5-david.marchand@redhat.com> From: Ferruh Yigit Autocrypt: addr=ferruh.yigit@amd.com; keydata= xsFNBGJDD3EBEAC/M7Tk/DfQSmP1K96vyzdhfSBzlCaGtcxNXorq4fALruqVsD3oi0yfyEz9 4YN8x7py0o9EL8ZdpOX0skc0AMCDAaw033uWhCn0GLMeGRKUbfOAPvL6ecSDvGD7CJIO9j0J eZUvasBgPdM/435PEr9DmC6Ggzdzt8IuG4PoLi5jpFSfcqxZFCCxLUDEo/w0nuguk2FTuYJg B2zEZ4JTBZrw7hIHiFh8D8hr6YA6a5uTofq1tr+l048lbtdFUl8TR0aIExVzE4Z8qKZlcE+9 RQaewjK5Al1jLE4sHdmd3GN+IvgDF3D/fLsi25SKJDeGSdeHkOmaX0qGeM4WKIfU6iARRCiQ N3AmBIxZ/A7UXBKLaOyZ+/i3sE6Wb53nrO4i8+0K2Qwyh6LjTeiJAIjYKN43ppxz3DaI+QwQ vI+uyHr4Gg0Da9EPPz/YyKauSeOZCfCB5gIfICO0j6x0SCl8uQ2nLpjxcZkf0gjcwUzP3h+S 3x6NfDji9YEij0zczW/dcSpGgZ6vsFpPrtnP9ZXy6J53yp0kJtOJoOlkEFFdU2yCZnCDseum CoudmGLZVvS0/DzHDJejq+3kK3FDGktZBOxZIIpal+nFqS7lVgOZc4+huVv3jyhzoAUOEyXA XK5j6o7g8STUY+z33QNnHpdLvecMwuzmvqy0jR54yAbZ64mB9QARAQABzSNGZXJydWggWWln aXQgPGZlcnJ1aC55aWdpdEBhbWQuY29tPsLBlwQTAQgAQQIbAwULCQgHAgYVCgkICwIEFgID AQIeAQIXgAIZARYhBEm7aYjps5XGsPHCElRTPtCKKm/6BQJkdyEEBQkE3meNAAoJEFRTPtCK Km/6UdcP/0/kEp49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 8Zk= In-Reply-To: <20240308144841.3615262-5-david.marchand@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P123CA0040.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600::28) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|SN7PR12MB8147:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b55546a-1ab5-4a18-f50e-08dc42b6482c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uzLgVwTGl+d+ZFj2+nmHaJz79B2t6wmHukg/Hff7pXkX4/KHG6WU7MyscgyhzsFYCbfoGu7s3Sx9nsLQZT6zgvfjMnuR62pNDc+hd30Fj8B7SHer3XUoUow9q4o93mKYJAr9JWM7Q/p2PrdWN3WOicQgNWxZacZQE99cOrZuOZYTtRhlyHyXGZv50yXK03RFSU9TGQSx6KRpuSphnj1e4vdEaPEvVbrzI7z5EHve0nQ+u0W0ib/o0v93jDddhhydLPq/jb+sIcnGwAV8VqiDeCO0LgzErJ44/Ec9IwbS7SYRb/ySiiADSjDLkRNe6wNlf6oZ7UOJIWBmsQLxX0sXmrrRvscanltC7PtkZMvzFhkZxMK8/10vPuoVvVA74IsSf/CKGm+fsjDdvt7y3/lhKUQ4084CzDmD2E2/fkrdLJqB6NfRl1jTz/EZMDi+xEZvvRQ3TBEBTm0F5xGIa5wnRK3+nBzirUaJrEpeOMxOlxRK/DzzfAgx+C+m5N02ki+T8T2ikpTAEIDX7xAo7Otszf/cDWvuSiAo/JRtGc/VGdJQKgjtB70ZZSCc+76Jmhqly3/x7ZRAftkGae3eUtx0p0G906cgiWc3kBwE09PYB2UFsVYJNJIswalUcbApoR2Ztsu7HkIjVruPdH0Z24iVda3N7Z8C8exi+r7oESExuXo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(1800799015); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SUlmUjEyRmpVVDNWSlNyRXVsclRFdCthZE9BZkx1NmlIRlJjZzZZMEtvcVAr?= =?utf-8?B?OVRQOEhXZlpncDVOQ3E4VHlVQzFUcnpDTmFiV01YbW5oUWdPc0FMUUowMlVY?= =?utf-8?B?cHduL29NS0pNUTVCWGpQYTVjZ0FRRGUrejcvYW9UQjdiRTVUZjcvaWQ0NTQy?= =?utf-8?B?azUzT2pQd09DYnBQWStRSlJHOERJcGFGSzdocW54R3BIaGFlb0pnQXQ5Yk5C?= =?utf-8?B?a25kWjJrZ3hqL3o0UGdJYWJUNm9pREZ1RUFvancrKyt5V05hcm1kSUZ4OGpL?= =?utf-8?B?MlI2QytudGZ3bFFtRElpcGpzQys4WEdYeTk0c1hFSWtLajF0LzVJMjJneTVX?= =?utf-8?B?eFA0TktxZXJnYXpla252UHZlMFJLQ0txUUlrWVpjY25HZkxPRkpFT08ybHht?= =?utf-8?B?MXRYY1AxbzAzQ21PQ0NBWTFOdUl5OGViRk1MeDFHL2JLUFhVVVVva3U4WVIz?= =?utf-8?B?aDFuNmdISnltSE8wZlpYOW1sZFUvVTVzNkRNcVcrV3pXeGtNTGlOTTRQT3Ru?= =?utf-8?B?V0kwd1U3TEFwemNydmk3ZzUwOWd3UkV5c054c1ROOWwxZ1NtanQ1Qk1HUys4?= =?utf-8?B?RnJDNExMWTFmSVdjakNmL0FjOFRTSjlJTDlnMjdjQnBJbkkwUUY4enA4WkhU?= =?utf-8?B?UjcwRnl6Q0ZUQUhTUVM1NlFxWWE1VlJZOGRBT3ZoN0R2YzVzclhxdDhhd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2L3FwY1Bxd2ZpNDlxajdu?= =?utf-8?B?WnZYRWpqWlI0UkJtWkVzam8rSmJsVnFsWUdNbjRCSDl6b0FiaEthZGVqZUFm?= =?utf-8?B?SU85NVR1M2s1ZmlKRGdUU01GVllMSmVXRGNUYjBtVi9JNWZ4eGxzZ0RmYmVC?= =?utf-8?B?MmR4ZG91THFNbnZYaVQ5Z3l6OEl5UUh3OUt5cmxKamRYT2ZHNW9ONGRZOEtR?= =?utf-8?B?bmlLN0pnRjU1S1Zic2VLbU1mWFhBWUx5YTlrcEtPRnBSTjBNWSs5N2hBM1M4?= =?utf-8?B?Umpra2FjSmpDS3dvY1JBdmdmNzdaU3I0K1dzdnFOVjE2TllLVzVKWVEvKzh3?= =?utf-8?B?d1JTWHQ1WGdzakFQWnl3M3Noa3FTa21jWGw5RmRjc05DUEhwZHFXeGhTY0lX?= =?utf-8?B?aE9mU0E0WnZjUXEycEdZNGNvUGJ4UnIwOE9NbGhlSVF4MHl0SldGeVlyNEpK?= =?utf-8?B?VUltUU5zOEUxVXpxcWRKaCtxMnIwbzYvOTl0dndiMGJFaFBURyt4Z0F1Nkhw?= =?utf-8?Q?KmeEQbCUzCK05bzqOHf+A1SD3?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b55546a-1ab5-4a18-f50e-08dc42b6482c X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2024 17:03:04.3340 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: h7yetezXVtJxAf8kZUTGcntxW7H9/og3qVnbM9SA+s7aMURf98J/CJZaGdAU7y0P X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8147 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 3/8/2024 2:48 PM, David Marchand wrote: > This is a cleanup similar to previous ones in EAL and examples. > Instead of using strcmp for every long options while getopt_long already > did such parsing, rely on getopt_long return value. > > Note for reviewers: this patch is best reviewed once applied locally and > displayed with git show -w. > Thanks for the cleanup, it was needed. > Signed-off-by: David Marchand > --- > app/test-pmd/parameters.c | 1928 +++++++++++++++++++++---------------- > 1 file changed, 1084 insertions(+), 844 deletions(-) > > diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c > index 271f0c995a..58f43cb5a8 100644 > --- a/app/test-pmd/parameters.c > +++ b/app/test-pmd/parameters.c > @@ -40,6 +40,346 @@ > > #include "testpmd.h" > > +enum { > + /* long options mapped to a short option */ > +#define TESTPMD_OPT_AUTO_START "auto-start" > + TESTPMD_OPT_AUTO_START_NUM = 'a', > +#define TESTPMD_OPT_HELP "help" > + TESTPMD_OPT_HELP_NUM = 'h', > +#define TESTPMD_OPT_INTERACTIVE "interactive" > + TESTPMD_OPT_INTERACTIVE_NUM = 'i', > + > + /* first long only option value must be >= 256 */ > + TESTPMD_OPT_LONG_MIN_NUM = 256, > This is to be able to use all short options, not sure if this requires a comment. <...> > +}; > + > +static struct option long_options[] = { > Can it be constant? > + { TESTPMD_OPT_AUTO_START, 0, NULL, TESTPMD_OPT_AUTO_START_NUM }, > In original version "auto-start" long version is enabled only if 'RTE_LIB_CMDLINE' enabled, not sure why, but not for short version, I think there is a confusion. OK to remove RTE_LIB_CMDLINE requirement for 'auto-start' but perhaps better to have it in separate patch, what do you think? > + { TESTPMD_OPT_HELP, 0, NULL, TESTPMD_OPT_HELP_NUM }, > +#ifdef RTE_LIB_CMDLINE > + { TESTPMD_OPT_INTERACTIVE, 0, NULL, TESTPMD_OPT_INTERACTIVE_NUM }, > + { TESTPMD_OPT_CMDLINE_FILE, 1, NULL, TESTPMD_OPT_CMDLINE_FILE}, > What about using 'no_argument' & 'required_argument' instead of '0' & '1', but I guess it will make lines too big, as flag will be always NULL in this approach, what about defining macros for arg and no_arg, like: ``` #define ARG(name) (name), required_argument, NULL, name##_NUM #define NOARG(name) (name), no_argument, NULL, name##_NUM #define OPTARG(name) (name), optional_argument, NULL, name##_NUM { NOARG(TESTPMD_OPT_INTERACTIVE) }, { ARG(TESTPMD_OPT_CMDLINE_FILE) }, ``` > + { TESTPMD_OPT_ETH_PEERS_CONFIGFILE, 1, NULL, TESTPMD_OPT_ETH_PEERS_CONFIGFILE_NUM }, > + { TESTPMD_OPT_ETH_PEER, 1, NULL, TESTPMD_OPT_ETH_PEER_NUM }, > These long options are within "#ifdef RTE_LIB_CMDLINE" block, I don't know why, I guess above two can work without cmdline library. <...> > - > argvopt = argv; > Why 'argvopt' is required, why not use 'argv' directly? <...> > #ifdef RTE_LIB_CMDLINE > ... > + case TESTPMD_OPT_ETH_PEER_NUM: { > + char *port_end; > > - if (rte_ether_unformat_addr(port_end, > - &peer_eth_addrs[n]) < 0) > - rte_exit(EXIT_FAILURE, > - "Invalid ethernet address: %s\n", > - port_end); > - nb_peer_eth_addrs++; > - } > + errno = 0; > + n = strtoul(optarg, &port_end, 10); > + if (errno != 0 || port_end == optarg || *port_end++ != ',') > + rte_exit(EXIT_FAILURE, > + "Invalid eth-peer: %s", optarg); > + if (n >= RTE_MAX_ETHPORTS) > + rte_exit(EXIT_FAILURE, > + "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n", > + n, RTE_MAX_ETHPORTS); > + > + if (rte_ether_unformat_addr(port_end, > + &peer_eth_addrs[n]) < 0) > + rte_exit(EXIT_FAILURE, > + "Invalid ethernet address: %s\n", > + port_end); > + nb_peer_eth_addrs++; > + break; > + } > #endif > Similar to the 'struct option long_options' comment, I think expect from "interactive" & "cmdline-file", rest can be moved out of "#ifdef RTE_LIB_CMDLINE" block, but not this patch in different patch. <...> > default: > usage(argv[0]); > It is not shown in the patch, to print the error case it uses: `fprintf(stderr, "Invalid option: %s\n", argv[optind]);` But as far as I can see 'optind' is the next arg to call, so instead it should be 'optind - 1'. And just after while loop, there is "if (optind != argc)" check, I don't see when this check will be hit, so it looks useless.