From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH 2/7] ethdev: reduce goto's in attach/detach Date: Tue, 10 Jan 2017 09:40:46 +0100 Message-ID: <29688688.OdmTMFx9gs@xps13> References: <20170109233022.31154-1-stephen@networkplumber.org> <20170109233022.31154-3-stephen@networkplumber.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org To: Stephen Hemminger Return-path: Received: from mail-wj0-f179.google.com (mail-wj0-f179.google.com [209.85.210.179]) by dpdk.org (Postfix) with ESMTP id 194B420F for ; Tue, 10 Jan 2017 09:40:48 +0100 (CET) Received: by mail-wj0-f179.google.com with SMTP id kq3so32785308wjc.0 for ; Tue, 10 Jan 2017 00:40:48 -0800 (PST) In-Reply-To: <20170109233022.31154-3-stephen@networkplumber.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Stephen, Please use --in-reply-to to keep v1 and v2 in the same thread. Comment below 2017-01-09 15:30, Stephen Hemminger: > 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) > + return ret; As commented on v1 by Ferruh and I, you should check also positive value. > > 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); > }