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 333A743CAD; Thu, 14 Mar 2024 00:28:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A76DD40297; Thu, 14 Mar 2024 00:28:08 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060.outbound.protection.outlook.com [40.107.244.60]) by mails.dpdk.org (Postfix) with ESMTP id 841B14021E for ; Thu, 14 Mar 2024 00:28:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l/qK2+Df/aZ+FUW8MbZCOQxpb1cgAmlSMZ46rNHeyOp3TcGd8UDH/fcobXY4PyJyqmqAFTQOEXboS9Cmy5F4nWpTPjWQu+CGHEsV8xu9A8QM840oi+tu5+YsC8Jz1lbuX7bKEB1Y8HZen/PB6SO9IF8F9mEQlwxBX7sIEqI11CR1UC/VuPIq3UxDBpRA+TL2bXkUt5wIRCDPd0J/FX8zWwx7C3yo1ePKqximnne6VqP+t828xFcKLUyVMa0l9IOiS4IaUmcawkH1CW1qFJvSHLfLMe9gvmYJJLXIOessMpDcERdywbHhBQUxb+JMYN5T7DIugwp3zkva9pJrVcEe8w== 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=OvCHtcEilwp+QoP7HGwg1znw4O5D8rKccFD5sXjvUPY=; b=gm98O8rQWh6L/wMQYZHBn7r+Ps19I7Q2osD0u9Sy0HH1wo7wxnB2e6YjVNvm822F/tHFTioQRlocjOYtglv7jTxRAovdTdYOHcrDRRJRDivGNQdjI+f9qpv5hf8BfrF0+4vu8aSICAqphVObVKWETm0eUD6XKknf9hNz/dnisuOg6L8kGlqpn3CeKIJELcG+SCuTfJYJb9bj7IUtrYvuKoRgR4P3L4Djn5JdfBJnT0EArJoiObP8uslY7I20UQFu8Tgaasjw1yvB2RClXi176lxFR+r35WuXYTjO0XwvkKqCHgGBxUml498UHeWxOkwRzMLYw3hAmaUop45HaKww1A== 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=OvCHtcEilwp+QoP7HGwg1znw4O5D8rKccFD5sXjvUPY=; b=SV4KtZFPeo/VvnNrV6GZz7gPbqEwrHqhC5J550Bf29PhEMWAmJ1K+l8ckZSAP3jVlMdQ4584cMTeYaowqKnogbVznBe8BW0inKOLuAJ5g0Bt8IzmfBxVMOyRnJKQfXJ+O3dzNy51Gq6R0HB/1+1HRDYxhsXKIMbS2fYgYgbXwcA= 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 SA1PR12MB8744.namprd12.prod.outlook.com (2603:10b6:806:38c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Wed, 13 Mar 2024 23:28:05 +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; Wed, 13 Mar 2024 23:28:05 +0000 Message-ID: <443719b6-e37a-47b5-9ef4-07514e742b7d@amd.com> Date: Wed, 13 Mar 2024 23:28:01 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] app/testpmd: enhance getopt_long usage To: David Marchand Cc: dev@dpdk.org, Aman Singh , Yuying Zhang References: <20240308144841.3615262-1-david.marchand@redhat.com> <20240308144841.3615262-5-david.marchand@redhat.com> <25bb9521-97fb-4466-8aca-237060d738ca@amd.com> Content-Language: en-US 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 AQIeAQIXgAIZARYhBEm7aYjps5XGsPHCElRTPtCKK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Te2YScp9dIV7fsS5tpDwIs7BZNVM1l3NAdK+DLHqNxKuyO 8Zk= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0318.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:390::17) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|SA1PR12MB8744:EE_ X-MS-Office365-Filtering-Correlation-Id: 45f875c6-7a1f-4d6f-a1bc-08dc43b53bcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iJlakNf+04RWot3amMRt583szXQKUhBgJhGngpYlMPsyXrpW9KJ5DqnhGvn4TjJn/mQk6VzO9T0Y/wmT+Cd2J4UgEg+lGb0U6YprA8Fqsjcp2IHhalaQ29fHbMtjiOGTJoYg7UGdDW6NFqH2rCCqPtd625PM8qt7K56bLJgOIW9yuRn/dXOlzCRTYxnHrzFS3PqyrYxtf83w61zD7TrD4I5DZtokAidlzc+brI3cs4C9bKpDx3ls9g/SlsdidDtmFyS7ahutfMd8sMAR8GrVRlMaYL4+VLpcL7Bocg6kysW1Fwcv5yByj+VicZrTwp2Bk82N/48mshsBth5X9MwGuMahuCZnFfN4SO5MjVS2W/Q7B5D1VijxDhQYZpfSNgQJH5SkejJBS4RiKnYLeQyY/isDhK963paSaRJa+euc/oNqqAcZLl6c+QWwkzC8jXq/9I/TwWDc5Udj1eo8atAY7u/F2XvgcJNkEBIDklf3nTwg6fkbXisXTx3cqEkNspKXZrRoxSbB+iFRlJ+MGgigBiPPxV7Ma6fAVOIgJt+nmfC0gpd2y+tcrs1TA/J6BWmB/+KEGpFbMyL8CjwfaH28DqZDy/EAVqa+MUDYJ+8MYR06DzKJYPdhqd+OFmJVLYivkIi6ptPOwnPxAx+WHKbSuA== 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?MlA4RzY3MXJxdXU1TEZuWUJYMlNlemNxRGlyM1JVUDRsbDFlNDVHKzZtZy8w?= =?utf-8?B?Tmk4b1luK2M4TVJCREQ0ZUg0VEdHbnpzcDNsMjJacFZoNzArOFZsV1lhVUZT?= =?utf-8?B?MWtQSzFYTWMyTmJweEptUjNDNzl2YU16dnBta2lhSENzR2Rtem1BZExUWTg5?= =?utf-8?B?M25aNUloS3grWGplWWFnTU1zanl3dlBzaGQ4YllhSTN3TmhHV3dJb0JwWmJZ?= =?utf-8?B?WUFUamVucFdzUExDVEZTV05UZnU3OUFJeTluMEJwazNMMTZXMUhnTkE4NG1I?= =?utf-8?B?ZThnTXdXd0wzbGFuMFNlRDU0QllqUXhnbUZVM1R3TnQrVEFiWEZ5MklJQk54?= =?utf-8?B?N21nZU9mQllwb2NqYW9EMEVEc3kwNHdlUTZmT3dsYWxYQlo2ejdicVl1QTZv?= =?utf-8?B?T1F1aisyS1Q1azN6MHN1ZXk5aWFWOWhFS1JVNlVvN2Jsd1ZTcWQ0L1BHNVd6?= =?utf-8?B?OHlkd1RVUHB1VzlCbUo5R2NYUVVWZUVEam1WbzZpVW45WnIrM1NBaExhYm4y?= =?utf-8?B?dm1ENFIrUDFhWXkyeEZ6cTFBdTgydnJRQ09ZbVEvU2JtTEpzOW0rUVllOW9m?= =?utf-8?B?NStncDVpMVNkeGZYUzdZN0prdzFoWUhYWklDZGg3b202dVNsbVd3Nkk2WUwr?= =?utf-8?B?aWR3bkFma0N3MWxkOEdaTDFRbzFQZ3dCb1pYYm1PS2FmbU16Wm9SYm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wdHJ6K2ZKQ1E4ZTZEMndw?= =?utf-8?B?dWxlQjVEUDNmaXljVFJkbjFCNDZPUWY4Mlg2VGRCdC9iaEtGTElEL0dwR1Ew?= =?utf-8?B?N296NmU0YSswTUszdFljbGZhWDkvSkxlSXV0ZS95OWlqb2gzWE5TYkpPdCsw?= =?utf-8?B?N0p2YUhaNjBQTDZBeTFHenFJMUkzSFlrdDNianZReWNOdzJIWE5JeWIwWC9v?= =?utf-8?B?OWxDOUZOWS9rZ0FDbTJhSmszTi93MHVDUFBsQXlXU0tCR280TkVtYkNHZVR0?= =?utf-8?B?Z0N2dS90Wm5Jbm85dEEwR2tmR0FiK2piV2N6YjhUcDVjeVN0UEdCRWJtUzNX?= =?utf-8?B?aDk1UDRZUllkUVU2OFF5cmh3bXhhS29UVHJJQldVMGpwdFhycU1XR3QxQkRi?= =?utf-8?B?S1REdm1pb0VwWWZxWW9TdVhwUnFxYVNaSmExMklyY3FxZWdvU3VMMERQb0FW?= =?utf-8?B?SndNQnJDSVo4VHRtTVB0N01PMmowZHdCTWFIZ2RJdzJGSkVzQlFnbGU4SnFQ?= =?utf-8?Q?7DR+yoaaN3aMtZ6zJZQn+l4pk?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45f875c6-7a1f-4d6f-a1bc-08dc43b53bcc X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2024 23:28:05.3001 (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: EyBOoVWgD1HXo/x800KT46EeJP+hbSTJs4BlVF583H+Rt/pv6EgkpI4yquY43kpN X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8744 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/13/2024 4:51 PM, David Marchand wrote: <...> >> >> 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. > But this part actually looks correct to me. > We could still hit this part with non handled trailing strings: > > $ build-mini/app/dpdk-testpmd -c 3 --no-huge -m 40 -a 0:0.0 --vdev > net_null1 --vdev net_null2 -- -i garbage > Invalid parameter: garbage > EAL: Error - exiting with code: 1 > Cause: Command line is incorrect > Port 0 is closed > Port 1 is closed > OK, I see it is to catch non-option argument and works as expected. I missed that when 'getopt_long()' returns -1 (EOF), it sets 'optind' to point first non-option argument in argv, and does this by swapping elements in argv[] (I wasn't aware 'getopt_long()' does this). Since testpmd doesn't get any non-option argument, it can be possible to prefix 'short_options' with '+', (like "+ah"), which modify 'getopt_long()' behavior to stop when first non-option argument seen. This prevents some unnecessary argument parsing, but it seems this is a GNU extension, not posix standard, so not sure does it worth this optimization.