From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EBBB1A0352; Thu, 16 Jan 2020 13:27:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1ACBE1C2F7; Thu, 16 Jan 2020 13:27:13 +0100 (CET) Received: from incedge.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 087F11BFDB for ; Thu, 16 Jan 2020 13:27:10 +0100 (CET) X-ASG-Debug-ID: 1579177627-0a3dd17c8916f00001-TfluYd Received: from mail.chinasoftinc.com (inccas001.ito.icss [10.168.0.51]) by incedge.chinasoftinc.com with ESMTP id puGdpk4nDEtDvl07 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 16 Jan 2020 20:27:07 +0800 (CST) X-Barracuda-Envelope-From: huwei013@chinasoftinc.com X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.51 X-ASG-Whitelist: Client Received: from localhost.localdomain (203.160.91.226) by INCCAS001.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.439.0; Thu, 16 Jan 2020 20:27:07 +0800 From: "Wei Hu (Xavier)" X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.60 To: Date: Thu, 16 Jan 2020 20:27:03 +0800 X-ASG-Orig-Subj: [PATCH] ethdev: move non null judgment of ops function pointer ahead Message-ID: <20200116122703.9199-1-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [203.160.91.226] X-Barracuda-Connect: inccas001.ito.icss[10.168.0.51] X-Barracuda-Start-Time: 1579177627 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://spam.chinasoftinc.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at chinasoftinc.com X-Barracuda-Scan-Msg-Size: 1588 Subject: [dpdk-dev] [PATCH] ethdev: move non null judgment of ops function pointer ahead 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Wei Hu (Xavier)" This patch moves the following judgement statement to the first half of the function named rte_eth_dev_set_vlan_offload, so we can avoid changing the content of dev->data->dev_conf.rxmode.offloads even when the pointer named dev->dev_ops->vlan_offload_set is NULL: RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chunsong Feng Signed-off-by: Min Wang (Jushui) Signed-off-by: Min Hu (Connor) --- lib/librte_ethdev/rte_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index aec2d0f70..21f24cd7f 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3257,6 +3257,7 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); /* save original values in case of failure */ orig_offloads = dev->data->dev_conf.rxmode.offloads; @@ -3307,7 +3308,6 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) if (mask == 0) return ret; - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); ret = (*dev->dev_ops->vlan_offload_set)(dev, mask); if (ret) { /* hit an error restore original values */ -- 2.23.0