From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 06EEB106A for ; Thu, 8 Dec 2016 11:25:09 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 08 Dec 2016 02:25:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,318,1477983600"; d="scan'208";a="1069535068" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.29]) ([10.237.220.29]) by orsmga001.jf.intel.com with ESMTP; 08 Dec 2016 02:25:08 -0800 To: Stephen Hemminger , dev@dpdk.org References: <20161208014751.24285-1-stephen@networkplumber.org> <20161208014751.24285-2-stephen@networkplumber.org> From: Ferruh Yigit Message-ID: <4179dac2-f433-ca40-2f4f-235abab77c6c@intel.com> Date: Thu, 8 Dec 2016 10:25:07 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161208014751.24285-2-stephen@networkplumber.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 1/2] eth: get rid of goto's in rte_eth_dev_detach X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2016 10:25:10 -0000 On 12/8/2016 1:47 AM, Stephen Hemminger wrote: > Extra goto's to just a return are unnecessary. > > Signed-off-by: Stephen Hemminger > --- > lib/librte_ether/rte_ethdev.c | 21 +++++++-------------- > 1 file changed, 7 insertions(+), 14 deletions(-) > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c > index 4209ad0..40c7cc6 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -466,27 +466,20 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id) > int > rte_eth_dev_detach(uint8_t port_id, char *name) > { > - int ret = -1; > + int ret; > > - if (name == NULL) { > - ret = -EINVAL; > - goto err; > - } > + if (name == NULL) > + return -EINVAL; > > /* FIXME: move this to eal, once device flags are relocated there */ > - if (rte_eth_dev_is_detachable(port_id)) > - goto err; > + ret = rte_eth_dev_is_detachable(port_id); > + if (ret < 0) rte_eth_dev_is_detachable() can return 1 to indicate device is not detachable. > + return ret; > > snprintf(name, sizeof(rte_eth_devices[port_id].data->name), > "%s", rte_eth_devices[port_id].data->name); > - ret = rte_eal_dev_detach(name); > - if (ret < 0) > - goto err; > > - return 0; > - > -err: > - return ret; > + return rte_eal_dev_detach(name); > } > > static int >