All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, brouer@redhat.com
Subject: Re: [PATCH bpf-next] samples/bpf: xdp_monitor, accept short options
Date: Fri, 11 May 2018 18:31:25 +0200	[thread overview]
Message-ID: <20180511183125.6b4f92e2@redhat.com> (raw)
In-Reply-To: <20180511013751.4360-1-bhole_prashant_q7@lab.ntt.co.jp>

On Fri, 11 May 2018 10:37:51 +0900
Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> wrote:

> updated optstring accept short options
> 
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.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.

If you want these short options, you also have to correct the "usage"
function that state these are "internal" short-options.

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'

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

  reply	other threads:[~2018-05-11 16:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11  1:37 [PATCH bpf-next] samples/bpf: xdp_monitor, accept short options Prashant Bhole
2018-05-11 16:31 ` Jesper Dangaard Brouer [this message]
2018-05-14  8:28   ` Prashant Bhole

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=20180511183125.6b4f92e2@redhat.com \
    --to=brouer@redhat.com \
    --cc=ast@kernel.org \
    --cc=bhole_prashant_q7@lab.ntt.co.jp \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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.