bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <kafai@fb.com>
To: Quentin Monnet <quentin@isovalent.com>
Cc: <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>,
	<netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next 4/4] bpftool: Add struct_ops support
Date: Mon, 16 Mar 2020 17:57:21 -0700	[thread overview]
Message-ID: <20200317005721.vhruudlmhr637uto@kafai-mbp> (raw)
In-Reply-To: <20200317002452.a4w2pu6vbv4cvsid@kafai-mbp>

On Mon, Mar 16, 2020 at 05:24:52PM -0700, Martin KaFai Lau wrote:
> On Mon, Mar 16, 2020 at 11:54:28AM +0000, Quentin Monnet wrote:
> 
> > [...]
> > 
> > > +static int do_unregister(int argc, char **argv)
> > > +{
> > > +	const char *search_type, *search_term;
> > > +	struct res res;
> > > +
> > > +	if (argc != 2)
> > > +		usage();
> > 
> > Or you could reuse the macros in main.h, for more consistency with other
> > subcommands:
> > 
> > 	if (!REQ_ARGS(2))
> > 		return -1;
> Thanks for the review!
> 
> I prefer to print out "usage();" whenever possible but then "-j" gave
> me a 'null' after a json error mesage ...
> 
> # bpftool -j struct_ops unregister
> {"error":"'unregister' needs at least 2 arguments, 0 found"},null
> 
> Then I went without REQ_ARGS(2) which is similar to a few existing
> cases like do_dump(), do_updaate()...etc in map.c.
> 
> That was my consideration.  However, I can go back to use REQ_ARGS(2)
> and return -1 without printing usage.  no strong preference here.
After another look,  I will keep it as is since REQ_ARGS() is a "<"
check.  "argc != 2" is the correct check here.  Otherwise,
allowing 'bpftool struct_ops unregister name cubic dctcp' looks weird.

  reply	other threads:[~2020-03-17  0:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16  0:55 [PATCH bpf-next 0/4] bpftool: Add struct_ops support Martin KaFai Lau
2020-03-16  0:56 ` [PATCH bpf-next 1/4] bpftool: Print the enum's name instead of value Martin KaFai Lau
2020-03-17 20:03   ` Andrii Nakryiko
2020-03-16  0:56 ` [PATCH bpf-next 2/4] bpftool: Print as a string for char array Martin KaFai Lau
2020-03-17 20:08   ` Andrii Nakryiko
2020-03-17 21:03     ` Martin KaFai Lau
2020-03-16  0:56 ` [PATCH bpf-next 3/4] bpftool: Translate prog_id to its bpf prog_name Martin KaFai Lau
2020-03-16  0:56 ` [PATCH bpf-next 4/4] bpftool: Add struct_ops support Martin KaFai Lau
2020-03-16 11:54   ` Quentin Monnet
2020-03-17  0:24     ` Martin KaFai Lau
2020-03-17  0:57       ` Martin KaFai Lau [this message]
2020-03-17  9:25         ` Quentin Monnet
2020-03-16 11:54 ` [PATCH bpf-next 0/4] " Quentin Monnet

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=20200317005721.vhruudlmhr637uto@kafai-mbp \
    --to=kafai@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).