From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=VOaZtuPg7L12skJQBl5iB5uCNm02BgMRhCYgs0Xs59o=; b=NSTdCrWzt6RpR/BWARQaSG+ONK9iQj2pc4+cNXRcpRgzTQncpKTrq2QaSOsrt4sn/9 WPpyaEYAHOsHyDSXdiTM3nVJkl23E5D5bvps8zIpgZswIet7XBIa8rSv2TMkyvw93AM2 NqgFvxYM0khMmsHyJdVHJ6RbLaYqy9DoRlKvjQ0Ji215HIP5ljBdKupXiD5+WDQDt1Nx pY4rHbjCzicNUi4quUruUjYlv4GntRDCZFSKlKK7sMXR8atSBflXWG4LuLlI8SZ0IDYJ ugQUBQdpoDdROEKB8D8aSgvdbj8MyaV/oKgEWqjupCYlRi0Y7bruslTn1m/BHHNRWKRe 69ew== X-Gm-Message-State: ALoCoQk+V/pYq0vvLVWcKIeL338o90WpWYw9zGDBa8PdvvBsJp5/tz+4ye2OBPYFET5XT4HEbPbC X-Received: by 10.42.144.131 with SMTP id b3mr43404426icv.35.1435239870427; Thu, 25 Jun 2015 06:44:30 -0700 (PDT) Received: from uryu.home.lan ([144.160.5.83]) by mx.google.com with ESMTPSA id i185sm19621470ioi.24.2015.06.25.06.44.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 06:44:30 -0700 (PDT) Date: Thu, 25 Jun 2015 09:44:27 -0400 From: Stephen Hemminger To: Liang-Min Larry Wang Message-ID: <20150625094427.4cf32009@uryu.home.lan> In-Reply-To: <1434579735-15496-2-git-send-email-liang-min.wang@intel.com> 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> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v7 1/4] ethdev: add apis to support access device info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jun 2015 13:44:31 -0000 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??