From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v7 1/4] ethdev: add apis to support access device info Date: Thu, 25 Jun 2015 09:44:27 -0400 Message-ID: <20150625094427.4cf32009@uryu.home.lan> References: <1432946276-9424-1-git-send-email-liang-min.wang@intel.com> <1434579735-15496-1-git-send-email-liang-min.wang@intel.com> <1434579735-15496-2-git-send-email-liang-min.wang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Liang-Min Larry Wang Return-path: Received: from mail-ig0-f173.google.com (mail-ig0-f173.google.com [209.85.213.173]) by dpdk.org (Postfix) with ESMTP id E5406C628 for ; Thu, 25 Jun 2015 15:44:30 +0200 (CEST) Received: by igbqq3 with SMTP id qq3so14833005igb.0 for ; Thu, 25 Jun 2015 06:44:30 -0700 (PDT) In-Reply-To: <1434579735-15496-2-git-send-email-liang-min.wang@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 17 Jun 2015 18:22:12 -0400 Liang-Min Larry Wang wrote: > +int > +rte_eth_dev_reg_length(uint8_t port_id) > +{ > + struct rte_eth_dev *dev; > + > + if ((dev= &rte_eth_devices[port_id]) == NULL) { > + PMD_DEBUG_TRACE("Invalid port device\n"); > + return -ENODEV; > + } Some minor nits: * for consistency you should add valid port check here. * style: - don't do assignment in if() unless it really helps readability - need whitespace if (!rte_eth_dev_is_valid_port(portid)) { PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); return -ENODEV; } dev = &rte_eth_devices[port_id]; if (dev == NULL) { PMD_DEBUG("Invalid port device\n"); return -ENODEV: } ... This code pattern is so common it really should be a function. dev = rte_eth_dev_get(port_id); if (dev == NULL) { PMD_DEBUG("Invalid port device\n"); return -ENODEV; } And then add a macro to generate this??