From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet Subject: Re: [PATCH 3/4] ethdev: count devices consistently Date: Fri, 31 Mar 2017 11:13:27 +0200 Message-ID: <20170331091327.GU7450@bidouze.vm.6wind.com> References: <08811b2c92fa8c802a13000186aaebd5db5ee2ca.1488550937.git.gaetan.rivet@6wind.com> <2147239.2BbhZDoxjl@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: dev@dpdk.org To: Thomas Monjalon Return-path: Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by dpdk.org (Postfix) with ESMTP id 20B152B92 for ; Fri, 31 Mar 2017 11:13:37 +0200 (CEST) Received: by mail-lf0-f48.google.com with SMTP id j90so40442477lfk.2 for ; Fri, 31 Mar 2017 02:13:36 -0700 (PDT) Content-Disposition: inline In-Reply-To: <2147239.2BbhZDoxjl@xps13> 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 Thu, Mar 30, 2017 at 09:26:12PM +0200, Thomas Monjalon wrote: >2017-03-03 16:40, Gaetan Rivet: >> Make the rte_eth_dev_count() return the correct number of devices even >> after some are detached by the hotplug API. > >Please explain what is the correct number, >or that the wrong number was a max id. > will do. >> This change does not affect existing applications that do not use >> hotplug API calls. Those that do are already aware that port IDs are not >> necessarily contiguous. >[...] >> --- a/lib/librte_ether/rte_ethdev.h >> +++ b/lib/librte_ether/rte_ethdev.h >> -#define RTE_ETH_FOREACH_DEV(p) \ >> - for (p = rte_eth_find_next(0); \ >> - p < RTE_MAX_ETHPORTS; \ >> +#define RTE_ETH_FOREACH_DEV(p) \ >> + for (p = rte_eth_find_next(0); \ >> + (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \ >> p = rte_eth_find_next(p + 1)) > >This macro was introduced in previous patch. >Why adding the cast here? In the function rte_eth_dev_get_port_by_name(), the iterator is an int. When I introduced the use of the iterator there, I then realized that it would be better to allow users to use signed ints as well, to avoid unnecessary edits on their part. In retrospective, I agree that it would have been better in the previous patch. -- Gaëtan Rivet 6WIND