[dpdk-dev] [PATCH 3/4] virtio: return 1 to tell the upper layer we don't take over this device
Xie, Huawei
huawei.xie at intel.com
Mon Dec 28 06:38:20 CET 2015
> -----Original Message-----
> From: Yuanhan Liu [mailto:yuanhan.liu at linux.intel.com]
> Sent: Monday, December 28, 2015 1:25 PM
> To: Xie, Huawei
> Cc: dev at dpdk.org; Jayakumar, Muthurajan; Troitsky, Nikita;
> peterx at redhat.com; stephen at networkplumber.org;
> Changchun.ouyang at hotmail.com; thomas.monjalon at 6wind.com
> Subject: Re: [PATCH 3/4] virtio: return 1 to tell the upper layer we
> don't take over this device
>
> On Fri, Dec 25, 2015 at 02:38:11AM +0800, Huawei Xie wrote:
> > if virtio_resource_init fails, cleanup the resource and return 1 to
> > tell the upper layer we don't take over this device.
> > return -1 means error and DPDK will exit.
> >
> > Signed-off-by: Huawei Xie <huawei.xie at intel.com>
> > ---
> > drivers/net/virtio/virtio_ethdev.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> > index d928339..00015ef 100644
> > --- a/drivers/net/virtio/virtio_ethdev.c
> > +++ b/drivers/net/virtio/virtio_ethdev.c
> > @@ -1287,8 +1287,12 @@ eth_virtio_dev_init(struct rte_eth_dev
> *eth_dev)
> >
> > pci_dev = eth_dev->pci_dev;
> >
> > - if (virtio_resource_init(pci_dev) < 0)
> > - return -1;
> > + /* Return 1 to tell the upper layer we don't take over this
> device. */
> > + if (virtio_resource_init(pci_dev) < 0) {
> > + rte_free(eth_dev->data->mac_addrs);
> > + eth_dev->data->mac_addrs = NULL;
>
> This assignment looks unnecessary to me.
>
Noted this when write this code. It is ok not to reset as this layer is responsible for all the allocation/free.
>
> And, I think above comment is better to put here, right above the
> return
> statement.
>
> > + return 1;
> > + }
>
> --yliu
More information about the dev
mailing list