DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] net/vdev_netvsc: fix erronous cast
Date: Thu, 14 Mar 2019 11:13:10 +0000	[thread overview]
Message-ID: <AM0PR0502MB4019F2341956C5FE4D7C409FD24B0@AM0PR0502MB4019.eurprd05.prod.outlook.com> (raw)
Message-ID: <20190314111310.41LEEYJ4b5-OrSRH8WetIsqHamit1TaGP4Wx0NPGISE@z> (raw)
In-Reply-To: <20190313021253.525-1-stephen@networkplumber.org>

Hi

From: Stephen Hemminger
> The return value from bus->find_device is a rte_device which is not safe to
> cast to a rte_vdev_device structure.
> It doesn't really matter since only being checked for NULL but static checkers
> might find a bug here.
> 

Fix line is missing.

> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/net/vdev_netvsc/vdev_netvsc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c
> b/drivers/net/vdev_netvsc/vdev_netvsc.c
> index ba63fac2a598..801f54c96e01 100644
> --- a/drivers/net/vdev_netvsc/vdev_netvsc.c
> +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
> @@ -808,7 +808,7 @@ vdev_netvsc_cmp_rte_device(const struct
> rte_device *dev1,  static void  vdev_netvsc_scan_callback(__rte_unused
> void *arg)  {
> -	struct rte_vdev_device *dev;
> +	struct rte_device *dev;
>  	struct rte_devargs *devargs;
>  	struct rte_bus *vbus = rte_bus_find_by_name("vdev");
> 
> @@ -816,8 +816,9 @@ vdev_netvsc_scan_callback(__rte_unused void *arg)
>  		if (!strncmp(devargs->name, VDEV_NETVSC_DRIVER_NAME,
>  			     VDEV_NETVSC_DRIVER_NAME_LEN))
>  			return;
> -	dev = (struct rte_vdev_device *)vbus->find_device(NULL,
> -		vdev_netvsc_cmp_rte_device,
> VDEV_NETVSC_DRIVER_NAME);
> +
> +	dev = vbus->find_device(NULL, vdev_netvsc_cmp_rte_device,
> +				VDEV_NETVSC_DRIVER_NAME);

Since the device must be vdev here,
It is better to use explicit cast to make the checker happy.

>  	if (dev)
>  		return;
>  	if (rte_devargs_add(RTE_DEVTYPE_VIRTUAL,
> VDEV_NETVSC_DRIVER_NAME))
> --
> 2.17.1


  reply	other threads:[~2019-03-14 11:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  2:12 Stephen Hemminger
2019-03-14 11:13 ` Matan Azrad [this message]
2019-03-14 11:13   ` Matan Azrad
2019-03-14 15:44   ` Stephen Hemminger
2019-03-14 15:44     ` Stephen Hemminger
2019-03-17  6:16     ` Matan Azrad
2019-03-17  6:16       ` Matan Azrad
2019-03-25 13:51       ` Ferruh Yigit
2019-03-25 13:51         ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM0PR0502MB4019F2341956C5FE4D7C409FD24B0@AM0PR0502MB4019.eurprd05.prod.outlook.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).