From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id 9CDF5A0096
	for <public@inbox.dpdk.org>; Thu, 14 Mar 2019 12:13:15 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 955773572;
	Thu, 14 Mar 2019 12:13:14 +0100 (CET)
Received: from EUR03-DB5-obe.outbound.protection.outlook.com
 (mail-eopbgr40076.outbound.protection.outlook.com [40.107.4.76])
 by dpdk.org (Postfix) with ESMTP id 9DD4C1E2F
 for <dev@dpdk.org>; Thu, 14 Mar 2019 12:13:12 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=Md4gNR7E3ND9gUM7+KZPORxx0cSL76j37+PIOw4gUqI=;
 b=L8qXrsIeJoiLA4Ov0DrAoQHxSFTVu1FsfuW0wPe02hrQ1hy53s1VEVmCd7Ui9H7QUgQ8re5jv6DtMSGeNtYAMK2CB2vFZMHAk4zNmDM3s3Otr41PwlL2Rm5XfANfPElA2guynyckeW6J8fi4xw6+tIUq0XYex9IZ0rdp9WWEVbc=
Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.39.139) by
 AM0PR0502MB3700.eurprd05.prod.outlook.com (52.133.44.154) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1709.13; Thu, 14 Mar 2019 11:13:11 +0000
Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com
 ([fe80::3cdc:e13a:204e:67a6]) by AM0PR0502MB4019.eurprd05.prod.outlook.com
 ([fe80::3cdc:e13a:204e:67a6%2]) with mapi id 15.20.1686.021; Thu, 14 Mar 2019
 11:13:11 +0000
From: Matan Azrad <matan@mellanox.com>
To: Stephen Hemminger <stephen@networkplumber.org>
CC: "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [PATCH] net/vdev_netvsc: fix erronous cast
Thread-Index: AQHU2UJIwXDADuylJE+441t89eFYIaYK+npg
Date: Thu, 14 Mar 2019 11:13:10 +0000
Message-ID:
 <AM0PR0502MB4019F2341956C5FE4D7C409FD24B0@AM0PR0502MB4019.eurprd05.prod.outlook.com>
References: <20190313021253.525-1-stephen@networkplumber.org>
In-Reply-To: <20190313021253.525-1-stephen@networkplumber.org>
Accept-Language: en-US, he-IL
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=matan@mellanox.com; 
x-originating-ip: [193.47.165.251]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 922a9413-2378-43e8-39bd-08d6a86e0b61
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: BCL:0; PCL:0;
 RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);
 SRVR:AM0PR0502MB3700; 
x-ms-traffictypediagnostic: AM0PR0502MB3700:
x-microsoft-antispam-prvs: <AM0PR0502MB370059241A61E4A5315DBE3BD24B0@AM0PR0502MB3700.eurprd05.prod.outlook.com>
x-forefront-prvs: 09760A0505
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(39860400002)(376002)(346002)(366004)(396003)(136003)(189003)(199004)(106356001)(8936002)(105586002)(76176011)(7696005)(229853002)(66066001)(11346002)(52536014)(476003)(3846002)(6916009)(99286004)(5660300002)(186003)(6506007)(6436002)(55016002)(53936002)(68736007)(446003)(86362001)(97736004)(2906002)(81166006)(6116002)(25786009)(8676002)(4326008)(81156014)(102836004)(9686003)(256004)(316002)(71190400001)(71200400001)(26005)(7736002)(74316002)(486006)(305945005)(14454004)(478600001)(33656002)(6246003);
 DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3700;
 H:AM0PR0502MB4019.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en;
 PTR:InfoNoRecords; MX:1; A:1; 
received-spf: None (protection.outlook.com: mellanox.com does not designate
 permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam-message-info: iK5QzMWiNLCjyf8oSK4PEK1zELKxjaqKaXv/vTvBBXm2voXhZi9m+boDIUbfo5+DCIJXiK6PQSdWR1NTR+mUZ7bjROxYaveYchVNzgXUV4brxNIeKWZ9Z8KRBjoZB3YBFESrgePIUJTOP0H6W3XcMmCrKfVnwITrI2KeNNyjcGg5Dg859hT4ly5l1nOyu8O9hEyjiLI/l8cas7okW9q2IZzVJB7NQbGHDmo670rXIL9cZrhuEurw1/cgxDUIRHLONqTQZLCjWkEDdlmWg4H9ulNxG539uUZvilKbRK5Az68UEMmW9omIv7D3UKoqKLrvm55N5vIM8QRH5P4YJczjy7wDcE7RG7LnmGnnvXu1lKsqfYpIPzoiARzaxEmAtJacCGQ9froaFm008jyXC8tDRrWEQsVND6lWfrYP9GeEPp4=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: Mellanox.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 922a9413-2378-43e8-39bd-08d6a86e0b61
X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Mar 2019 11:13:10.8662 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3700
Subject: Re: [dpdk-dev] [PATCH] net/vdev_netvsc: fix erronous cast
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Message-ID: <20190314111310.41LEEYJ4b5-OrSRH8WetIsqHamit1TaGP4Wx0NPGISE@z>

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 che=
ckers
> might find a bug here.
>=20

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(-)
>=20
> 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 =3D rte_bus_find_by_name("vdev");
>=20
> @@ -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 =3D (struct rte_vdev_device *)vbus->find_device(NULL,
> -		vdev_netvsc_cmp_rte_device,
> VDEV_NETVSC_DRIVER_NAME);
> +
> +	dev =3D 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