[v2] eal/windows: explicitly cast void * to type *
Checks
Commit Message
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")
Cc: stable@dpdk.org
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/librte_eal/windows/include/rte_os.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
15/01/2021 20:38, 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")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Applied with title "eal/windows: fix C++ compatibility", thanks.
On Fri, 15 Jan 2021 11:38:21 -0800
Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
> 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")
> Cc: stable@dpdk.org
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
> lib/librte_eal/windows/include/rte_os.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h
> index ea3fe60e5..7ef38ff06 100644
> --- a/lib/librte_eal/windows/include/rte_os.h
> +++ b/lib/librte_eal/windows/include/rte_os.h
> @@ -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.
On Sun, 17 Jan 2021 10:10:39 -0800, Stephen Hemminger wrote:
> > - *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.
> 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.
@@ -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;