From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2C32F20E98; Thu, 10 May 2018 17:53:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 10 May 2018 17:53:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=9YRXiVwoFhlDJzzt+Hx17zPp1I XNdwrYsdvTzJvOc+I=; b=guGCaYqEM4fALqgPc7B9dY2MhQh82FSNHKBTeTdiBH dVJ621+EOby4HXEVxuJLc0BZnDXDapeUz5zFBOZFaN/ozySboMcwdq0OM47xa635 tAW+Zk3FDBfBjeSrxdeqFMdIiBOcDktFs8CXUL8K741CpDed401nCB5s9ctYCuCu s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=9YRXiV woFhlDJzzt+Hx17zPp1IXNdwrYsdvTzJvOc+I=; b=S4HiTRwKI22jd1zXVmn7oj ZGdSM5liFQzII2Q/NryMqh/a3cNjAbU9XDDwnfH9bv5BEDpQrJglkfeYHyCSRbUG fcQreiPeQI4nKypbWayd9rixi4MMLsiRG9QmioP0gm1u6WNyi63Qgjcdp9QVazoL o1D2KQMa9VRZepSpSBfFbW7yG28IeiAEIpfz//jZ52AqZri+i5XPpL4y/zeBKdqe dq95nbR4XJA2ekbNm+3a+9XiNQngAqkuTAl9hGnVnMz3hJnWscbJSew32P2KcQQl YB8z96egmYBfVBf89DHund37vjOTcvXflLE5/roVo47mJrdfjBmYPKaWHF75Z1Mg == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 74842E43E8; Thu, 10 May 2018 17:53:42 -0400 (EDT) From: Thomas Monjalon To: Stephen Hemminger Cc: dev@dpdk.org, Matan Azrad Date: Thu, 10 May 2018 23:53:41 +0200 Message-ID: <1586686.NZVuy3NJE0@xps> In-Reply-To: <20180510132646.5aeb3467@xeon-e3> References: <20180509094337.26112-1-thomas@monjalon.net> <20180509094337.26112-7-thomas@monjalon.net> <20180510132646.5aeb3467@xeon-e3> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH 06/11] ethdev: allow ownership operations on unused port 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, 10 May 2018 21:53:43 -0000 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".