public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome•com>
To: Roman Gushchin <guro@fb•com>
Cc: <netdev@vger•kernel.org>, <linux-kernel@vger•kernel.org>,
	<kernel-team@fb•com>, <ast@kernel•org>, <daniel@iogearbox•net>,
	<kafai@fb•com>
Subject: Re: [PATCH net-next 3/5] bpftool: implement cgattach command
Date: Thu, 30 Nov 2017 19:13:53 -0800	[thread overview]
Message-ID: <20171130191353.3a46ff6e@cakuba.netronome.com> (raw)
In-Reply-To: <20171130134302.2840-4-guro@fb.com>

On Thu, 30 Nov 2017 13:43:00 +0000, Roman Gushchin wrote:
> +	attach_type = parse_attach_type(argv[2]);
> +	if (attach_type == __MAX_BPF_ATTACH_TYPE) {
> +		bpf_object__close(obj);
> +		close(prog_fd);
> +		close(cgroup_fd);
> +		p_err("Invalid attach type\n");
> +		return -1;
> +	}
> +
> +	if (bpf_prog_attach(prog_fd, cgroup_fd, attach_type, 0)) {
> +		bpf_object__close(obj);
> +		close(prog_fd);
> +		close(cgroup_fd);
> +		p_err("Failed to attach program");
> +		return -1;
> +	}
> +
> +	bpf_object__close(obj);
> +	close(prog_fd);
> +	close(cgroup_fd);
> +
> +	return 0;
> +}

Could you try to consolidate the error paths into a one larger handler
and use gotos to jump to it?  You can see it done in number of places,
grep for e.g. exit_free.

  parent reply	other threads:[~2017-12-01  3:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 13:42 [PATCH net-next 0/5] bpftool: cgroup bpf operations Roman Gushchin
2017-11-30 13:42 ` [PATCH net-next 1/5] libbpf: add ability to guess program type based on section name Roman Gushchin
2017-12-01 10:22   ` Quentin Monnet
2017-12-01 22:46     ` Jakub Kicinski
2017-12-04 12:34       ` Roman Gushchin
2017-12-04 13:12         ` Quentin Monnet
2017-12-04 13:22           ` Roman Gushchin
2017-11-30 13:42 ` [PATCH net-next 2/5] libbpf: prefer global symbols as bpf program name source Roman Gushchin
2017-11-30 13:43 ` [PATCH net-next 3/5] bpftool: implement cgattach command Roman Gushchin
2017-11-30 16:17   ` David Ahern
2017-11-30 16:44     ` Roman Gushchin
2017-11-30 16:24   ` David Ahern
2017-12-01  3:13   ` Jakub Kicinski [this message]
2017-11-30 13:43 ` [PATCH net-next 4/5] bpftool: implement cgdetach command Roman Gushchin
2017-12-01 10:26   ` Quentin Monnet
2017-11-30 13:43 ` [PATCH net-next 5/5] bpftool: implement cglist command Roman Gushchin
2017-12-01  3:04 ` [PATCH net-next 0/5] bpftool: cgroup bpf operations Jakub Kicinski
2017-12-01 17:06   ` Roman Gushchin

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=20171130191353.3a46ff6e@cakuba.netronome.com \
    --to=jakub.kicinski@netronome$(echo .)com \
    --cc=ast@kernel$(echo .)org \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=guro@fb$(echo .)com \
    --cc=kafai@fb$(echo .)com \
    --cc=kernel-team@fb$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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