From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by dpdk.org (Postfix) with ESMTP id 07A4CDE3 for ; Mon, 12 Jun 2017 12:31:53 +0200 (CEST) Received: by mail-pg0-f68.google.com with SMTP id v14so13950049pgn.1 for ; Mon, 12 Jun 2017 03:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xasVoE3E+BEBUlglfzAvAegcg5TEBEGcuFnXSR+B3yw=; b=fC/QrN0iuTxcPk4JEiINLN0fY5iGbJ5mkFIAm72lHz1AUatub0vaOQ22yqVzhn1VD5 WiCu+mTLbZfuel9EMtqjxayGe7hVFYPW8jGefUrhsOz9eiGJIgZAMSkjOHQyVXBmtfTT SNJwucffnn7BytNqG0r1JIdnRGiTh9I7pSfF24zyRGs44CQNzdBeIvdTtK8xngGx4jE5 fDdfm0AyjCsddB6eQ7eb90Hn03hFBB+0iXsJ5EwCOcHrNB05+3hVjwwOAa0ieJPiUrKn pZIZmy5OR7FBt2uDltOdfIx3BoTp/258R6wdnuHoLW9H8c4ZTjQV0/HaUJFmyBWiGtYy YPZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xasVoE3E+BEBUlglfzAvAegcg5TEBEGcuFnXSR+B3yw=; b=lerjrWHJ25nkX1ZuQhjAG2/BKJ3rdThQ9dRjiuelcgV+BFStcd5v2tY1cNANHRpKPz KssgA34d2kFDOZSzTpb5tlVo56+kxtkc4Xgj8iSVlxQNC0pDKPXyAUm0w1ukG5sZuk9F YKL3k3Jsg9LfxXaKrtJhc7Wu1Nnq9DQZ6J3wY8SdeVevz8bBnUAgFhQ9AkInaRmOCk1z PbXOhM6qgcpSZMc1hDWquHJFLCheAdAZrheNJnMwEHLFdNT02wngOPRPLDclB/afZTj5 W761jUGFuOzm6l4OjFbWXIPWCwrd/zVpsbOo/dBiKE+9C3kZeASZo0W/sWAdkTrKBtRy sZDg== X-Gm-Message-State: AODbwcDvRLQmjsKC8SH/usprXa8Lk4zyg54gUbQ1mB/8KaXoz23B9Lsn X6x9VWxW1wCXbRPZP071Lg== X-Received: by 10.101.76.79 with SMTP id l15mr57324065pgr.86.1497263512812; Mon, 12 Jun 2017 03:31:52 -0700 (PDT) Received: from yliu-home ([45.63.61.64]) by smtp.gmail.com with ESMTPSA id g86sm18277230pfe.116.2017.06.12.03.31.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 03:31:51 -0700 (PDT) Date: Mon, 12 Jun 2017 18:31:45 +0800 From: Yuanhan Liu To: Brian Russell Cc: Maxime Coquelin , dev@dpdk.org Message-ID: <20170612103145.GB2611@yliu-home> References: <1496677473-17893-1-git-send-email-brussell@brocade.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1496677473-17893-1-git-send-email-brussell@brocade.com> User-Agent: Mutt/1.6.1 (2016-04-27) Subject: Re: [dpdk-dev] [PATCH] virtio: fix PCI config err handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jun 2017 10:31:54 -0000 On Mon, Jun 05, 2017 at 04:44:33PM +0100, Brian Russell wrote: > In virtio_read_caps, rte_pci_read_config returns the number of bytes > read from PCI config or <0 on error. > If less than the expected number of bytes are read then log the > failure and return rather than carrying on with garbage. > > Signed-off-by: Brian Russell > --- > drivers/net/virtio/virtio_pci.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c > index b7b3d61..90c098e 100644 > --- a/drivers/net/virtio/virtio_pci.c > +++ b/drivers/net/virtio/virtio_pci.c > @@ -592,16 +592,18 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) > } > > ret = rte_pci_read_config(dev, &pos, 1, PCI_CAPABILITY_LIST); > - if (ret < 0) { > - PMD_INIT_LOG(DEBUG, "failed to read pci capability list"); > + if (ret != 1) { > + PMD_INIT_LOG(DEBUG, > + "failed to read pci capability list, ret %d", ret); > return -1; > } There are two things worth mentioning: - rte_pci.h states nothing about the return value - The BSD implementation actually returns 0 on success, while the Linux implementation indeed returns the bytes read. --yliu