From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH 06/11] ethdev: allow ownership operations on unused port Date: Thu, 10 May 2018 23:53:41 +0200 Message-ID: <1586686.NZVuy3NJE0@xps> References: <20180509094337.26112-1-thomas@monjalon.net> <20180509094337.26112-7-thomas@monjalon.net> <20180510132646.5aeb3467@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, Matan Azrad To: Stephen Hemminger Return-path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 847451BA97 for ; Thu, 10 May 2018 23:53:43 +0200 (CEST) In-Reply-To: <20180510132646.5aeb3467@xeon-e3> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 10/05/2018 22:26, Stephen Hemminger: > On Wed, 9 May 2018 11:43:32 +0200 > Thomas Monjalon wrote: > > > - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + if (port_id >= RTE_MAX_ETHPORTS || ethdev->data->name[0] == '\0') { > > Since name being empty now has significance, why not introduce an macro or inline function > to make the test. Also, static checkers don't like pointers which maybe outside valid > range (sometimes). > > static inline bool rte_ethdev_is_unused(const struct rte_ethdev *ethdev) > { > return ethdev->data->name[0] == '\0'; > } > > #define RTE_ETH_UNUSED_OR_ERR_RET(ethdev, retval) do { \ > if (!rte_ethdev_is_unused(ethdev)) { \ > RTE_PMD_DEBUG_TRACE("Port already in use=%d\n", ethdev->port_id); \ > return retval; \ > } } while(0) Yes we can have a static function for this check. The name should be "ethdev_is_allocated".