From: Ferruh Yigit <ferruh.yigit@amd.com>
To: David Marchand <david.marchand@redhat.com>
Cc: dev@dpdk.org, Aman Singh <aman.deep.singh@intel.com>,
Yuying Zhang <yuying.zhang@intel.com>
Subject: Re: [PATCH 4/4] app/testpmd: enhance getopt_long usage
Date: Wed, 13 Mar 2024 23:28:01 +0000 [thread overview]
Message-ID: <443719b6-e37a-47b5-9ef4-07514e742b7d@amd.com> (raw)
In-Reply-To: <CAJFAV8xqS+aEa8QgtJFCD4ckK7RuhriDo=9_Xd+as8r-EnXwWA@mail.gmail.com>
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.
next prev parent reply other threads:[~2024-03-13 23:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-08 14:48 [PATCH 0/4] testpmd options parsing cleanup David Marchand
2024-03-08 14:48 ` [PATCH 1/4] app/testpmd: fix stats-period option check David Marchand
2024-03-12 16:43 ` Ferruh Yigit
2024-03-08 14:48 ` [PATCH 2/4] app/testpmd: fix burst option parsing David Marchand
2024-03-12 16:47 ` Ferruh Yigit
2024-03-13 7:24 ` David Marchand
2024-03-13 10:37 ` Ferruh Yigit
2024-03-13 11:13 ` David Marchand
2024-03-13 12:09 ` Ferruh Yigit
2024-03-13 16:32 ` Stephen Hemminger
2024-03-08 14:48 ` [PATCH 3/4] app/testpmd: check queue count for related options David Marchand
2024-03-12 16:59 ` Ferruh Yigit
2024-03-13 7:37 ` David Marchand
2024-03-13 10:42 ` Ferruh Yigit
2024-03-13 11:10 ` David Marchand
2024-03-13 12:18 ` Ferruh Yigit
2024-03-08 14:48 ` [PATCH 4/4] app/testpmd: enhance getopt_long usage David Marchand
2024-03-12 17:03 ` Ferruh Yigit
2024-03-13 16:51 ` David Marchand
2024-03-13 17:20 ` David Marchand
2024-03-13 23:28 ` Ferruh Yigit
2024-03-13 23:28 ` Ferruh Yigit [this message]
2024-03-14 9:17 ` [PATCH v2 0/6] testpmd options parsing cleanup David Marchand
2024-03-14 9:17 ` [PATCH v2 1/6] app/testpmd: fix stats-period option check David Marchand
2024-03-14 9:17 ` [PATCH v2 2/6] app/testpmd: fix burst option parsing David Marchand
2024-03-14 9:22 ` Ferruh Yigit
2024-03-14 9:17 ` [PATCH v2 3/6] app/testpmd: fix error message for invalid option David Marchand
2024-03-14 9:23 ` Ferruh Yigit
2024-03-14 9:17 ` [PATCH v2 4/6] app/testpmd: enhance queue count check David Marchand
2024-03-14 9:23 ` Ferruh Yigit
2024-03-14 9:17 ` [PATCH v2 5/6] app/testpmd: remove dead code for disabling cmdline library David Marchand
2024-03-14 11:33 ` Ferruh Yigit
2024-03-14 9:17 ` [PATCH v2 6/6] app/testpmd: enhance getopt_long usage David Marchand
2024-03-14 11:43 ` Ferruh Yigit
2024-03-14 12:43 ` [PATCH v2 0/6] testpmd options parsing cleanup Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=443719b6-e37a-47b5-9ef4-07514e742b7d@amd.com \
--to=ferruh.yigit@amd.com \
--cc=aman.deep.singh@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=yuying.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.