From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: Re: [PATCH 7/9] pci: add a helper for device name Date: Wed, 10 Feb 2016 13:04:16 +0100 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: "dev@dpdk.org" To: Jan Viktorin 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) In-Reply-To: <20160210121020.7389c33f@pcviktorin.fit.vutbr.cz> 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, 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