[RFC,10/12] ethdev: add cast for bus_device

Message ID 20190409190630.31975-11-vivkong@ca.ibm.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series introduce s390x architecture |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Vivian Kong April 9, 2019, 7:06 p.m. UTC
  Signed-off-by: Vivian Kong <vivkong@ca.ibm.com>
---
 lib/librte_ethdev/rte_ethdev_pci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon April 9, 2019, 8:14 p.m. UTC | #1
09/04/2019 21:06, Vivian Kong:
> Signed-off-by: Vivian Kong <vivkong@ca.ibm.com>
> ---
>  static inline int
>  eth_dev_pci_specific_init(struct rte_eth_dev *eth_dev, void *bus_device) {
> -	struct rte_pci_device *pci_dev = bus_device;
> +	struct rte_pci_device *pci_dev = (struct rte_pci_device *) bus_device;

Why do we need such cast?
  
Stephen Hemminger April 10, 2019, 2:41 a.m. UTC | #2
On Tue, 09 Apr 2019 22:14:08 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> 09/04/2019 21:06, Vivian Kong:
> > Signed-off-by: Vivian Kong <vivkong@ca.ibm.com>
> > ---
> >  static inline int
> >  eth_dev_pci_specific_init(struct rte_eth_dev *eth_dev, void *bus_device) {
> > -	struct rte_pci_device *pci_dev = bus_device;
> > +	struct rte_pci_device *pci_dev = (struct rte_pci_device *) bus_device;  
> 
> Why do we need such cast?
> 
> 

I agree with Thomas, we try to avoid extra casts and there is even
a script to find them.
  
Vivian Kong April 10, 2019, 5:10 p.m. UTC | #3
Hmm...we weren't able to compile without the cast.  I'll take a closer
look.  Thanks.

Regards,

Vivian Kong
Linux on IBM Z Open Source Ecosystem
IBM Canada Toronto Lab

Thomas Monjalon <thomas@monjalon.net> wrote on 2019/04/09 04:14:08 PM:

> From: Thomas Monjalon <thomas@monjalon.net>
> To: vivkong@ca.ibm.com
> Cc: dev@dpdk.org
> Date: 2019/04/09 04:14 PM
> Subject: Re: [dpdk-dev] [RFC 10/12] ethdev: add cast for bus_device
>
> 09/04/2019 21:06, Vivian Kong:
> > Signed-off-by: Vivian Kong <vivkong@ca.ibm.com>
> > ---
> >  static inline int
> >  eth_dev_pci_specific_init(struct rte_eth_dev *eth_dev, void
*bus_device) {
> > -   struct rte_pci_device *pci_dev = bus_device;
> > +   struct rte_pci_device *pci_dev = (struct rte_pci_device *)
bus_device;
>
> Why do we need such cast?
>
>
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
index 23257e986..80bd120b9 100644
--- a/lib/librte_ethdev/rte_ethdev_pci.h
+++ b/lib/librte_ethdev/rte_ethdev_pci.h
@@ -72,7 +72,7 @@  rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev,
 
 static inline int
 eth_dev_pci_specific_init(struct rte_eth_dev *eth_dev, void *bus_device) {
-	struct rte_pci_device *pci_dev = bus_device;
+	struct rte_pci_device *pci_dev = (struct rte_pci_device *) bus_device;
 
 	if (!pci_dev)
 		return -ENODEV;