From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 06/11] ethdev: allow ownership operations on unused port Date: Thu, 10 May 2018 13:26:46 -0700 Message-ID: <20180510132646.5aeb3467@xeon-e3> References: <20180509094337.26112-1-thomas@monjalon.net> <20180509094337.26112-7-thomas@monjalon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, Matan Azrad , stable@dpdk.org To: Thomas Monjalon Return-path: Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by dpdk.org (Postfix) with ESMTP id 32FCE1B74B for ; Thu, 10 May 2018 22:26:54 +0200 (CEST) Received: by mail-pg0-f68.google.com with SMTP id n9-v6so1438979pgq.5 for ; Thu, 10 May 2018 13:26:54 -0700 (PDT) In-Reply-To: <20180509094337.26112-7-thomas@monjalon.net> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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)