From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752260AbdLADOA (ORCPT ); Thu, 30 Nov 2017 22:14:00 -0500 Received: from mail-pg0-f42.google.com ([74.125.83.42]:33447 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbdLADN6 (ORCPT ); Thu, 30 Nov 2017 22:13:58 -0500 X-Google-Smtp-Source: AGs4zMbcSp6FdA0CtzvJLhNbAk9kRVPICG79QURNvSQer3uAgJDA30NyjnlpMR5ZHm7+YM3q3b3jDw== Date: Thu, 30 Nov 2017 19:13:53 -0800 From: Jakub Kicinski To: Roman Gushchin Cc: , , , , , Subject: Re: [PATCH net-next 3/5] bpftool: implement cgattach command Message-ID: <20171130191353.3a46ff6e@cakuba.netronome.com> In-Reply-To: <20171130134302.2840-4-guro@fb.com> References: <20171130134302.2840-1-guro@fb.com> <20171130134302.2840-4-guro@fb.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.