From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ob0-f176.google.com (mail-ob0-f176.google.com [209.85.214.176]) by dpdk.org (Postfix) with ESMTP id 3C1A6E6D for ; Wed, 10 Feb 2016 13:04:36 +0100 (CET) Received: by mail-ob0-f176.google.com with SMTP id wb13so23799084obb.1 for ; Wed, 10 Feb 2016 04:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=fTBt0uu7hOZBJGUZJ03muEH5kgQDpLZnhQc3WJgM+h4=; b=KzjecvHVirLLbWJ6dWRA5dkKDshzieMKp52rFdLv3yocdni2CcH0W+X2rS+91bQJR6 UJpgLTuJcx/DPX1wMSjklaeAZdnt8zhai0FERKSIRgRAvEfgOc2maa3hO78S+enOEZ/s kF96EOyxZbSCR+2xQl2+8PjK0G2xRbQGt6s01YrJ6eSUuc0b1+NTYxMAxkUour71M0t4 Uf15AEFiZHPayG8Cts57PDNyP9ipnZDYXCsSsrfyLXqda9vFtPjTDIUR4BuI7afFvVgi Aazj/xFsm2mQtpsi6lnJV8ocUX/bKJE7CBTjyb/ji0aOVp+a2OYk497q4xebaU9go0/A IXFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=fTBt0uu7hOZBJGUZJ03muEH5kgQDpLZnhQc3WJgM+h4=; b=iShPKrOi1RIXnqPZh4AEUmn2yjLFNN6evzIz2g3Pk1+LAU+jqozgDEtuf3gDJ/8rxV f0RDjF2OT1qEI1usqoc54x++jVasiTcH4OAAbKJZOPW0WEiC1hFLb9cjw1dehD/1W4I2 36Zyx95EaaAGyB6FhNDjxW10iXqMmihewWYnH8V9rgKlhnPIhbx7yLXFWPPuGgWujTEo Fh7PGpSWlXGvHJrsAzfoZ46sMHzI/nlXKZWzajmZnTBENwXX0WDNGXKZQo5WRr5KKxLb eLLdGV3wra6jGTxzh1AlAvqqnPH4HMR0m3w8b4WnHUex7Opm0c7qPd4WMB7yxc4JjLia 7DNQ== X-Gm-Message-State: AG10YOQUk7cwqdz79m6b6wuucOuwMpzOX2MH1cjwkr4KVn0TK5yb1EZA7QziMCUk0LPLovM6VeOVwPWNiu99Kzf/ X-Received: by 10.60.117.137 with SMTP id ke9mr37330816oeb.16.1455105875730; Wed, 10 Feb 2016 04:04:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.76.180.72 with HTTP; Wed, 10 Feb 2016 04:04:16 -0800 (PST) In-Reply-To: <20160210121020.7389c33f@pcviktorin.fit.vutbr.cz> References: <1454076516-21591-1-git-send-email-david.marchand@6wind.com> <1454076516-21591-8-git-send-email-david.marchand@6wind.com> <20160210121020.7389c33f@pcviktorin.fit.vutbr.cz> From: David Marchand Date: Wed, 10 Feb 2016 13:04:16 +0100 Message-ID: To: Jan Viktorin Content-Type: text/plain; charset=UTF-8 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 7/9] pci: add a helper for device name 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: Wed, 10 Feb 2016 12:04:36 -0000 On Wed, Feb 10, 2016 at 12:10 PM, Jan Viktorin wrote: > On Fri, 29 Jan 2016 15:08:34 +0100 > David Marchand wrote: > >> eal is a better place than ethdev for naming resources. >> Add a helper here, and make use of it in ethdev hotplug code. >> >> Signed-off-by: David Marchand >> --- >> lib/librte_eal/common/include/rte_pci.h | 28 ++++++++++++++++++++++++++++ >> lib/librte_ether/rte_ethdev.c | 22 ++-------------------- >> 2 files changed, 30 insertions(+), 20 deletions(-) >> >> diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h >> index 334c12e..9edd5f5 100644 >> --- a/lib/librte_eal/common/include/rte_pci.h >> +++ b/lib/librte_eal/common/include/rte_pci.h >> @@ -309,6 +309,34 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) >> } >> #undef GET_PCIADDR_FIELD >> >> +/** >> + * Utility function to write a pci device name, this device name can later be >> + * used to retrieve the corresponding rte_pci_addr using above functions. >> + * >> + * @param addr >> + * The PCI Bus-Device-Function address >> + * @param output >> + * The output buffer string >> + * @param size >> + * The output buffer size >> + * @return >> + * 0 on success, negative on error. >> + */ >> +static inline int >> +eal_pci_device_name(const struct rte_pci_addr *addr, >> + char *output, int size) > > "size_t size" (or unsigned int) seems to be better to me. Yes. > >> +{ >> + int ret; >> + >> + ret = snprintf(output, size, PCI_PRI_FMT, >> + addr->domain, addr->bus, >> + addr->devid, addr->function); >> + if (ret < 0 || ret >= size) >> + return -1; > > The return value is not checked (below). I think, such functions > are usually missing error checking as nobody expects them to fail. > Wouldn't it be better to panic here? assert or panic, yes. -- David Marchand