eal/headers: explicitly cast void * to type *
PATCH 1/1 eal/headers: explicitly cast void * to type *
Explicitly cast void * to type * so that eal headers may be compiled as C or C++.
--- lib/librte_eal/windows/include/rte_os.h | 2 +- lib/librte_ethdev/rte_ethdev_pci.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/windows/include/rte_os.h +1 -1
@@ -86,7 +86,7 @@ asprintf(char **buffer, const char *format, ...)return -1 ; size++; - *buffer =malloc (size); + *buffer = (char *)malloc (size);if (*buffer ==NULL )return -1 ;
lib/librte_ethdev/rte_ethdev_pci.h +1 -1
@@ -47,7 +47,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 ;
Signature · 1 line
2.29.0.vfs.0.0
Quoted 2 lines · Tyler Retzlaff
Explicitly cast void * to type * so that eal headers may be compiled as C or C++.
Topic should probably be "eal/windows".
Quoted 2 lines
Signed-off-by Tyler Retzlaff <[email protected]>---
[...]
lib/librte_ethdev/rte_ethdev_pci.h rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, · line 53
Quoted 13 lines
lib/librte_ethdev/rte_ethdev_pci.h +1
-1@@ -47,7 +47,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 ;
This is a private header, it's never exposed---why the change is needed (not that I have a strong opinion, though)?
Quoted 5 lines · Dmitry Kozlyuk
Quoted 2 lines · Tyler Retzlaff
Explicitly cast void * to type * so that eal headers may be compiled as C or C++.
Topic should probably be "eal/windows".
i'll submit a new rev that changes this, it's not really windows specific but i guess windows is the only people crazy enough to use c++.
Quoted 3 lines
Fixes e8428a9d89f1 ("eal/windows: add some basic functions and macros")
yep, will do thanks.
Quoted 15 lines
Quoted 3 lines
Signed-off-by Tyler Retzlaff <[email protected]>---
[...]
Quoted 11 lines
lib/librte_ethdev/rte_ethdev_pci.h +1
-1@@ -47,7 +47,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;
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_pci.h rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, · line 53
Quoted 2 lines
lib/librte_ethdev/rte_ethdev_pci.h +0
-0if (!pci_dev)return -ENODEV ;This is a private header, it's never exposed---why the change is needed (not that I have a strong opinion, though)?
interesting, i'll look into why/how it is being included and confirm. i suppose the question in the back of my mind is if it is private then why is the header being installed at all?
Quoted 9 lines · Tyler Retzlaff
Quoted 5 lines · Dmitry Kozlyuk
Quoted 2 lines · Tyler Retzlaff
Explicitly cast void * to type * so that eal headers may be compiled as C or C++.
Topic should probably be "eal/windows".
i'll submit a new rev that changes this, it's not really windows specific but i guess windows is the only people crazy enough to use c++.
1. Topic usually describe area of changes, rte_os.h is in windows directory.
2. It's a perfectly valid concern that public headers must be usable from C++.
Quoted 17 lines
Quoted 11 lines
Quoted 11 lines
lib/librte_ethdev/rte_ethdev_pci.h +1
-1@@ -47,7 +47,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;Quoted 5 lines
lib/librte_ethdev/rte_ethdev_pci.h rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, · line 53
Quoted 2 lines
lib/librte_ethdev/rte_ethdev_pci.h +0
-0if (!pci_dev)return -ENODEV ;This is a private header, it's never exposed---why the change is needed (not that I have a strong opinion, though)?
Quoted 3 lines
interesting, i'll look into why/how it is being included and confirm. i suppose the question in the back of my mind is if it is private then why is the header being installed at all?
+ Bruce
If it's a public header then maybe it's missing a @file?
Quoted 35 lines · Dmitry Kozlyuk
Quoted 10 lines · Tyler Retzlaff
Quoted 5 lines · Dmitry Kozlyuk
Quoted 2 lines · Tyler Retzlaff
Explicitly cast void * to type * so that eal headers may be compiled as C or C++.
Topic should probably be "eal/windows".
i'll submit a new rev that changes this, it's not really windows specific but i guess windows is the only people crazy enough to use c++.
1. Topic usually describe area of changes,
rte_os.his in windows directory.2. It's a perfectly valid concern that public headers must be usable from C++.
Quoted 16 lines
Quoted 15 lines
Quoted 6 lines
(quoted diff) +0
-0
b/lib/librte_ethdev/rte_ethdev_pci.hindexbf715896a..c20be29b1100644 ---a/lib/librte_ethdev/rte_ethdev_pci.h+++b/lib/librte_ethdev/rte_ethdev_pci.h@@ -47,7 +47,7 @@ rte_eth_copy_pci_info(structrte_eth_dev*eth_dev,Quoted 6 lines
static inline int eth_dev_pci_specific_init(struct
rte_eth_dev
*eth_dev, void*bus_device) { - structrte_pci_device
*pci_dev=bus_device; + structrte_pci_device*pci_dev=
(structrte_pci_device*)bus_device;if (!pci_dev) return
-ENODEV;This is a private header, it's never exposed---why the change is needed (not that I have a strong opinion, though)?
Quoted 8 lines
Quoted 3 lines
interesting, i'll look into why/how it is being included and confirm. i suppose the question in the back of my mind is if it is private then why is the header being installed at all?
+ Bruce
If it's a public header then maybe it's missing a @file?
My 2c on this in general...
The use of public vs private headers is not always clear, sadly, in DPDK, for historical reasons. With the make builds, libraries picked up headers from other libraries via the "include" folder for all of DPDK, meaning that if a particular header was internal only but used by multiple other libs, it was placed in "include" for simplicity, rather than having each library using it having to have separate "-I/path/to/header" cflags specified. With the switch to meson, this common folder use is no longer be the case, but because of the old way of doing things it may be that in the transition some private headers were inadvertently kept as public (and possibly vice versa, though that is more likely to be spotted by now).
/Bruce
Quoted 15 lines
Quoted 2 lines
If it's a public header then maybe it's missing a @file?
My 2c on this in general...
The use of public vs private headers is not always clear, sadly, in DPDK, for historical reasons. With the make builds, libraries picked up headers from other libraries via the "include" folder for all of DPDK, meaning that if a particular header was internal only but used by multiple other libs, it was placed in "include" for simplicity, rather than having each library using it having to have separate "-I/path/to/header" cflags specified. With the switch to meson, this common folder use is no longer be the case, but because of the old way of doing things it may be that in the transition some private headers were inadvertently kept as public (and possibly vice versa, though that is more likely to be spotted by now).
Quoted 1 line
/Bruce
Here is why rte_ethdev_pci.h should be considered private to DPDK:
* rte_eth_copy_pci_info - intended for device init, that is, driver job
* eth_dev_pci_specific_init - wrapper for the above
* rte_eth_dev_pci_allocate - @internal, deals with private data
* rte_eth_dev_pci_generic_probe - @internal, deals with private data
* rte_eth_dev_pci_generic_remove - @internal
14/01/2021 19:27, Dmitry Kozlyuk:
Quoted 17 lines
Quoted 15 lines
Quoted 2 lines
If it's a public header then maybe it's missing a @file?
My 2c on this in general...
The use of public vs private headers is not always clear, sadly, in DPDK, for historical reasons. With the make builds, libraries picked up headers from other libraries via the "include" folder for all of DPDK, meaning that if a particular header was internal only but used by multiple other libs, it was placed in "include" for simplicity, rather than having each library using it having to have separate "-I/path/to/header" cflags specified. With the switch to meson, this common folder use is no longer be the case, but because of the old way of doing things it may be that in the transition some private headers were inadvertently kept as public (and possibly vice versa, though that is more likely to be spotted by now).
Quoted 1 line
/Bruce
Quoted 7 lines
Here is why
rte_ethdev_pci.hshould be considered private to DPDK:*
rte_eth_copy_pci_info- intended for device init, that is, driver job
*eth_dev_pci_specific_init- wrapper for the above
*rte_eth_dev_pci_allocate- @internal, deals with private data
*rte_eth_dev_pci_generic_probe- @internal, deals with private data
*rte_eth_dev_pci_generic_remove- @internal
Yes rte_ethdev_pci.h is a helper for ethdev drivers, it is DPDK internal.
Quoted 6 lines · Bruce Richardson
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
This is a private header, it's never exposed---why the change is needed (not that I have a strong opinion, though)?
interesting, i'll look into why/how it is being included and confirm. i suppose the question in the back of my mind is if it is private then why is the header being installed at all?
okay, i now understand how we ended up compiling this header directly. long story short we just had it #include directly somewhere.
as you have noted it is a private header. a quick examination of the other installed headers shows that it is not included by any of them.
i will update the patch to remove the cast from rte_ethdev_pci.h since it is not necessary.
would you also like a patch submitted that stops installing the header. the change will be breaking if any other consumers have made the same mistake as we did. i'm not sure what dpdk's stance is on pulling headers back out of public space.
thanks
PATCH v2 1/1 eal/windows: explicitly cast void * to type *
In reply to Tyler RetzlaffExplicitly cast void * to type * so that eal headers may be compiled as C or C++.
--- lib/librte_eal/windows/include/rte_os.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/windows/include/rte_os.h +1 -1
@@ -86,7 +86,7 @@ asprintf(char **buffer, const char *format, ...)return -1 ; size++; - *buffer =malloc (size); + *buffer = (char *)malloc (size);if (*buffer ==NULL )return -1 ;
Signature · 1 line
2.29.0.vfs.0.0
15/01/2021 20:21, Tyler Retzlaff:
Quoted 4 lines
would you also like a patch submitted that stops installing the header. the change will be breaking if any other consumers have made the same mistake as we did. i'm not sure what dpdk's stance is on pulling headers back out of public space.
That's a good question.
If it is described enough that it is not part of the API,
I think we can stop installing the header.
Anyway, our only commitment is on ABI compatibility, so it should be OK.
Re: [dpdk-dev] [PATCH v2] eal/windows: explicitly cast void * to type *
In reply to Tyler Retzlaff15/01/2021 20:38, Tyler Retzlaff:
Quoted 7 lines
Explicitly cast void * to type * so that eal headers may be compiled as C or C++.
Fixes e8428a9d89f1 ("eal/windows: add some basic functions and macros")Signed-off-by Tyler Retzlaff <[email protected]>
Applied with title "eal/windows: fix C++ compatibility", thanks.
Re: [dpdk-dev] [PATCH v2] eal/windows: explicitly cast void * to type *
In reply to Tyler RetzlaffQuoted 16 lines · On Fri, 15 Jan 2021 11:38:21 -0800 Tyler Retzlaff…
Explicitly cast void * to type * so that eal headers may be compiled as C or C++.
Fixes e8428a9d89f1 ("eal/windows: add some basic functions and macros")Signed-off-by Tyler Retzlaff <[email protected]>--- lib/librte_eal/windows/include/rte_os.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/windows/include/rte_os.h +0
-0
lib/librte_eal/windows/include/rte_os.h asprintf(char **buffer, const char *format, ...) · line 92
Quoted 8 lines
lib/librte_eal/windows/include/rte_os.h +1
-1@@ -86,7 +86,7 @@ asprintf(char **buffer, const char *format, ...)return -1 ; size++; - *buffer =malloc (size); + *buffer = (char *)malloc (size);if (*buffer ==NULL )return -1 ;
Why is the compiler enforcing C++ rules on code that is inside "extern C {"?
Bigger question is why is this code inlined? It is not critical path and should be a function.
Re: [dpdk-dev] [PATCH v2] eal/windows: explicitly cast void * to type *
Quoted 7 lines · Stephen Hemminger
lib/librte_eal/windows/include/rte_os.h asprintf(char **buffer, const char *format, ...) · line 91
Quoted 5 lines
lib/librte_eal/windows/include/rte_os.h +1
-1- *buffer =malloc (size); + *buffer = (char *)malloc (size);if (*buffer ==NULL )return -1 ;Why is the compiler enforcing C++ rules on code that is inside "extern C {"?
Code inside extern "C" is not compiled as C; directive only affects linkage.
Quoted 2 lines
Bigger question is why is this code inlined? It is not critical path and should be a function.
Absolutely.
There's more: windows/rte_os.h should not expose POSIX symbols at all, I'm working on a patchset to clean it up and un-inline this code.