[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e9b94aa8-1f28-a410-c295-d1c341b193ab@lab.ntt.co.jp>
Date: Mon, 14 May 2018 17:28:40 +0900
From: Prashant Bhole <bhole_prashant_q7@....ntt.co.jp>
To: Jesper Dangaard Brouer <brouer@...hat.com>
Cc: Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <ast@...nel.org>,
"David S . Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next] samples/bpf: xdp_monitor, accept short options
On 5/12/2018 1:31 AM, Jesper Dangaard Brouer wrote:
> On Fri, 11 May 2018 10:37:51 +0900
> Prashant Bhole <bhole_prashant_q7@....ntt.co.jp> wrote:
>
>> updated optstring accept short options
>>
>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@....ntt.co.jp>
>> ---
>> samples/bpf/xdp_monitor_user.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/samples/bpf/xdp_monitor_user.c b/samples/bpf/xdp_monitor_user.c
>> index 894bc64c2cac..668511c77aaf 100644
>> --- a/samples/bpf/xdp_monitor_user.c
>> +++ b/samples/bpf/xdp_monitor_user.c
>> @@ -594,7 +594,7 @@ int main(int argc, char **argv)
>> snprintf(bpf_obj_file, sizeof(bpf_obj_file), "%s_kern.o", argv[0]);
>>
>> /* Parse commands line args */
>> - while ((opt = getopt_long(argc, argv, "h",
>> + while ((opt = getopt_long(argc, argv, "hDSs:",
>> long_options, &longindex)) != -1) {
>> switch (opt) {
>> case 'D':
>
> It was actually on purpose that I didn't add the short options,
> in-order to force people use those "self-documenting" long-options when
> they show the usage on public mailing lists or in blog-posts.
Got it.
>
> If you want these short options, you also have to correct the "usage"
> function that state these are "internal" short-options.
I am submitting v2 with "usage" updated, because with usability point of
view it is nice to have short options. Thanks.
-Prashant
>
> Notice the long options parsing done by getopt_long() allow you to only
> specify part of the string. Al-through, I can see --s is ambiguous.
>
> $ sudo ./xdp_monitor --s
> ./xdp_monitor: option '--s' is ambiguous; possibilities: '--stats' '--sec'
Powered by blists - more mailing lists