DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/3] eal: small rte_common.h fixes and cleanup
@ 2022-08-21 20:50 Dmitry Kozlyuk
  2022-08-21 20:50 ` [PATCH 1/3] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
                   ` (5 more replies)
  0 siblings, 6 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-21 20:50 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

Dmitry Kozlyuk (3):
  eal: fix pointer arithmetic with an expression argument
  eal: uninline rte_str_to_size
  eal: deduplicate roundup code

 app/test/test_common.c                 | 11 ++++++++
 lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++
 lib/eal/include/rte_common.h           | 38 ++++----------------------
 lib/eal/version.map                    |  1 +
 4 files changed, 49 insertions(+), 33 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 1/3] eal: fix pointer arithmetic with an expression argument
  2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
@ 2022-08-21 20:50 ` Dmitry Kozlyuk
  2022-08-22  7:14   ` Morten Brørup
  2022-08-21 20:50 ` [PATCH 2/3] eal: uninline rte_str_to_size Dmitry Kozlyuk
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-21 20:50 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk, stable

RTE_PTR_SUB(ptr, x) and RTE_PTR_ALIGN_FLOOR() worked incorrectly
if "ptr" was an expression:

    uint32_t arr[3];

    RTE_PTR_SUB(arr + 1, sizeof(arr[0]));
    // expected: (uint32_t *)((uintptr_t)(arr + 1) - 4) == arr
    // actual:   (uint32_t *)((uintptr_t) arr + 1  - 4) != arr

    RTE_PTR_ALIGN_FLOOR(arr + 2, sizeof(arr[0]));
    // expected: RTE_ALIGN_FLOOR((uintptr_t)(arr + 2), 4) == &arr[2]
    // actual:   RTE_ALIGN_FLOOR((uintptr_t) arr + 2,  4) == &arr[0]

Fix the macros and extend the relevant unit test.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 app/test/test_common.c       | 11 +++++++++++
 lib/eal/include/rte_common.h |  4 ++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/app/test/test_common.c b/app/test/test_common.c
index ef177cecb1..4194c1208a 100644
--- a/app/test/test_common.c
+++ b/app/test/test_common.c
@@ -31,6 +31,7 @@ test_macros(int __rte_unused unused_parm)
 
 	uintptr_t unused = 0;
 	unsigned int smaller = SMALLER, bigger  = BIGGER;
+	uint32_t arr[3];
 
 	RTE_SET_USED(unused);
 
@@ -41,6 +42,16 @@ test_macros(int __rte_unused unused_parm)
 		FAIL_MACRO(RTE_PTR_ADD);
 	if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER)
 		FAIL_MACRO(RTE_PTR_SUB);
+	if (RTE_PTR_ADD(arr + 1, sizeof(arr[0])) != &arr[2])
+		FAIL_MACRO(RTE_PTR_ADD);
+	if (RTE_PTR_SUB(arr + 1, sizeof(arr[0])) != &arr[0])
+		FAIL_MACRO(RTE_PTR_SUB);
+	if (RTE_PTR_ALIGN_FLOOR(arr + 2, 4) != &arr[2])
+		FAIL_MACRO(RTE_PTR_ALIGN_FLOOR);
+	if (RTE_PTR_ALIGN_CEIL(arr + 2, 4) != &arr[2])
+		FAIL_MACRO(RTE_PTR_ALIGN_CEIL);
+	if (RTE_PTR_ALIGN(arr + 2, 4) != &arr[2])
+		FAIL_MACRO(RTE_PTR_ALIGN);
 	if (RTE_PTR_DIFF(BIGGER, SMALLER) != PTR_DIFF)
 		FAIL_MACRO(RTE_PTR_DIFF);
 	if (RTE_MAX(SMALLER, BIGGER) != BIGGER)
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index a96cc2a138..d517e9f75f 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -295,7 +295,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /**
  * subtract a byte-value offset from a pointer
  */
-#define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
+#define RTE_PTR_SUB(ptr, x) ((void *)((uintptr_t)(ptr) - (x)))
 
 /**
  * get the difference between two pointer values, i.e. how far apart
@@ -320,7 +320,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
  * must be a power-of-two value.
  */
 #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
-	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align))
+	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))
 
 /**
  * Macro to align a value to a given power-of-two. The resultant value
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 2/3] eal: uninline rte_str_to_size
  2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  2022-08-21 20:50 ` [PATCH 1/3] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
@ 2022-08-21 20:50 ` Dmitry Kozlyuk
  2022-08-22  7:24   ` Morten Brørup
  2022-08-21 20:50 ` [PATCH 3/3] eal: deduplicate roundup code Dmitry Kozlyuk
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-21 20:50 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk, Ray Kinsella

There is no reason for rte_str_to_size() to be inline.
Move the implementation out of <rte_common.h>.
Export it as a stable ABI because it always has been public.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
Now <rte_common.h> doesn't need to #include <ctypes.h> and <stdlib.h>,
but removing them breaks some DPDK code, may break user code too.
I'm not sure what is the compatibility policy in this regard.
If such a breakage is allowed, I'd remove includes and fix DPDK code.

 lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++++++
 lib/eal/include/rte_common.h           | 30 ++----------------------
 lib/eal/version.map                    |  1 +
 3 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 0236ae4023..5fc4ee71dc 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -64,3 +64,35 @@ rte_strscpy(char *dst, const char *src, size_t dsize)
 	rte_errno = E2BIG;
 	return -rte_errno;
 }
+
+uint64_t
+rte_str_to_size(const char *str)
+{
+	char *endptr;
+	unsigned long long size;
+
+	while (isspace((int)*str))
+		str++;
+	if (*str == '-')
+		return 0;
+
+	errno = 0;
+	size = strtoull(str, &endptr, 0);
+	if (errno)
+		return 0;
+
+	if (*endptr == ' ')
+		endptr++; /* allow 1 space gap */
+
+	switch (*endptr) {
+	case 'G': case 'g':
+		size *= 1024; /* fall-through */
+	case 'M': case 'm':
+		size *= 1024; /* fall-through */
+	case 'K': case 'k':
+		size *= 1024; /* fall-through */
+	default:
+		break;
+	}
+	return size;
+}
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index d517e9f75f..772e40f8c2 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -875,34 +875,8 @@ rte_log2_u64(uint64_t v)
  * @return
  *     Number.
  */
-static inline uint64_t
-rte_str_to_size(const char *str)
-{
-	char *endptr;
-	unsigned long long size;
-
-	while (isspace((int)*str))
-		str++;
-	if (*str == '-')
-		return 0;
-
-	errno = 0;
-	size = strtoull(str, &endptr, 0);
-	if (errno)
-		return 0;
-
-	if (*endptr == ' ')
-		endptr++; /* allow 1 space gap */
-
-	switch (*endptr){
-	case 'G': case 'g': size *= 1024; /* fall-through */
-	case 'M': case 'm': size *= 1024; /* fall-through */
-	case 'K': case 'k': size *= 1024; /* fall-through */
-	default:
-		break;
-	}
-	return size;
-}
+uint64_t
+rte_str_to_size(const char *str);
 
 /**
  * Function to terminate the application immediately, printing an error
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 1f293e768b..773b0902c0 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -261,6 +261,7 @@ DPDK_23 {
 	rte_socket_id;
 	rte_socket_id_by_idx;
 	rte_srand;
+	rte_str_to_size;
 	rte_strerror;
 	rte_strscpy;
 	rte_strsplit;
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/3] eal: deduplicate roundup code
  2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  2022-08-21 20:50 ` [PATCH 1/3] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
  2022-08-21 20:50 ` [PATCH 2/3] eal: uninline rte_str_to_size Dmitry Kozlyuk
@ 2022-08-21 20:50 ` Dmitry Kozlyuk
  2022-08-22  7:25   ` Morten Brørup
  2022-08-22 14:06 ` [PATCH 0/3] eal: small rte_common.h fixes and cleanup Bruce Richardson
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-21 20:50 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

RTE_CACHE_LINE_ROUNDUP() implementation repeated RTE_ALIGN_MUL_CEIL().
In other places RTE_CACHE_LINE_SIZE is assumed to be a power-of-2,
so define RTE_CACHE_LINE_ROUNDUP() using RTE_ALIGN_CEIL().

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/eal/include/rte_common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 772e40f8c2..86c50c55e0 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -425,9 +425,7 @@ rte_is_aligned(void *ptr, unsigned align)
 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
 
 /** Return the first cache-aligned value greater or equal to size. */
-#define RTE_CACHE_LINE_ROUNDUP(size) \
-	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
-	RTE_CACHE_LINE_SIZE))
+#define RTE_CACHE_LINE_ROUNDUP(size) RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE)
 
 /** Cache line size in terms of log2 */
 #if RTE_CACHE_LINE_SIZE == 64
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* RE: [PATCH 1/3] eal: fix pointer arithmetic with an expression argument
  2022-08-21 20:50 ` [PATCH 1/3] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
@ 2022-08-22  7:14   ` Morten Brørup
  0 siblings, 0 replies; 29+ messages in thread
From: Morten Brørup @ 2022-08-22  7:14 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev; +Cc: stable

> From: Dmitry Kozlyuk [mailto:dmitry.kozliuk@gmail.com]
> Sent: Sunday, 21 August 2022 22.50
> 
> RTE_PTR_SUB(ptr, x) and RTE_PTR_ALIGN_FLOOR() worked incorrectly
> if "ptr" was an expression:
> 
>     uint32_t arr[3];
> 
>     RTE_PTR_SUB(arr + 1, sizeof(arr[0]));
>     // expected: (uint32_t *)((uintptr_t)(arr + 1) - 4) == arr
>     // actual:   (uint32_t *)((uintptr_t) arr + 1  - 4) != arr
> 
>     RTE_PTR_ALIGN_FLOOR(arr + 2, sizeof(arr[0]));
>     // expected: RTE_ALIGN_FLOOR((uintptr_t)(arr + 2), 4) == &arr[2]
>     // actual:   RTE_ALIGN_FLOOR((uintptr_t) arr + 2,  4) == &arr[0]
> 
> Fix the macros and extend the relevant unit test.

Good catch. Serious bugs!

> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
>  app/test/test_common.c       | 11 +++++++++++
>  lib/eal/include/rte_common.h |  4 ++--
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test/test_common.c b/app/test/test_common.c
> index ef177cecb1..4194c1208a 100644
> --- a/app/test/test_common.c
> +++ b/app/test/test_common.c
> @@ -31,6 +31,7 @@ test_macros(int __rte_unused unused_parm)
> 
>  	uintptr_t unused = 0;
>  	unsigned int smaller = SMALLER, bigger  = BIGGER;
> +	uint32_t arr[3];
> 
>  	RTE_SET_USED(unused);
> 
> @@ -41,6 +42,16 @@ test_macros(int __rte_unused unused_parm)
>  		FAIL_MACRO(RTE_PTR_ADD);
>  	if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER)
>  		FAIL_MACRO(RTE_PTR_SUB);
> +	if (RTE_PTR_ADD(arr + 1, sizeof(arr[0])) != &arr[2])
> +		FAIL_MACRO(RTE_PTR_ADD);
> +	if (RTE_PTR_SUB(arr + 1, sizeof(arr[0])) != &arr[0])
> +		FAIL_MACRO(RTE_PTR_SUB);

Very elegant test cases. :-)

> +	if (RTE_PTR_ALIGN_FLOOR(arr + 2, 4) != &arr[2])
> +		FAIL_MACRO(RTE_PTR_ALIGN_FLOOR);
> +	if (RTE_PTR_ALIGN_CEIL(arr + 2, 4) != &arr[2])
> +		FAIL_MACRO(RTE_PTR_ALIGN_CEIL);

While you are at it, consider adding a few more test cases, e.g.

RTE_PTR_ALIGN_FLOOR/CEIL(RTE_PTR_ADD(&arr[1], 1), 4), and
RTE_PTR_ALIGN_FLOOR/CEIL(RTE_PTR_ADD(&arr[1], sizeof(uint32_t) - 1), 4)

> +	if (RTE_PTR_ALIGN(arr + 2, 4) != &arr[2])
> +		FAIL_MACRO(RTE_PTR_ALIGN);
>  	if (RTE_PTR_DIFF(BIGGER, SMALLER) != PTR_DIFF)
>  		FAIL_MACRO(RTE_PTR_DIFF);
>  	if (RTE_MAX(SMALLER, BIGGER) != BIGGER)
> diff --git a/lib/eal/include/rte_common.h
> b/lib/eal/include/rte_common.h
> index a96cc2a138..d517e9f75f 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -295,7 +295,7 @@ static void
> __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
>  /**
>   * subtract a byte-value offset from a pointer
>   */
> -#define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
> +#define RTE_PTR_SUB(ptr, x) ((void *)((uintptr_t)(ptr) - (x)))
> 
>  /**
>   * get the difference between two pointer values, i.e. how far apart
> @@ -320,7 +320,7 @@ static void
> __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
>   * must be a power-of-two value.
>   */
>  #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
> -	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align))
> +	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))
> 
>  /**
>   * Macro to align a value to a given power-of-two. The resultant value
> --
> 2.33.1
> 

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>


^ permalink raw reply	[flat|nested] 29+ messages in thread

* RE: [PATCH 2/3] eal: uninline rte_str_to_size
  2022-08-21 20:50 ` [PATCH 2/3] eal: uninline rte_str_to_size Dmitry Kozlyuk
@ 2022-08-22  7:24   ` Morten Brørup
  2022-08-22 14:06     ` Bruce Richardson
  0 siblings, 1 reply; 29+ messages in thread
From: Morten Brørup @ 2022-08-22  7:24 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev; +Cc: Ray Kinsella

> From: Dmitry Kozlyuk [mailto:dmitry.kozliuk@gmail.com]
> Sent: Sunday, 21 August 2022 22.50
> To: dev@dpdk.org
> Cc: Dmitry Kozlyuk; Ray Kinsella
> Subject: [PATCH 2/3] eal: uninline rte_str_to_size
> 
> There is no reason for rte_str_to_size() to be inline.
> Move the implementation out of <rte_common.h>.
> Export it as a stable ABI because it always has been public.
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

Acked-by: Morten Brørup <mb@smartsharesystems.com>

> ---
> Now <rte_common.h> doesn't need to #include <ctypes.h> and <stdlib.h>,
> but removing them breaks some DPDK code, may break user code too.
> I'm not sure what is the compatibility policy in this regard.
> If such a breakage is allowed, I'd remove includes and fix DPDK code.
> 

The question I'm asking myself here is: Do we want rte_common.h to include common headers like these, just so we don't need to include them elsewhere? I think not.

I'm in favor of the principle of keeping it clean: Remove them from rte_common.h, and deal with the consequences.

If we keep them, we will forget why they are there, and some day in the future, someone will ask what these unused headers are doing in <rte_common.h>.


^ permalink raw reply	[flat|nested] 29+ messages in thread

* RE: [PATCH 3/3] eal: deduplicate roundup code
  2022-08-21 20:50 ` [PATCH 3/3] eal: deduplicate roundup code Dmitry Kozlyuk
@ 2022-08-22  7:25   ` Morten Brørup
  0 siblings, 0 replies; 29+ messages in thread
From: Morten Brørup @ 2022-08-22  7:25 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev

> From: Dmitry Kozlyuk [mailto:dmitry.kozliuk@gmail.com]
> Sent: Sunday, 21 August 2022 22.50
> 
> RTE_CACHE_LINE_ROUNDUP() implementation repeated RTE_ALIGN_MUL_CEIL().
> In other places RTE_CACHE_LINE_SIZE is assumed to be a power-of-2,
> so define RTE_CACHE_LINE_ROUNDUP() using RTE_ALIGN_CEIL().
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
>  lib/eal/include/rte_common.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/lib/eal/include/rte_common.h
> b/lib/eal/include/rte_common.h
> index 772e40f8c2..86c50c55e0 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -425,9 +425,7 @@ rte_is_aligned(void *ptr, unsigned align)
>  #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
> 
>  /** Return the first cache-aligned value greater or equal to size. */
> -#define RTE_CACHE_LINE_ROUNDUP(size) \
> -	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
> -	RTE_CACHE_LINE_SIZE))
> +#define RTE_CACHE_LINE_ROUNDUP(size) RTE_ALIGN_CEIL(size,
> RTE_CACHE_LINE_SIZE)
> 
>  /** Cache line size in terms of log2 */
>  #if RTE_CACHE_LINE_SIZE == 64
> --
> 2.33.1
> 

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 2/3] eal: uninline rte_str_to_size
  2022-08-22  7:24   ` Morten Brørup
@ 2022-08-22 14:06     ` Bruce Richardson
  0 siblings, 0 replies; 29+ messages in thread
From: Bruce Richardson @ 2022-08-22 14:06 UTC (permalink / raw)
  To: Morten Brørup; +Cc: Dmitry Kozlyuk, dev, Ray Kinsella

On Mon, Aug 22, 2022 at 09:24:47AM +0200, Morten Brørup wrote:
> > From: Dmitry Kozlyuk [mailto:dmitry.kozliuk@gmail.com]
> > Sent: Sunday, 21 August 2022 22.50
> > To: dev@dpdk.org
> > Cc: Dmitry Kozlyuk; Ray Kinsella
> > Subject: [PATCH 2/3] eal: uninline rte_str_to_size
> > 
> > There is no reason for rte_str_to_size() to be inline.
> > Move the implementation out of <rte_common.h>.
> > Export it as a stable ABI because it always has been public.
> > 
> > Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> 
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
> 
> > ---
> > Now <rte_common.h> doesn't need to #include <ctypes.h> and <stdlib.h>,
> > but removing them breaks some DPDK code, may break user code too.
> > I'm not sure what is the compatibility policy in this regard.
> > If such a breakage is allowed, I'd remove includes and fix DPDK code.
> > 
> 
> The question I'm asking myself here is: Do we want rte_common.h to include common headers like these, just so we don't need to include them elsewhere? I think not.
> 
> I'm in favor of the principle of keeping it clean: Remove them from rte_common.h, and deal with the consequences.
> 
> If we keep them, we will forget why they are there, and some day in the future, someone will ask what these unused headers are doing in <rte_common.h>.
> 
+1
Since removing headers is a build-time issue only and not runtime, I think
we should just remove them.

/Bruce

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 0/3] eal: small rte_common.h fixes and cleanup
  2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
                   ` (2 preceding siblings ...)
  2022-08-21 20:50 ` [PATCH 3/3] eal: deduplicate roundup code Dmitry Kozlyuk
@ 2022-08-22 14:06 ` Bruce Richardson
  2022-08-24  3:52 ` fengchengwen
  2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
  5 siblings, 0 replies; 29+ messages in thread
From: Bruce Richardson @ 2022-08-22 14:06 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev

On Sun, Aug 21, 2022 at 11:50:06PM +0300, Dmitry Kozlyuk wrote:
> Dmitry Kozlyuk (3):
>   eal: fix pointer arithmetic with an expression argument
>   eal: uninline rte_str_to_size
>   eal: deduplicate roundup code
> 
>  app/test/test_common.c                 | 11 ++++++++
>  lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++
>  lib/eal/include/rte_common.h           | 38 ++++----------------------
>  lib/eal/version.map                    |  1 +
>  4 files changed, 49 insertions(+), 33 deletions(-)
> 
Thanks.

Series-acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 0/3] eal: small rte_common.h fixes and cleanup
  2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
                   ` (3 preceding siblings ...)
  2022-08-22 14:06 ` [PATCH 0/3] eal: small rte_common.h fixes and cleanup Bruce Richardson
@ 2022-08-24  3:52 ` fengchengwen
  2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
  5 siblings, 0 replies; 29+ messages in thread
From: fengchengwen @ 2022-08-24  3:52 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev

Series-acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2022/8/22 4:50, Dmitry Kozlyuk wrote:
> Dmitry Kozlyuk (3):
>   eal: fix pointer arithmetic with an expression argument
>   eal: uninline rte_str_to_size
>   eal: deduplicate roundup code
> 
>  app/test/test_common.c                 | 11 ++++++++
>  lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++
>  lib/eal/include/rte_common.h           | 38 ++++----------------------
>  lib/eal/version.map                    |  1 +
>  4 files changed, 49 insertions(+), 33 deletions(-)
> 


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 0/4] eal: small rte_common.h fixes and cleanup
  2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
                   ` (4 preceding siblings ...)
  2022-08-24  3:52 ` fengchengwen
@ 2022-08-25 15:37 ` Dmitry Kozlyuk
  2022-08-25 15:37   ` [PATCH v2 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
                     ` (4 more replies)
  5 siblings, 5 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 15:37 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

v2:
    * Extend and tidy up the macro unit test (Morten).
    * Remove unneeded includes from rte_common.h (Morten, Bruce).

Dmitry Kozlyuk (4):
  eal: fix pointer arithmetic with an expression argument
  eal: deduplicate roundup code
  eal: uninline rte_str_to_size
  eal: remove unneeded includes from a public header

 app/test-bbdev/test_bbdev_vector.c            |  1 +
 .../cperf_test_vector_parsing.c               |  1 +
 app/test-eventdev/parser.h                    |  1 +
 app/test-pmd/bpf_cmd.c                        |  2 +
 app/test-pmd/cmdline.c                        |  1 +
 app/test-pmd/cmdline_tm.c                     |  2 +
 app/test-pmd/config.c                         |  1 +
 app/test/test.h                               |  2 +
 app/test/test_common.c                        | 58 +++++++++++++------
 drivers/bus/vdev/vdev_params.c                |  1 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      |  1 +
 drivers/common/cnxk/cnxk_telemetry_npa.c      |  1 +
 drivers/crypto/scheduler/scheduler_pmd.c      |  2 +
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c  |  2 +
 drivers/net/i40e/i40e_ethdev.c                |  1 +
 drivers/net/iavf/iavf_ethdev.c                |  1 +
 drivers/net/ice/ice_ethdev.c                  |  1 +
 drivers/net/softnic/parser.h                  |  1 +
 lib/dmadev/rte_dmadev.c                       |  1 +
 lib/eal/common/eal_common_debug.c             |  2 +
 lib/eal/common/eal_common_string_fns.c        | 36 +++++++++++-
 lib/eal/include/generic/rte_rwlock.h          |  2 +
 lib/eal/include/rte_common.h                  | 41 ++-----------
 lib/eal/linux/eal.c                           |  1 +
 lib/eal/linux/eal_vfio_mp_sync.c              |  1 +
 lib/eal/unix/eal_unix_timer.c                 |  1 +
 lib/eal/version.map                           |  1 +
 lib/eal/windows/rte_thread.c                  |  2 +
 lib/ethdev/sff_telemetry.c                    |  1 +
 lib/eventdev/rte_event_eth_rx_adapter.c       |  1 +
 lib/eventdev/rte_event_timer_adapter.c        |  1 +
 lib/meter/rte_meter.c                         |  1 +
 lib/pci/rte_pci.c                             |  1 +
 lib/pipeline/rte_swx_ctl.c                    |  1 +
 lib/sched/rte_pie.c                           |  1 +
 lib/security/rte_security.c                   |  2 +
 lib/telemetry/telemetry_data.c                |  3 +
 lib/telemetry/telemetry_legacy.c              |  1 +
 38 files changed, 126 insertions(+), 55 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 1/4] eal: fix pointer arithmetic with an expression argument
  2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
@ 2022-08-25 15:37   ` Dmitry Kozlyuk
  2022-08-25 15:37   ` [PATCH v2 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 15:37 UTC (permalink / raw)
  To: dev
  Cc: Dmitry Kozlyuk, stable, Morten Brørup, Bruce Richardson,
	Chengwen Feng

RTE_PTR_SUB(ptr, x) and RTE_PTR_ALIGN_FLOOR() worked incorrectly
if "ptr" was an expression:

    uint32_t arr[3];

    RTE_PTR_SUB(arr + 1, sizeof(arr[0]));
    // expected: (uint32_t *)((uintptr_t)(arr + 1) - 4) == arr
    // actual:   (uint32_t *)((uintptr_t) arr + 1  - 4) != arr

    RTE_PTR_ALIGN_FLOOR(arr + 2, sizeof(arr[0]));
    // expected: RTE_ALIGN_FLOOR((uintptr_t)(arr + 2), 4) == &arr[2]
    // actual:   RTE_ALIGN_FLOOR((uintptr_t) arr + 2,  4) == &arr[0]

Fix the macros and extend the relevant unit test.
Convert uses of a custom test failure macro to RTE_TEST_ASSERT*().

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_common.c       | 58 +++++++++++++++++++++++++-----------
 lib/eal/include/rte_common.h |  4 +--
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/app/test/test_common.c b/app/test/test_common.c
index ef177cecb1..f89e1eb7ee 100644
--- a/app/test/test_common.c
+++ b/app/test/test_common.c
@@ -25,31 +25,53 @@ test_macros(int __rte_unused unused_parm)
 #define SMALLER 0x1000U
 #define BIGGER 0x2000U
 #define PTR_DIFF BIGGER - SMALLER
-#define FAIL_MACRO(x)\
-	{printf(#x "() test failed!\n");\
-	return -1;}
 
 	uintptr_t unused = 0;
 	unsigned int smaller = SMALLER, bigger  = BIGGER;
+	uint32_t arr[3];
 
 	RTE_SET_USED(unused);
 
 	RTE_SWAP(smaller, bigger);
-	if (smaller != BIGGER && bigger != SMALLER)
-		FAIL_MACRO(RTE_SWAP);
-	if ((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF) != BIGGER)
-		FAIL_MACRO(RTE_PTR_ADD);
-	if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER)
-		FAIL_MACRO(RTE_PTR_SUB);
-	if (RTE_PTR_DIFF(BIGGER, SMALLER) != PTR_DIFF)
-		FAIL_MACRO(RTE_PTR_DIFF);
-	if (RTE_MAX(SMALLER, BIGGER) != BIGGER)
-		FAIL_MACRO(RTE_MAX);
-	if (RTE_MIN(SMALLER, BIGGER) != SMALLER)
-		FAIL_MACRO(RTE_MIN);
-
-	if (strncmp(RTE_STR(test), "test", sizeof("test")))
-		FAIL_MACRO(RTE_STR);
+	RTE_TEST_ASSERT(smaller == BIGGER && bigger == SMALLER,
+		"RTE_SWAP");
+	RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF), BIGGER,
+		"RTE_PTR_ADD");
+	RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF), SMALLER,
+		"RTE_PTR_SUB");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_DIFF(BIGGER, SMALLER), PTR_DIFF,
+		"RTE_PTR_DIFF");
+	RTE_TEST_ASSERT_EQUAL(RTE_MAX(SMALLER, BIGGER), BIGGER,
+		"RTE_MAX");
+	RTE_TEST_ASSERT_EQUAL(RTE_MIN(SMALLER, BIGGER), SMALLER,
+		"RTE_MIN");
+
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ADD(arr + 1, sizeof(arr[0])), &arr[2],
+		"RTE_PTR_ADD(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_SUB(arr + 1, sizeof(arr[0])), &arr[0],
+		"RTE_PTR_SUB(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_FLOOR(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN_FLOOR(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_CEIL(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN(expr, x)");
+
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 1), 4), &arr[1],
+		"RTE_PTR_ALIGN_FLOOR(x < y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 3), 4), &arr[1],
+		"RTE_PTR_ALIGN_FLOOR(x > y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 3), 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(x < y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 1), 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(x > y/2, y)");
+
+	RTE_TEST_ASSERT(strncmp(RTE_STR(test), "test", sizeof("test")) == 0,
+		"RTE_STR");
 
 	return 0;
 }
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index a96cc2a138..d517e9f75f 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -295,7 +295,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /**
  * subtract a byte-value offset from a pointer
  */
-#define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
+#define RTE_PTR_SUB(ptr, x) ((void *)((uintptr_t)(ptr) - (x)))
 
 /**
  * get the difference between two pointer values, i.e. how far apart
@@ -320,7 +320,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
  * must be a power-of-two value.
  */
 #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
-	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align))
+	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))
 
 /**
  * Macro to align a value to a given power-of-two. The resultant value
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 2/4] eal: deduplicate roundup code
  2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
  2022-08-25 15:37   ` [PATCH v2 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
@ 2022-08-25 15:37   ` Dmitry Kozlyuk
  2022-08-25 15:37   ` [PATCH v2 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 15:37 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk, Morten Brørup, Bruce Richardson, Chengwen Feng

RTE_CACHE_LINE_ROUNDUP() implementation repeated RTE_ALIGN_MUL_CEIL().
In other places RTE_CACHE_LINE_SIZE is assumed to be a power-of-2,
so define RTE_CACHE_LINE_ROUNDUP() using RTE_ALIGN_CEIL().

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/include/rte_common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index d517e9f75f..b65555bac6 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -425,9 +425,7 @@ rte_is_aligned(void *ptr, unsigned align)
 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
 
 /** Return the first cache-aligned value greater or equal to size. */
-#define RTE_CACHE_LINE_ROUNDUP(size) \
-	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
-	RTE_CACHE_LINE_SIZE))
+#define RTE_CACHE_LINE_ROUNDUP(size) RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE)
 
 /** Cache line size in terms of log2 */
 #if RTE_CACHE_LINE_SIZE == 64
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 3/4] eal: uninline rte_str_to_size
  2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
  2022-08-25 15:37   ` [PATCH v2 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
  2022-08-25 15:37   ` [PATCH v2 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
@ 2022-08-25 15:37   ` Dmitry Kozlyuk
  2022-08-25 15:37   ` [PATCH v2 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
  2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 15:37 UTC (permalink / raw)
  To: dev
  Cc: Dmitry Kozlyuk, Ray Kinsella, Morten Brørup,
	Bruce Richardson, Chengwen Feng

There is no reason for rte_str_to_size() to be inline.
Move the implementation out of <rte_common.h>.
Export it as a stable ABI because it always has been public.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++++++
 lib/eal/include/rte_common.h           | 30 ++----------------------
 lib/eal/version.map                    |  1 +
 3 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 0236ae4023..5fc4ee71dc 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -64,3 +64,35 @@ rte_strscpy(char *dst, const char *src, size_t dsize)
 	rte_errno = E2BIG;
 	return -rte_errno;
 }
+
+uint64_t
+rte_str_to_size(const char *str)
+{
+	char *endptr;
+	unsigned long long size;
+
+	while (isspace((int)*str))
+		str++;
+	if (*str == '-')
+		return 0;
+
+	errno = 0;
+	size = strtoull(str, &endptr, 0);
+	if (errno)
+		return 0;
+
+	if (*endptr == ' ')
+		endptr++; /* allow 1 space gap */
+
+	switch (*endptr) {
+	case 'G': case 'g':
+		size *= 1024; /* fall-through */
+	case 'M': case 'm':
+		size *= 1024; /* fall-through */
+	case 'K': case 'k':
+		size *= 1024; /* fall-through */
+	default:
+		break;
+	}
+	return size;
+}
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index b65555bac6..86c50c55e0 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -873,34 +873,8 @@ rte_log2_u64(uint64_t v)
  * @return
  *     Number.
  */
-static inline uint64_t
-rte_str_to_size(const char *str)
-{
-	char *endptr;
-	unsigned long long size;
-
-	while (isspace((int)*str))
-		str++;
-	if (*str == '-')
-		return 0;
-
-	errno = 0;
-	size = strtoull(str, &endptr, 0);
-	if (errno)
-		return 0;
-
-	if (*endptr == ' ')
-		endptr++; /* allow 1 space gap */
-
-	switch (*endptr){
-	case 'G': case 'g': size *= 1024; /* fall-through */
-	case 'M': case 'm': size *= 1024; /* fall-through */
-	case 'K': case 'k': size *= 1024; /* fall-through */
-	default:
-		break;
-	}
-	return size;
-}
+uint64_t
+rte_str_to_size(const char *str);
 
 /**
  * Function to terminate the application immediately, printing an error
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 1f293e768b..773b0902c0 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -261,6 +261,7 @@ DPDK_23 {
 	rte_socket_id;
 	rte_socket_id_by_idx;
 	rte_srand;
+	rte_str_to_size;
 	rte_strerror;
 	rte_strscpy;
 	rte_strsplit;
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 4/4] eal: remove unneeded includes from a public header
  2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
                     ` (2 preceding siblings ...)
  2022-08-25 15:37   ` [PATCH v2 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
@ 2022-08-25 15:37   ` Dmitry Kozlyuk
  2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 15:37 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

Do not include <ctype.h>, <errno.h>, and <stdlib.h> from <rte_common.h>,
because they are not used by this file directly.
Include the needed headers directly from the files that need them.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
Done as a separate commit to keep EAL change clean.

 app/test-bbdev/test_bbdev_vector.c               | 1 +
 app/test-crypto-perf/cperf_test_vector_parsing.c | 1 +
 app/test-eventdev/parser.h                       | 1 +
 app/test-pmd/bpf_cmd.c                           | 2 ++
 app/test-pmd/cmdline.c                           | 1 +
 app/test-pmd/cmdline_tm.c                        | 2 ++
 app/test-pmd/config.c                            | 1 +
 app/test/test.h                                  | 2 ++
 drivers/bus/vdev/vdev_params.c                   | 1 +
 drivers/common/cnxk/cnxk_telemetry_nix.c         | 1 +
 drivers/common/cnxk/cnxk_telemetry_npa.c         | 1 +
 drivers/crypto/scheduler/scheduler_pmd.c         | 2 ++
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c     | 2 ++
 drivers/net/i40e/i40e_ethdev.c                   | 1 +
 drivers/net/iavf/iavf_ethdev.c                   | 1 +
 drivers/net/ice/ice_ethdev.c                     | 1 +
 drivers/net/softnic/parser.h                     | 1 +
 lib/dmadev/rte_dmadev.c                          | 1 +
 lib/eal/common/eal_common_debug.c                | 2 ++
 lib/eal/common/eal_common_string_fns.c           | 4 +++-
 lib/eal/include/generic/rte_rwlock.h             | 2 ++
 lib/eal/include/rte_common.h                     | 3 ---
 lib/eal/linux/eal.c                              | 1 +
 lib/eal/linux/eal_vfio_mp_sync.c                 | 1 +
 lib/eal/unix/eal_unix_timer.c                    | 1 +
 lib/eal/windows/rte_thread.c                     | 2 ++
 lib/ethdev/sff_telemetry.c                       | 1 +
 lib/eventdev/rte_event_eth_rx_adapter.c          | 1 +
 lib/eventdev/rte_event_timer_adapter.c           | 1 +
 lib/meter/rte_meter.c                            | 1 +
 lib/pci/rte_pci.c                                | 1 +
 lib/pipeline/rte_swx_ctl.c                       | 1 +
 lib/sched/rte_pie.c                              | 1 +
 lib/security/rte_security.c                      | 2 ++
 lib/telemetry/telemetry_data.c                   | 3 +++
 lib/telemetry/telemetry_legacy.c                 | 1 +
 36 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/app/test-bbdev/test_bbdev_vector.c b/app/test-bbdev/test_bbdev_vector.c
index f020836f88..5018397c46 100644
--- a/app/test-bbdev/test_bbdev_vector.c
+++ b/app/test-bbdev/test_bbdev_vector.c
@@ -5,6 +5,7 @@
 #ifdef RTE_EXEC_ENV_FREEBSD
 	#define _WITH_GETLINE
 #endif
+#include <ctype.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <rte_malloc.h>
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 87f3a90055..2c9087b5f9 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -4,6 +4,7 @@
 #ifdef RTE_EXEC_ENV_FREEBSD
 	#define _WITH_GETLINE
 #endif
+#include <ctype.h>
 #include <stdio.h>
 
 #include <rte_malloc.h>
diff --git a/app/test-eventdev/parser.h b/app/test-eventdev/parser.h
index 696b40a3e2..954371b5b8 100644
--- a/app/test-eventdev/parser.h
+++ b/app/test-eventdev/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_PARSER_H__
 #define __INCLUDE_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #define PARSE_DELIMITER				" \f\n\r\t\v"
diff --git a/app/test-pmd/bpf_cmd.c b/app/test-pmd/bpf_cmd.c
index 648e0e9294..46f6b7d6d2 100644
--- a/app/test-pmd/bpf_cmd.c
+++ b/app/test-pmd/bpf_cmd.c
@@ -2,7 +2,9 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
+
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
 #include <rte_flow.h>
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b4fe9dfb17..07566c7a77 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index fb56a234c5..1bc6c00998 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <ctype.h>
+
 #include <cmdline_parse.h>
 #include <cmdline_parse_num.h>
 #include <cmdline_parse_string.h>
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a2939867c4..86054455d2 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3,6 +3,7 @@
  * Copyright 2013-2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/app/test/test.h b/app/test/test.h
index 7115edf469..85f57efbc6 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -5,7 +5,9 @@
 #ifndef _TEST_H_
 #define _TEST_H_
 
+#include <errno.h>
 #include <stddef.h>
+#include <stdlib.h>
 #include <sys/queue.h>
 
 #include <rte_hexdump.h>
diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c
index 3969faf16d..3d6f63344a 100644
--- a/drivers/bus/vdev/vdev_params.c
+++ b/drivers/bus/vdev/vdev_params.c
@@ -2,6 +2,7 @@
  * Copyright 2018 Gaëtan Rivet
  */
 
+#include <errno.h>
 #include <string.h>
 
 #include <rte_dev.h>
diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
index 4119e9ee4f..b7285cf137 100644
--- a/drivers/common/cnxk/cnxk_telemetry_nix.c
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <ctype.h>
 #include "cnxk_telemetry.h"
 #include "roc_api.h"
 #include "roc_priv.h"
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
index ae515df84f..b6ae108b10 100644
--- a/drivers/common/cnxk/cnxk_telemetry_npa.c
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <ctype.h>
 #include "cnxk_telemetry.h"
 #include "roc_api.h"
 #include "roc_priv.h"
diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index dd198080bf..2750fe8bd3 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Intel Corporation
  */
+#include <ctype.h>
+
 #include <rte_common.h>
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
index bfdbd1ee5d..c38af63bdc 100644
--- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
+++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
@@ -2,6 +2,8 @@
  * Copyright(C) 2022 Marvell.
  */
 
+#include <ctype.h>
+
 #include <rte_telemetry.h>
 
 #include <roc_api.h>
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67d79de08d..36ca42aa87 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 506fcff6e3..652f0d00a5 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <sys/queue.h>
 #include <stdio.h>
 #include <errno.h>
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index b2300790ae..e8304a1f2b 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5,6 +5,7 @@
 #include <rte_string_fns.h>
 #include <ethdev_pci.h>
 
+#include <ctype.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/drivers/net/softnic/parser.h b/drivers/net/softnic/parser.h
index 6f408b2485..c17a5d8ef0 100644
--- a/drivers/net/softnic/parser.h
+++ b/drivers/net/softnic/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_SOFTNIC_PARSER_H__
 #define __INCLUDE_SOFTNIC_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #include <rte_ip.h>
diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 174d4c40ae..e64c923a00 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2021 Intel Corporation
  */
 
+#include <ctype.h>
 #include <inttypes.h>
 
 #include <rte_eal.h>
diff --git a/lib/eal/common/eal_common_debug.c b/lib/eal/common/eal_common_debug.c
index 15418e957f..dcb554af1e 100644
--- a/lib/eal/common/eal_common_debug.c
+++ b/lib/eal/common/eal_common_debug.c
@@ -3,6 +3,8 @@
  */
 
 #include <stdarg.h>
+#include <stdlib.h>
+
 #include <rte_eal.h>
 #include <rte_log.h>
 #include <rte_debug.h>
diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 5fc4ee71dc..9ca2045b18 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -2,8 +2,10 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include <stdio.h>
+#include <ctype.h>
 #include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 #include <rte_string_fns.h>
 #include <rte_errno.h>
diff --git a/lib/eal/include/generic/rte_rwlock.h b/lib/eal/include/generic/rte_rwlock.h
index da9bc3e9c0..6f600db2af 100644
--- a/lib/eal/include/generic/rte_rwlock.h
+++ b/lib/eal/include/generic/rte_rwlock.h
@@ -21,6 +21,8 @@
 extern "C" {
 #endif
 
+#include <errno.h>
+
 #include <rte_common.h>
 #include <rte_atomic.h>
 #include <rte_pause.h>
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 86c50c55e0..2e22c1b955 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -17,9 +17,6 @@ extern "C" {
 #endif
 
 #include <stdint.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
 #include <limits.h>
 
 #include <rte_config.h>
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 37d29643a5..46bf52cef0 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2012-2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/lib/eal/linux/eal_vfio_mp_sync.c b/lib/eal/linux/eal_vfio_mp_sync.c
index 4e26781948..157f20e583 100644
--- a/lib/eal/linux/eal_vfio_mp_sync.c
+++ b/lib/eal/linux/eal_vfio_mp_sync.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2018 Intel Corporation
  */
 
+#include <errno.h>
 #include <unistd.h>
 #include <string.h>
 
diff --git a/lib/eal/unix/eal_unix_timer.c b/lib/eal/unix/eal_unix_timer.c
index cc50159104..e71602b3a1 100644
--- a/lib/eal/unix/eal_unix_timer.c
+++ b/lib/eal/unix/eal_unix_timer.c
@@ -2,6 +2,7 @@
  * Copyright 2020 Mellanox Technologies, Ltd
  */
 
+#include <errno.h>
 #include <time.h>
 
 #include <rte_cycles.h>
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index 077152568f..63442ece9d 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -3,6 +3,8 @@
  * Copyright (C) 2022 Microsoft Corporation
  */
 
+#include <errno.h>
+
 #include <rte_common.h>
 #include <rte_errno.h>
 #include <rte_thread.h>
diff --git a/lib/ethdev/sff_telemetry.c b/lib/ethdev/sff_telemetry.c
index 887f07c47e..81dec4a39c 100644
--- a/lib/ethdev/sff_telemetry.c
+++ b/lib/ethdev/sff_telemetry.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <ctype.h>
 #include <errno.h>
 
 #include "rte_ethdev.h"
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d2ea..2ce7dc652c 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation.
  * All rights reserved.
  */
+#include <ctype.h>
 #if defined(LINUX)
 #include <sys/epoll.h>
 #endif
diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c
index e0d978d641..27bf4c85b3 100644
--- a/lib/eventdev/rte_event_timer_adapter.c
+++ b/lib/eventdev/rte_event_timer_adapter.c
@@ -3,6 +3,7 @@
  * All rights reserved.
  */
 
+#include <ctype.h>
 #include <string.h>
 #include <inttypes.h>
 #include <stdbool.h>
diff --git a/lib/meter/rte_meter.c b/lib/meter/rte_meter.c
index 4549b97d36..6545803d36 100644
--- a/lib/meter/rte_meter.c
+++ b/lib/meter/rte_meter.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <math.h>
 
diff --git a/lib/pci/rte_pci.c b/lib/pci/rte_pci.c
index 355772ff56..1c5ef951d3 100644
--- a/lib/pci/rte_pci.c
+++ b/lib/pci/rte_pci.c
@@ -3,6 +3,7 @@
  * Copyright 2013-2014 6WIND S.A.
  */
 
+#include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c
index 710e89a46a..fecc215398 100644
--- a/lib/pipeline/rte_swx_ctl.c
+++ b/lib/pipeline/rte_swx_ctl.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2020 Intel Corporation
  */
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index c84f75a18c..947e2a059f 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index 4f5e4b4d49..9bf49a3bd0 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,6 +4,8 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <ctype.h>
+
 #include <rte_cryptodev.h>
 #include <rte_dev.h>
 #include <rte_telemetry.h>
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index e14ae3c4d4..2581c27413 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -2,6 +2,9 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
+#include <stdlib.h>
+
 #undef RTE_USE_LIBBSD
 #include <rte_string_fns.h>
 
diff --git a/lib/telemetry/telemetry_legacy.c b/lib/telemetry/telemetry_legacy.c
index 8aba44d689..17d77fff59 100644
--- a/lib/telemetry/telemetry_legacy.c
+++ b/lib/telemetry/telemetry_legacy.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2020 Intel Corporation
  */
+#include <ctype.h>
 
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include <unistd.h>
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup
  2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
                     ` (3 preceding siblings ...)
  2022-08-25 15:37   ` [PATCH v2 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
@ 2022-08-25 22:33   ` Dmitry Kozlyuk
  2022-08-25 22:33     ` [PATCH v3 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
                       ` (4 more replies)
  4 siblings, 5 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 22:33 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

v3: Fix build (CI).

v2:
    * Extend and tidy up the macro unit test (Morten).
    * Remove unneeded includes from rte_common.h (Morten, Bruce).

Dmitry Kozlyuk (4):
  eal: fix pointer arithmetic with an expression argument
  eal: deduplicate roundup code
  eal: uninline rte_str_to_size
  eal: remove unneeded includes from a public header

 app/test-bbdev/test_bbdev_vector.c            |  1 +
 .../cperf_test_vector_parsing.c               |  1 +
 app/test-eventdev/parser.h                    |  1 +
 app/test-pmd/bpf_cmd.c                        |  2 +
 app/test-pmd/cmdline.c                        |  1 +
 app/test-pmd/cmdline_tm.c                     |  2 +
 app/test-pmd/config.c                         |  1 +
 app/test/test.h                               |  2 +
 app/test/test_common.c                        | 58 +++++++++++++------
 drivers/bus/vdev/vdev_params.c                |  1 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      |  1 +
 drivers/common/cnxk/cnxk_telemetry_npa.c      |  1 +
 drivers/crypto/scheduler/scheduler_pmd.c      |  2 +
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c  |  2 +
 drivers/net/i40e/i40e_ethdev.c                |  1 +
 drivers/net/iavf/iavf_ethdev.c                |  1 +
 drivers/net/ice/ice_ethdev.c                  |  1 +
 drivers/net/softnic/parser.h                  |  1 +
 examples/eventdev_pipeline/main.c             |  1 +
 examples/fips_validation/fips_validation.c    |  1 +
 examples/ip_pipeline/parser.h                 |  1 +
 examples/ipsec-secgw/parser.h                 |  1 +
 examples/l3fwd-power/perf_core.c              |  1 +
 examples/pipeline/cli.c                       |  1 +
 examples/vhost/main.c                         |  1 +
 lib/dmadev/rte_dmadev.c                       |  1 +
 lib/eal/common/eal_common_debug.c             |  2 +
 lib/eal/common/eal_common_string_fns.c        | 36 +++++++++++-
 lib/eal/freebsd/eal.c                         |  1 +
 lib/eal/include/generic/rte_rwlock.h          |  2 +
 lib/eal/include/rte_common.h                  | 41 ++-----------
 lib/eal/linux/eal.c                           |  1 +
 lib/eal/linux/eal_vfio_mp_sync.c              |  1 +
 lib/eal/unix/eal_unix_timer.c                 |  1 +
 lib/eal/version.map                           |  1 +
 lib/eal/windows/rte_thread.c                  |  2 +
 lib/ethdev/sff_telemetry.c                    |  1 +
 lib/eventdev/rte_event_eth_rx_adapter.c       |  1 +
 lib/eventdev/rte_event_timer_adapter.c        |  1 +
 lib/meter/rte_meter.c                         |  1 +
 lib/pci/rte_pci.c                             |  1 +
 lib/pipeline/rte_swx_ctl.c                    |  1 +
 lib/sched/rte_pie.c                           |  1 +
 lib/security/rte_security.c                   |  2 +
 lib/telemetry/telemetry.c                     |  1 +
 lib/telemetry/telemetry_data.c                |  3 +
 lib/telemetry/telemetry_legacy.c              |  2 +
 47 files changed, 136 insertions(+), 55 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 1/4] eal: fix pointer arithmetic with an expression argument
  2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
@ 2022-08-25 22:33     ` Dmitry Kozlyuk
  2022-08-25 22:33     ` [PATCH v3 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 22:33 UTC (permalink / raw)
  To: dev
  Cc: Dmitry Kozlyuk, stable, Morten Brørup, Bruce Richardson,
	Chengwen Feng

RTE_PTR_SUB(ptr, x) and RTE_PTR_ALIGN_FLOOR() worked incorrectly
if "ptr" was an expression:

    uint32_t arr[3];

    RTE_PTR_SUB(arr + 1, sizeof(arr[0]));
    // expected: (uint32_t *)((uintptr_t)(arr + 1) - 4) == arr
    // actual:   (uint32_t *)((uintptr_t) arr + 1  - 4) != arr

    RTE_PTR_ALIGN_FLOOR(arr + 2, sizeof(arr[0]));
    // expected: RTE_ALIGN_FLOOR((uintptr_t)(arr + 2), 4) == &arr[2]
    // actual:   RTE_ALIGN_FLOOR((uintptr_t) arr + 2,  4) == &arr[0]

Fix the macros and extend the relevant unit test.
Convert uses of a custom test failure macro to RTE_TEST_ASSERT*().

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_common.c       | 58 +++++++++++++++++++++++++-----------
 lib/eal/include/rte_common.h |  4 +--
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/app/test/test_common.c b/app/test/test_common.c
index ef177cecb1..f89e1eb7ee 100644
--- a/app/test/test_common.c
+++ b/app/test/test_common.c
@@ -25,31 +25,53 @@ test_macros(int __rte_unused unused_parm)
 #define SMALLER 0x1000U
 #define BIGGER 0x2000U
 #define PTR_DIFF BIGGER - SMALLER
-#define FAIL_MACRO(x)\
-	{printf(#x "() test failed!\n");\
-	return -1;}
 
 	uintptr_t unused = 0;
 	unsigned int smaller = SMALLER, bigger  = BIGGER;
+	uint32_t arr[3];
 
 	RTE_SET_USED(unused);
 
 	RTE_SWAP(smaller, bigger);
-	if (smaller != BIGGER && bigger != SMALLER)
-		FAIL_MACRO(RTE_SWAP);
-	if ((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF) != BIGGER)
-		FAIL_MACRO(RTE_PTR_ADD);
-	if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER)
-		FAIL_MACRO(RTE_PTR_SUB);
-	if (RTE_PTR_DIFF(BIGGER, SMALLER) != PTR_DIFF)
-		FAIL_MACRO(RTE_PTR_DIFF);
-	if (RTE_MAX(SMALLER, BIGGER) != BIGGER)
-		FAIL_MACRO(RTE_MAX);
-	if (RTE_MIN(SMALLER, BIGGER) != SMALLER)
-		FAIL_MACRO(RTE_MIN);
-
-	if (strncmp(RTE_STR(test), "test", sizeof("test")))
-		FAIL_MACRO(RTE_STR);
+	RTE_TEST_ASSERT(smaller == BIGGER && bigger == SMALLER,
+		"RTE_SWAP");
+	RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF), BIGGER,
+		"RTE_PTR_ADD");
+	RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF), SMALLER,
+		"RTE_PTR_SUB");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_DIFF(BIGGER, SMALLER), PTR_DIFF,
+		"RTE_PTR_DIFF");
+	RTE_TEST_ASSERT_EQUAL(RTE_MAX(SMALLER, BIGGER), BIGGER,
+		"RTE_MAX");
+	RTE_TEST_ASSERT_EQUAL(RTE_MIN(SMALLER, BIGGER), SMALLER,
+		"RTE_MIN");
+
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ADD(arr + 1, sizeof(arr[0])), &arr[2],
+		"RTE_PTR_ADD(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_SUB(arr + 1, sizeof(arr[0])), &arr[0],
+		"RTE_PTR_SUB(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_FLOOR(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN_FLOOR(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_CEIL(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN(expr, x)");
+
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 1), 4), &arr[1],
+		"RTE_PTR_ALIGN_FLOOR(x < y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 3), 4), &arr[1],
+		"RTE_PTR_ALIGN_FLOOR(x > y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 3), 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(x < y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 1), 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(x > y/2, y)");
+
+	RTE_TEST_ASSERT(strncmp(RTE_STR(test), "test", sizeof("test")) == 0,
+		"RTE_STR");
 
 	return 0;
 }
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index a96cc2a138..d517e9f75f 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -295,7 +295,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /**
  * subtract a byte-value offset from a pointer
  */
-#define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
+#define RTE_PTR_SUB(ptr, x) ((void *)((uintptr_t)(ptr) - (x)))
 
 /**
  * get the difference between two pointer values, i.e. how far apart
@@ -320,7 +320,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
  * must be a power-of-two value.
  */
 #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
-	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align))
+	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))
 
 /**
  * Macro to align a value to a given power-of-two. The resultant value
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 2/4] eal: deduplicate roundup code
  2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  2022-08-25 22:33     ` [PATCH v3 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
@ 2022-08-25 22:33     ` Dmitry Kozlyuk
  2022-08-25 22:33     ` [PATCH v3 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 22:33 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk, Morten Brørup, Bruce Richardson, Chengwen Feng

RTE_CACHE_LINE_ROUNDUP() implementation repeated RTE_ALIGN_MUL_CEIL().
In other places RTE_CACHE_LINE_SIZE is assumed to be a power-of-2,
so define RTE_CACHE_LINE_ROUNDUP() using RTE_ALIGN_CEIL().

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/include/rte_common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index d517e9f75f..b65555bac6 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -425,9 +425,7 @@ rte_is_aligned(void *ptr, unsigned align)
 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
 
 /** Return the first cache-aligned value greater or equal to size. */
-#define RTE_CACHE_LINE_ROUNDUP(size) \
-	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
-	RTE_CACHE_LINE_SIZE))
+#define RTE_CACHE_LINE_ROUNDUP(size) RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE)
 
 /** Cache line size in terms of log2 */
 #if RTE_CACHE_LINE_SIZE == 64
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 3/4] eal: uninline rte_str_to_size
  2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  2022-08-25 22:33     ` [PATCH v3 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
  2022-08-25 22:33     ` [PATCH v3 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
@ 2022-08-25 22:33     ` Dmitry Kozlyuk
  2022-08-25 22:33     ` [PATCH v3 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
  2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 22:33 UTC (permalink / raw)
  To: dev
  Cc: Dmitry Kozlyuk, Ray Kinsella, Morten Brørup,
	Bruce Richardson, Chengwen Feng

There is no reason for rte_str_to_size() to be inline.
Move the implementation out of <rte_common.h>.
Export it as a stable ABI because it always has been public.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++++++
 lib/eal/include/rte_common.h           | 30 ++----------------------
 lib/eal/version.map                    |  1 +
 3 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 0236ae4023..5fc4ee71dc 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -64,3 +64,35 @@ rte_strscpy(char *dst, const char *src, size_t dsize)
 	rte_errno = E2BIG;
 	return -rte_errno;
 }
+
+uint64_t
+rte_str_to_size(const char *str)
+{
+	char *endptr;
+	unsigned long long size;
+
+	while (isspace((int)*str))
+		str++;
+	if (*str == '-')
+		return 0;
+
+	errno = 0;
+	size = strtoull(str, &endptr, 0);
+	if (errno)
+		return 0;
+
+	if (*endptr == ' ')
+		endptr++; /* allow 1 space gap */
+
+	switch (*endptr) {
+	case 'G': case 'g':
+		size *= 1024; /* fall-through */
+	case 'M': case 'm':
+		size *= 1024; /* fall-through */
+	case 'K': case 'k':
+		size *= 1024; /* fall-through */
+	default:
+		break;
+	}
+	return size;
+}
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index b65555bac6..86c50c55e0 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -873,34 +873,8 @@ rte_log2_u64(uint64_t v)
  * @return
  *     Number.
  */
-static inline uint64_t
-rte_str_to_size(const char *str)
-{
-	char *endptr;
-	unsigned long long size;
-
-	while (isspace((int)*str))
-		str++;
-	if (*str == '-')
-		return 0;
-
-	errno = 0;
-	size = strtoull(str, &endptr, 0);
-	if (errno)
-		return 0;
-
-	if (*endptr == ' ')
-		endptr++; /* allow 1 space gap */
-
-	switch (*endptr){
-	case 'G': case 'g': size *= 1024; /* fall-through */
-	case 'M': case 'm': size *= 1024; /* fall-through */
-	case 'K': case 'k': size *= 1024; /* fall-through */
-	default:
-		break;
-	}
-	return size;
-}
+uint64_t
+rte_str_to_size(const char *str);
 
 /**
  * Function to terminate the application immediately, printing an error
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 1f293e768b..773b0902c0 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -261,6 +261,7 @@ DPDK_23 {
 	rte_socket_id;
 	rte_socket_id_by_idx;
 	rte_srand;
+	rte_str_to_size;
 	rte_strerror;
 	rte_strscpy;
 	rte_strsplit;
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 4/4] eal: remove unneeded includes from a public header
  2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
                       ` (2 preceding siblings ...)
  2022-08-25 22:33     ` [PATCH v3 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
@ 2022-08-25 22:33     ` Dmitry Kozlyuk
  2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-25 22:33 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

Do not include <ctype.h>, <errno.h>, and <stdlib.h> from <rte_common.h>,
because they are not used by this file directly.
Include the needed headers directly from the files that need them.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 app/test-bbdev/test_bbdev_vector.c               | 1 +
 app/test-crypto-perf/cperf_test_vector_parsing.c | 1 +
 app/test-eventdev/parser.h                       | 1 +
 app/test-pmd/bpf_cmd.c                           | 2 ++
 app/test-pmd/cmdline.c                           | 1 +
 app/test-pmd/cmdline_tm.c                        | 2 ++
 app/test-pmd/config.c                            | 1 +
 app/test/test.h                                  | 2 ++
 drivers/bus/vdev/vdev_params.c                   | 1 +
 drivers/common/cnxk/cnxk_telemetry_nix.c         | 1 +
 drivers/common/cnxk/cnxk_telemetry_npa.c         | 1 +
 drivers/crypto/scheduler/scheduler_pmd.c         | 2 ++
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c     | 2 ++
 drivers/net/i40e/i40e_ethdev.c                   | 1 +
 drivers/net/iavf/iavf_ethdev.c                   | 1 +
 drivers/net/ice/ice_ethdev.c                     | 1 +
 drivers/net/softnic/parser.h                     | 1 +
 examples/eventdev_pipeline/main.c                | 1 +
 examples/fips_validation/fips_validation.c       | 1 +
 examples/ip_pipeline/parser.h                    | 1 +
 examples/ipsec-secgw/parser.h                    | 1 +
 examples/l3fwd-power/perf_core.c                 | 1 +
 examples/pipeline/cli.c                          | 1 +
 examples/vhost/main.c                            | 1 +
 lib/dmadev/rte_dmadev.c                          | 1 +
 lib/eal/common/eal_common_debug.c                | 2 ++
 lib/eal/common/eal_common_string_fns.c           | 4 +++-
 lib/eal/freebsd/eal.c                            | 1 +
 lib/eal/include/generic/rte_rwlock.h             | 2 ++
 lib/eal/include/rte_common.h                     | 3 ---
 lib/eal/linux/eal.c                              | 1 +
 lib/eal/linux/eal_vfio_mp_sync.c                 | 1 +
 lib/eal/unix/eal_unix_timer.c                    | 1 +
 lib/eal/windows/rte_thread.c                     | 2 ++
 lib/ethdev/sff_telemetry.c                       | 1 +
 lib/eventdev/rte_event_eth_rx_adapter.c          | 1 +
 lib/eventdev/rte_event_timer_adapter.c           | 1 +
 lib/meter/rte_meter.c                            | 1 +
 lib/pci/rte_pci.c                                | 1 +
 lib/pipeline/rte_swx_ctl.c                       | 1 +
 lib/sched/rte_pie.c                              | 1 +
 lib/security/rte_security.c                      | 2 ++
 lib/telemetry/telemetry.c                        | 1 +
 lib/telemetry/telemetry_data.c                   | 3 +++
 lib/telemetry/telemetry_legacy.c                 | 2 ++
 45 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/app/test-bbdev/test_bbdev_vector.c b/app/test-bbdev/test_bbdev_vector.c
index f020836f88..5018397c46 100644
--- a/app/test-bbdev/test_bbdev_vector.c
+++ b/app/test-bbdev/test_bbdev_vector.c
@@ -5,6 +5,7 @@
 #ifdef RTE_EXEC_ENV_FREEBSD
 	#define _WITH_GETLINE
 #endif
+#include <ctype.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <rte_malloc.h>
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 87f3a90055..2c9087b5f9 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -4,6 +4,7 @@
 #ifdef RTE_EXEC_ENV_FREEBSD
 	#define _WITH_GETLINE
 #endif
+#include <ctype.h>
 #include <stdio.h>
 
 #include <rte_malloc.h>
diff --git a/app/test-eventdev/parser.h b/app/test-eventdev/parser.h
index 696b40a3e2..954371b5b8 100644
--- a/app/test-eventdev/parser.h
+++ b/app/test-eventdev/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_PARSER_H__
 #define __INCLUDE_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #define PARSE_DELIMITER				" \f\n\r\t\v"
diff --git a/app/test-pmd/bpf_cmd.c b/app/test-pmd/bpf_cmd.c
index 648e0e9294..46f6b7d6d2 100644
--- a/app/test-pmd/bpf_cmd.c
+++ b/app/test-pmd/bpf_cmd.c
@@ -2,7 +2,9 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
+
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
 #include <rte_flow.h>
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b4fe9dfb17..07566c7a77 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index fb56a234c5..1bc6c00998 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <ctype.h>
+
 #include <cmdline_parse.h>
 #include <cmdline_parse_num.h>
 #include <cmdline_parse_string.h>
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a2939867c4..86054455d2 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3,6 +3,7 @@
  * Copyright 2013-2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/app/test/test.h b/app/test/test.h
index 7115edf469..85f57efbc6 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -5,7 +5,9 @@
 #ifndef _TEST_H_
 #define _TEST_H_
 
+#include <errno.h>
 #include <stddef.h>
+#include <stdlib.h>
 #include <sys/queue.h>
 
 #include <rte_hexdump.h>
diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c
index 3969faf16d..3d6f63344a 100644
--- a/drivers/bus/vdev/vdev_params.c
+++ b/drivers/bus/vdev/vdev_params.c
@@ -2,6 +2,7 @@
  * Copyright 2018 Gaëtan Rivet
  */
 
+#include <errno.h>
 #include <string.h>
 
 #include <rte_dev.h>
diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
index 4119e9ee4f..b7285cf137 100644
--- a/drivers/common/cnxk/cnxk_telemetry_nix.c
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <ctype.h>
 #include "cnxk_telemetry.h"
 #include "roc_api.h"
 #include "roc_priv.h"
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
index ae515df84f..b6ae108b10 100644
--- a/drivers/common/cnxk/cnxk_telemetry_npa.c
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <ctype.h>
 #include "cnxk_telemetry.h"
 #include "roc_api.h"
 #include "roc_priv.h"
diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index dd198080bf..2750fe8bd3 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Intel Corporation
  */
+#include <ctype.h>
+
 #include <rte_common.h>
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
index bfdbd1ee5d..c38af63bdc 100644
--- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
+++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
@@ -2,6 +2,8 @@
  * Copyright(C) 2022 Marvell.
  */
 
+#include <ctype.h>
+
 #include <rte_telemetry.h>
 
 #include <roc_api.h>
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67d79de08d..36ca42aa87 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 506fcff6e3..652f0d00a5 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <sys/queue.h>
 #include <stdio.h>
 #include <errno.h>
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index b2300790ae..e8304a1f2b 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5,6 +5,7 @@
 #include <rte_string_fns.h>
 #include <ethdev_pci.h>
 
+#include <ctype.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/drivers/net/softnic/parser.h b/drivers/net/softnic/parser.h
index 6f408b2485..c17a5d8ef0 100644
--- a/drivers/net/softnic/parser.h
+++ b/drivers/net/softnic/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_SOFTNIC_PARSER_H__
 #define __INCLUDE_SOFTNIC_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #include <rte_ip.h>
diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index 3dbef6ed45..b9448c7c4b 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2016-2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <getopt.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 12b9b03f56..7719b56123 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 
diff --git a/examples/ip_pipeline/parser.h b/examples/ip_pipeline/parser.h
index 4538f675d4..5224b18a89 100644
--- a/examples/ip_pipeline/parser.h
+++ b/examples/ip_pipeline/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_PARSER_H__
 #define __INCLUDE_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #include <rte_ip.h>
diff --git a/examples/ipsec-secgw/parser.h b/examples/ipsec-secgw/parser.h
index a0ff7e1b3f..b5c5d0210f 100644
--- a/examples/ipsec-secgw/parser.h
+++ b/examples/ipsec-secgw/parser.h
@@ -5,6 +5,7 @@
 #ifndef __PARSER_H
 #define __PARSER_H
 
+#include <ctype.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
diff --git a/examples/l3fwd-power/perf_core.c b/examples/l3fwd-power/perf_core.c
index 4705967ea2..3051c45674 100644
--- a/examples/l3fwd-power/perf_core.c
+++ b/examples/l3fwd-power/perf_core.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2018 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 
diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index ad553f19ab..41eefbaae8 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 7e1666f42a..71d053bf0c 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <arpa/inet.h>
 #include <getopt.h>
 #include <linux/if_ether.h>
diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 174d4c40ae..e64c923a00 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2021 Intel Corporation
  */
 
+#include <ctype.h>
 #include <inttypes.h>
 
 #include <rte_eal.h>
diff --git a/lib/eal/common/eal_common_debug.c b/lib/eal/common/eal_common_debug.c
index 15418e957f..dcb554af1e 100644
--- a/lib/eal/common/eal_common_debug.c
+++ b/lib/eal/common/eal_common_debug.c
@@ -3,6 +3,8 @@
  */
 
 #include <stdarg.h>
+#include <stdlib.h>
+
 #include <rte_eal.h>
 #include <rte_log.h>
 #include <rte_debug.h>
diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 5fc4ee71dc..9ca2045b18 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -2,8 +2,10 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include <stdio.h>
+#include <ctype.h>
 #include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 #include <rte_string_fns.h>
 #include <rte_errno.h>
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 26fbc91b26..ee5c929da8 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/lib/eal/include/generic/rte_rwlock.h b/lib/eal/include/generic/rte_rwlock.h
index da9bc3e9c0..6f600db2af 100644
--- a/lib/eal/include/generic/rte_rwlock.h
+++ b/lib/eal/include/generic/rte_rwlock.h
@@ -21,6 +21,8 @@
 extern "C" {
 #endif
 
+#include <errno.h>
+
 #include <rte_common.h>
 #include <rte_atomic.h>
 #include <rte_pause.h>
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 86c50c55e0..2e22c1b955 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -17,9 +17,6 @@ extern "C" {
 #endif
 
 #include <stdint.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
 #include <limits.h>
 
 #include <rte_config.h>
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 37d29643a5..46bf52cef0 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2012-2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/lib/eal/linux/eal_vfio_mp_sync.c b/lib/eal/linux/eal_vfio_mp_sync.c
index 4e26781948..157f20e583 100644
--- a/lib/eal/linux/eal_vfio_mp_sync.c
+++ b/lib/eal/linux/eal_vfio_mp_sync.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2018 Intel Corporation
  */
 
+#include <errno.h>
 #include <unistd.h>
 #include <string.h>
 
diff --git a/lib/eal/unix/eal_unix_timer.c b/lib/eal/unix/eal_unix_timer.c
index cc50159104..e71602b3a1 100644
--- a/lib/eal/unix/eal_unix_timer.c
+++ b/lib/eal/unix/eal_unix_timer.c
@@ -2,6 +2,7 @@
  * Copyright 2020 Mellanox Technologies, Ltd
  */
 
+#include <errno.h>
 #include <time.h>
 
 #include <rte_cycles.h>
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index 077152568f..63442ece9d 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -3,6 +3,8 @@
  * Copyright (C) 2022 Microsoft Corporation
  */
 
+#include <errno.h>
+
 #include <rte_common.h>
 #include <rte_errno.h>
 #include <rte_thread.h>
diff --git a/lib/ethdev/sff_telemetry.c b/lib/ethdev/sff_telemetry.c
index 887f07c47e..81dec4a39c 100644
--- a/lib/ethdev/sff_telemetry.c
+++ b/lib/ethdev/sff_telemetry.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <ctype.h>
 #include <errno.h>
 
 #include "rte_ethdev.h"
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d2ea..2ce7dc652c 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation.
  * All rights reserved.
  */
+#include <ctype.h>
 #if defined(LINUX)
 #include <sys/epoll.h>
 #endif
diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c
index e0d978d641..27bf4c85b3 100644
--- a/lib/eventdev/rte_event_timer_adapter.c
+++ b/lib/eventdev/rte_event_timer_adapter.c
@@ -3,6 +3,7 @@
  * All rights reserved.
  */
 
+#include <ctype.h>
 #include <string.h>
 #include <inttypes.h>
 #include <stdbool.h>
diff --git a/lib/meter/rte_meter.c b/lib/meter/rte_meter.c
index 4549b97d36..6545803d36 100644
--- a/lib/meter/rte_meter.c
+++ b/lib/meter/rte_meter.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <math.h>
 
diff --git a/lib/pci/rte_pci.c b/lib/pci/rte_pci.c
index 355772ff56..1c5ef951d3 100644
--- a/lib/pci/rte_pci.c
+++ b/lib/pci/rte_pci.c
@@ -3,6 +3,7 @@
  * Copyright 2013-2014 6WIND S.A.
  */
 
+#include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c
index 710e89a46a..fecc215398 100644
--- a/lib/pipeline/rte_swx_ctl.c
+++ b/lib/pipeline/rte_swx_ctl.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2020 Intel Corporation
  */
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index c84f75a18c..947e2a059f 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index 4f5e4b4d49..9bf49a3bd0 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,6 +4,8 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <ctype.h>
+
 #include <rte_cryptodev.h>
 #include <rte_dev.h>
 #include <rte_telemetry.h>
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index c6fd03a5ab..8345120413 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include <unistd.h>
 #include <pthread.h>
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index e14ae3c4d4..2581c27413 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -2,6 +2,9 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
+#include <stdlib.h>
+
 #undef RTE_USE_LIBBSD
 #include <rte_string_fns.h>
 
diff --git a/lib/telemetry/telemetry_legacy.c b/lib/telemetry/telemetry_legacy.c
index 8aba44d689..a1d074d884 100644
--- a/lib/telemetry/telemetry_legacy.c
+++ b/lib/telemetry/telemetry_legacy.c
@@ -1,7 +1,9 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2020 Intel Corporation
  */
+#include <ctype.h>
 
+#include <errno.h>
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include <unistd.h>
 #include <sys/socket.h>
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup
  2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
                       ` (3 preceding siblings ...)
  2022-08-25 22:33     ` [PATCH v3 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
@ 2022-08-27 11:32     ` Dmitry Kozlyuk
  2022-08-27 11:32       ` [PATCH v4 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
                         ` (4 more replies)
  4 siblings, 5 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-27 11:32 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

v4: Fix build on ARM and RISC-V (CI).

v3: Fix build (CI).

v2:
    * Extend and tidy up the macro unit test (Morten).
    * Remove unneeded includes from rte_common.h (Morten, Bruce).


Dmitry Kozlyuk (4):
  eal: fix pointer arithmetic with an expression argument
  eal: deduplicate roundup code
  eal: uninline rte_str_to_size
  eal: remove unneeded includes from a public header

 app/test-bbdev/main.c                         |  1 +
 app/test-bbdev/test_bbdev_perf.c              |  1 +
 app/test-bbdev/test_bbdev_vector.c            |  2 +
 .../comp_perf_test_cyclecount.c               |  2 +
 .../comp_perf_test_throughput.c               |  2 +
 .../comp_perf_test_verify.c                   |  2 +
 app/test-compress-perf/main.c                 |  1 +
 app/test-crypto-perf/cperf_options_parsing.c  |  1 +
 .../cperf_test_pmd_cyclecount.c               |  1 +
 app/test-crypto-perf/cperf_test_throughput.c  |  2 +
 .../cperf_test_vector_parsing.c               |  2 +
 app/test-crypto-perf/cperf_test_verify.c      |  2 +
 app/test-crypto-perf/main.c                   |  1 +
 app/test-eventdev/evt_main.c                  |  1 +
 app/test-eventdev/evt_options.c               |  1 +
 app/test-eventdev/parser.h                    |  1 +
 app/test-fib/main.c                           |  1 +
 app/test-flow-perf/actions_gen.c              |  1 +
 app/test-pmd/bpf_cmd.c                        |  2 +
 app/test-pmd/cmdline.c                        |  1 +
 app/test-pmd/cmdline_tm.c                     |  2 +
 app/test-pmd/config.c                         |  1 +
 app/test-sad/main.c                           |  1 +
 app/test/test.h                               |  2 +
 app/test/test_common.c                        | 58 +++++++++++++------
 drivers/baseband/la12xx/bbdev_la12xx.c        |  1 +
 drivers/baseband/null/bbdev_null.c            |  1 +
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  1 +
 drivers/bus/vdev/vdev_params.c                |  1 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      |  1 +
 drivers/common/cnxk/cnxk_telemetry_npa.c      |  1 +
 drivers/common/octeontx/octeontx_mbox.c       |  1 +
 drivers/crypto/bcmfs/bcmfs_device.c           |  1 +
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c     |  2 +
 drivers/crypto/scheduler/scheduler_pmd.c      |  3 +
 drivers/dma/skeleton/skeleton_dmadev.c        |  1 +
 drivers/event/dsw/dsw_event.c                 |  1 +
 drivers/event/octeontx/ssovf_evdev.c          |  1 +
 drivers/event/octeontx/ssovf_evdev_selftest.c |  2 +
 drivers/event/opdl/opdl_evdev.c               |  1 +
 drivers/event/opdl/opdl_test.c                |  1 +
 drivers/event/sw/sw_evdev.c                   |  1 +
 drivers/event/sw/sw_evdev_selftest.c          |  1 +
 drivers/net/af_packet/rte_eth_af_packet.c     |  1 +
 drivers/net/ark/ark_pktchkr.c                 |  1 +
 drivers/net/ark/ark_pktgen.c                  |  1 +
 drivers/net/atlantic/atl_hw_regs.h            |  1 +
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c  |  2 +
 drivers/net/failsafe/failsafe_intr.c          |  1 +
 drivers/net/hns3/hns3_mp.c                    |  2 +
 drivers/net/i40e/base/i40e_adminq.h           |  2 +
 drivers/net/i40e/i40e_ethdev.c                |  1 +
 drivers/net/iavf/iavf_ethdev.c                |  1 +
 drivers/net/ice/ice_dcf_parent.c              |  1 +
 drivers/net/ice/ice_ddp_package.c             |  2 +
 drivers/net/ice/ice_ethdev.c                  |  1 +
 drivers/net/mlx4/mlx4_mp.c                    |  1 +
 drivers/net/null/rte_eth_null.c               |  2 +
 drivers/net/octeontx/base/octeontx_bgx.c      |  1 +
 drivers/net/octeontx/octeontx_ethdev.c        |  1 +
 drivers/net/octeontx_ep/otx2_ep_vf.c          |  2 +
 drivers/net/pcap/pcap_ethdev.c                |  1 +
 drivers/net/ring/rte_eth_ring.c               |  2 +
 drivers/net/softnic/parser.h                  |  1 +
 drivers/net/tap/rte_eth_tap.c                 |  1 +
 drivers/net/vhost/rte_eth_vhost.c             |  1 +
 drivers/net/virtio/virtio_ethdev.c            |  1 +
 drivers/net/virtio/virtio_user/vhost_kernel.c |  1 +
 drivers/net/virtio/virtio_user/vhost_user.c   |  1 +
 drivers/net/virtio/virtio_user/vhost_vdpa.c   |  1 +
 .../net/virtio/virtio_user/virtio_user_dev.c  |  1 +
 drivers/net/virtio/virtio_user_ethdev.c       |  1 +
 .../raw/ifpga/base/osdep_rte/osdep_generic.h  |  2 +
 drivers/raw/skeleton/skeleton_rawdev.c        |  1 +
 drivers/raw/skeleton/skeleton_rawdev_test.c   |  2 +
 examples/distributor/main.c                   |  1 +
 examples/dma/dmafwd.c                         |  1 +
 examples/ethtool/ethtool-app/ethapp.c         |  2 +
 examples/eventdev_pipeline/main.c             |  2 +
 .../pipeline_worker_generic.c                 |  2 +
 .../eventdev_pipeline/pipeline_worker_tx.c    |  2 +
 examples/fips_validation/fips_validation.c    |  2 +
 .../fips_validation/fips_validation_gcm.c     |  1 +
 examples/fips_validation/main.c               |  1 +
 examples/ip_pipeline/main.c                   |  1 +
 examples/ip_pipeline/parser.h                 |  1 +
 examples/ipsec-secgw/event_helper.c           |  2 +
 examples/ipsec-secgw/flow.c                   |  1 +
 examples/ipsec-secgw/parser.c                 |  1 +
 examples/ipsec-secgw/parser.h                 |  1 +
 examples/ipsec-secgw/rt.c                     |  1 +
 examples/ipsec-secgw/sa.c                     |  1 +
 examples/l3fwd-power/perf_core.c              |  2 +
 .../client_server_mp/mp_server/init.c         |  1 +
 examples/multi_process/simple_mp/main.c       |  1 +
 examples/ntb/ntb_fwd.c                        |  1 +
 examples/packet_ordering/main.c               |  1 +
 examples/pipeline/cli.c                       |  1 +
 examples/pipeline/main.c                      |  1 +
 examples/ptpclient/ptpclient.c                |  1 +
 examples/qos_meter/main.c                     |  1 +
 examples/qos_sched/init.c                     |  1 +
 examples/rxtx_callbacks/main.c                |  1 +
 examples/server_node_efd/server/init.c        |  1 +
 examples/skeleton/basicfwd.c                  |  1 +
 examples/vdpa/main.c                          |  1 +
 examples/vhost/main.c                         |  2 +
 examples/vhost/virtio_net.c                   |  1 +
 examples/vhost_blk/vhost_blk.c                |  1 +
 lib/bpf/bpf_jit_arm64.c                       |  1 +
 lib/bpf/bpf_validate.c                        |  1 +
 lib/compressdev/rte_compressdev_pmd.c         |  2 +
 lib/cryptodev/cryptodev_pmd.c                 |  1 +
 lib/distributor/rte_distributor.c             |  1 +
 lib/dmadev/rte_dmadev.c                       |  2 +
 lib/eal/arm/rte_power_intrinsics.c            |  2 +
 lib/eal/common/eal_common_debug.c             |  2 +
 lib/eal/common/eal_common_dev.c               |  1 +
 lib/eal/common/eal_common_devargs.c           |  1 +
 lib/eal/common/eal_common_dynmem.c            |  1 +
 lib/eal/common/eal_common_lcore.c             |  1 +
 lib/eal/common/eal_common_memalloc.c          |  1 +
 lib/eal/common/eal_common_string_fns.c        | 36 +++++++++++-
 lib/eal/common/eal_common_trace.c             |  1 +
 lib/eal/common/eal_common_trace_ctf.c         |  1 +
 lib/eal/common/hotplug_mp.c                   |  1 +
 lib/eal/common/malloc_mp.c                    |  1 +
 lib/eal/freebsd/eal.c                         |  1 +
 lib/eal/include/generic/rte_rwlock.h          |  2 +
 lib/eal/include/rte_common.h                  | 41 ++-----------
 lib/eal/linux/eal.c                           |  1 +
 lib/eal/linux/eal_alarm.c                     |  1 +
 lib/eal/linux/eal_dev.c                       |  1 +
 lib/eal/linux/eal_vfio_mp_sync.c              |  1 +
 lib/eal/ppc/rte_power_intrinsics.c            |  2 +
 lib/eal/riscv/rte_power_intrinsics.c          |  2 +
 lib/eal/unix/eal_unix_timer.c                 |  1 +
 lib/eal/version.map                           |  1 +
 lib/eal/windows/rte_thread.c                  |  2 +
 lib/efd/rte_efd.c                             |  2 +
 lib/ethdev/ethdev_driver.c                    |  2 +
 lib/ethdev/rte_class_eth.c                    |  1 +
 lib/ethdev/sff_telemetry.c                    |  2 +
 lib/eventdev/rte_event_eth_rx_adapter.c       |  2 +
 lib/eventdev/rte_event_timer_adapter.c        |  2 +
 lib/gpudev/gpudev.c                           |  2 +
 lib/graph/graph.c                             |  1 +
 lib/graph/graph_ops.c                         |  1 +
 lib/graph/graph_stats.c                       |  1 +
 lib/graph/node.c                              |  1 +
 lib/ipsec/ipsec_telemetry.c                   |  1 +
 lib/meter/rte_meter.c                         |  1 +
 lib/metrics/rte_metrics.c                     |  1 +
 lib/node/ethdev_ctrl.c                        |  2 +
 lib/pci/rte_pci.c                             |  1 +
 lib/pdump/rte_pdump.c                         |  2 +
 lib/pipeline/rte_swx_ctl.c                    |  1 +
 lib/port/rte_swx_port_fd.c                    |  1 +
 lib/port/rte_swx_port_ring.c                  |  1 +
 lib/power/power_cppc_cpufreq.c                |  2 +
 lib/power/rte_power.c                         |  2 +
 lib/power/rte_power_pmd_mgmt.c                |  2 +
 lib/sched/rte_pie.c                           |  1 +
 lib/security/rte_security.c                   |  3 +
 lib/telemetry/telemetry.c                     |  2 +
 lib/telemetry/telemetry_data.c                |  3 +
 lib/telemetry/telemetry_legacy.c              |  3 +-
 lib/vhost/vhost.h                             |  1 +
 168 files changed, 301 insertions(+), 56 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v4 1/4] eal: fix pointer arithmetic with an expression argument
  2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
@ 2022-08-27 11:32       ` Dmitry Kozlyuk
  2022-08-27 11:32       ` [PATCH v4 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-27 11:32 UTC (permalink / raw)
  To: dev
  Cc: Dmitry Kozlyuk, stable, Morten Brørup, Bruce Richardson,
	Chengwen Feng

RTE_PTR_SUB(ptr, x) and RTE_PTR_ALIGN_FLOOR() worked incorrectly
if "ptr" was an expression:

    uint32_t arr[3];

    RTE_PTR_SUB(arr + 1, sizeof(arr[0]));
    // expected: (uint32_t *)((uintptr_t)(arr + 1) - 4) == arr
    // actual:   (uint32_t *)((uintptr_t) arr + 1  - 4) != arr

    RTE_PTR_ALIGN_FLOOR(arr + 2, sizeof(arr[0]));
    // expected: RTE_ALIGN_FLOOR((uintptr_t)(arr + 2), 4) == &arr[2]
    // actual:   RTE_ALIGN_FLOOR((uintptr_t) arr + 2,  4) == &arr[0]

Fix the macros and extend the relevant unit test.
Convert uses of a custom test failure macro to RTE_TEST_ASSERT*().

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_common.c       | 58 +++++++++++++++++++++++++-----------
 lib/eal/include/rte_common.h |  4 +--
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/app/test/test_common.c b/app/test/test_common.c
index ef177cecb1..f89e1eb7ee 100644
--- a/app/test/test_common.c
+++ b/app/test/test_common.c
@@ -25,31 +25,53 @@ test_macros(int __rte_unused unused_parm)
 #define SMALLER 0x1000U
 #define BIGGER 0x2000U
 #define PTR_DIFF BIGGER - SMALLER
-#define FAIL_MACRO(x)\
-	{printf(#x "() test failed!\n");\
-	return -1;}
 
 	uintptr_t unused = 0;
 	unsigned int smaller = SMALLER, bigger  = BIGGER;
+	uint32_t arr[3];
 
 	RTE_SET_USED(unused);
 
 	RTE_SWAP(smaller, bigger);
-	if (smaller != BIGGER && bigger != SMALLER)
-		FAIL_MACRO(RTE_SWAP);
-	if ((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF) != BIGGER)
-		FAIL_MACRO(RTE_PTR_ADD);
-	if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER)
-		FAIL_MACRO(RTE_PTR_SUB);
-	if (RTE_PTR_DIFF(BIGGER, SMALLER) != PTR_DIFF)
-		FAIL_MACRO(RTE_PTR_DIFF);
-	if (RTE_MAX(SMALLER, BIGGER) != BIGGER)
-		FAIL_MACRO(RTE_MAX);
-	if (RTE_MIN(SMALLER, BIGGER) != SMALLER)
-		FAIL_MACRO(RTE_MIN);
-
-	if (strncmp(RTE_STR(test), "test", sizeof("test")))
-		FAIL_MACRO(RTE_STR);
+	RTE_TEST_ASSERT(smaller == BIGGER && bigger == SMALLER,
+		"RTE_SWAP");
+	RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF), BIGGER,
+		"RTE_PTR_ADD");
+	RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF), SMALLER,
+		"RTE_PTR_SUB");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_DIFF(BIGGER, SMALLER), PTR_DIFF,
+		"RTE_PTR_DIFF");
+	RTE_TEST_ASSERT_EQUAL(RTE_MAX(SMALLER, BIGGER), BIGGER,
+		"RTE_MAX");
+	RTE_TEST_ASSERT_EQUAL(RTE_MIN(SMALLER, BIGGER), SMALLER,
+		"RTE_MIN");
+
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ADD(arr + 1, sizeof(arr[0])), &arr[2],
+		"RTE_PTR_ADD(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_SUB(arr + 1, sizeof(arr[0])), &arr[0],
+		"RTE_PTR_SUB(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_FLOOR(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN_FLOOR(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_CEIL(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(expr, x)");
+	RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN(arr + 2, 4), &arr[2],
+		"RTE_PTR_ALIGN(expr, x)");
+
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 1), 4), &arr[1],
+		"RTE_PTR_ALIGN_FLOOR(x < y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 3), 4), &arr[1],
+		"RTE_PTR_ALIGN_FLOOR(x > y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 3), 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(x < y/2, y)");
+	RTE_TEST_ASSERT_EQUAL(
+		RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 1), 4), &arr[2],
+		"RTE_PTR_ALIGN_CEIL(x > y/2, y)");
+
+	RTE_TEST_ASSERT(strncmp(RTE_STR(test), "test", sizeof("test")) == 0,
+		"RTE_STR");
 
 	return 0;
 }
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index a96cc2a138..d517e9f75f 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -295,7 +295,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 /**
  * subtract a byte-value offset from a pointer
  */
-#define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
+#define RTE_PTR_SUB(ptr, x) ((void *)((uintptr_t)(ptr) - (x)))
 
 /**
  * get the difference between two pointer values, i.e. how far apart
@@ -320,7 +320,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
  * must be a power-of-two value.
  */
 #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
-	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align))
+	((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))
 
 /**
  * Macro to align a value to a given power-of-two. The resultant value
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v4 2/4] eal: deduplicate roundup code
  2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  2022-08-27 11:32       ` [PATCH v4 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
@ 2022-08-27 11:32       ` Dmitry Kozlyuk
  2022-08-27 11:32       ` [PATCH v4 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-27 11:32 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk, Morten Brørup, Bruce Richardson, Chengwen Feng

RTE_CACHE_LINE_ROUNDUP() implementation repeated RTE_ALIGN_MUL_CEIL().
In other places RTE_CACHE_LINE_SIZE is assumed to be a power-of-2,
so define RTE_CACHE_LINE_ROUNDUP() using RTE_ALIGN_CEIL().

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/include/rte_common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index d517e9f75f..b65555bac6 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -425,9 +425,7 @@ rte_is_aligned(void *ptr, unsigned align)
 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
 
 /** Return the first cache-aligned value greater or equal to size. */
-#define RTE_CACHE_LINE_ROUNDUP(size) \
-	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
-	RTE_CACHE_LINE_SIZE))
+#define RTE_CACHE_LINE_ROUNDUP(size) RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE)
 
 /** Cache line size in terms of log2 */
 #if RTE_CACHE_LINE_SIZE == 64
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v4 3/4] eal: uninline rte_str_to_size
  2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
  2022-08-27 11:32       ` [PATCH v4 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
  2022-08-27 11:32       ` [PATCH v4 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
@ 2022-08-27 11:32       ` Dmitry Kozlyuk
  2022-08-27 11:32       ` [PATCH v4 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
  2022-09-21 13:30       ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup David Marchand
  4 siblings, 0 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-27 11:32 UTC (permalink / raw)
  To: dev
  Cc: Dmitry Kozlyuk, Ray Kinsella, Morten Brørup,
	Bruce Richardson, Chengwen Feng

There is no reason for rte_str_to_size() to be inline.
Move the implementation out of <rte_common.h>.
Export it as a stable ABI because it always has been public.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++++++
 lib/eal/include/rte_common.h           | 30 ++----------------------
 lib/eal/version.map                    |  1 +
 3 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 0236ae4023..5fc4ee71dc 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -64,3 +64,35 @@ rte_strscpy(char *dst, const char *src, size_t dsize)
 	rte_errno = E2BIG;
 	return -rte_errno;
 }
+
+uint64_t
+rte_str_to_size(const char *str)
+{
+	char *endptr;
+	unsigned long long size;
+
+	while (isspace((int)*str))
+		str++;
+	if (*str == '-')
+		return 0;
+
+	errno = 0;
+	size = strtoull(str, &endptr, 0);
+	if (errno)
+		return 0;
+
+	if (*endptr == ' ')
+		endptr++; /* allow 1 space gap */
+
+	switch (*endptr) {
+	case 'G': case 'g':
+		size *= 1024; /* fall-through */
+	case 'M': case 'm':
+		size *= 1024; /* fall-through */
+	case 'K': case 'k':
+		size *= 1024; /* fall-through */
+	default:
+		break;
+	}
+	return size;
+}
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index b65555bac6..86c50c55e0 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -873,34 +873,8 @@ rte_log2_u64(uint64_t v)
  * @return
  *     Number.
  */
-static inline uint64_t
-rte_str_to_size(const char *str)
-{
-	char *endptr;
-	unsigned long long size;
-
-	while (isspace((int)*str))
-		str++;
-	if (*str == '-')
-		return 0;
-
-	errno = 0;
-	size = strtoull(str, &endptr, 0);
-	if (errno)
-		return 0;
-
-	if (*endptr == ' ')
-		endptr++; /* allow 1 space gap */
-
-	switch (*endptr){
-	case 'G': case 'g': size *= 1024; /* fall-through */
-	case 'M': case 'm': size *= 1024; /* fall-through */
-	case 'K': case 'k': size *= 1024; /* fall-through */
-	default:
-		break;
-	}
-	return size;
-}
+uint64_t
+rte_str_to_size(const char *str);
 
 /**
  * Function to terminate the application immediately, printing an error
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 1f293e768b..773b0902c0 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -261,6 +261,7 @@ DPDK_23 {
 	rte_socket_id;
 	rte_socket_id_by_idx;
 	rte_srand;
+	rte_str_to_size;
 	rte_strerror;
 	rte_strscpy;
 	rte_strsplit;
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v4 4/4] eal: remove unneeded includes from a public header
  2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
                         ` (2 preceding siblings ...)
  2022-08-27 11:32       ` [PATCH v4 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
@ 2022-08-27 11:32       ` Dmitry Kozlyuk
  2022-08-29  8:29         ` Bruce Richardson
                           ` (2 more replies)
  2022-09-21 13:30       ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup David Marchand
  4 siblings, 3 replies; 29+ messages in thread
From: Dmitry Kozlyuk @ 2022-08-27 11:32 UTC (permalink / raw)
  To: dev; +Cc: Dmitry Kozlyuk

Do not include <ctype.h>, <errno.h>, and <stdlib.h> from <rte_common.h>,
because they are not used by this file.
Include the needed headers directly from the files that need them.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 app/test-bbdev/main.c                                    | 1 +
 app/test-bbdev/test_bbdev_perf.c                         | 1 +
 app/test-bbdev/test_bbdev_vector.c                       | 2 ++
 app/test-compress-perf/comp_perf_test_cyclecount.c       | 2 ++
 app/test-compress-perf/comp_perf_test_throughput.c       | 2 ++
 app/test-compress-perf/comp_perf_test_verify.c           | 2 ++
 app/test-compress-perf/main.c                            | 1 +
 app/test-crypto-perf/cperf_options_parsing.c             | 1 +
 app/test-crypto-perf/cperf_test_pmd_cyclecount.c         | 1 +
 app/test-crypto-perf/cperf_test_throughput.c             | 2 ++
 app/test-crypto-perf/cperf_test_vector_parsing.c         | 2 ++
 app/test-crypto-perf/cperf_test_verify.c                 | 2 ++
 app/test-crypto-perf/main.c                              | 1 +
 app/test-eventdev/evt_main.c                             | 1 +
 app/test-eventdev/evt_options.c                          | 1 +
 app/test-eventdev/parser.h                               | 1 +
 app/test-fib/main.c                                      | 1 +
 app/test-flow-perf/actions_gen.c                         | 1 +
 app/test-pmd/bpf_cmd.c                                   | 2 ++
 app/test-pmd/cmdline.c                                   | 1 +
 app/test-pmd/cmdline_tm.c                                | 2 ++
 app/test-pmd/config.c                                    | 1 +
 app/test-sad/main.c                                      | 1 +
 app/test/test.h                                          | 2 ++
 drivers/baseband/la12xx/bbdev_la12xx.c                   | 1 +
 drivers/baseband/null/bbdev_null.c                       | 1 +
 drivers/baseband/turbo_sw/bbdev_turbo_software.c         | 1 +
 drivers/bus/vdev/vdev_params.c                           | 1 +
 drivers/common/cnxk/cnxk_telemetry_nix.c                 | 1 +
 drivers/common/cnxk/cnxk_telemetry_npa.c                 | 1 +
 drivers/common/octeontx/octeontx_mbox.c                  | 1 +
 drivers/crypto/bcmfs/bcmfs_device.c                      | 1 +
 drivers/crypto/bcmfs/hw/bcmfs_rm_common.c                | 2 ++
 drivers/crypto/scheduler/scheduler_pmd.c                 | 3 +++
 drivers/dma/skeleton/skeleton_dmadev.c                   | 1 +
 drivers/event/dsw/dsw_event.c                            | 1 +
 drivers/event/octeontx/ssovf_evdev.c                     | 1 +
 drivers/event/octeontx/ssovf_evdev_selftest.c            | 2 ++
 drivers/event/opdl/opdl_evdev.c                          | 1 +
 drivers/event/opdl/opdl_test.c                           | 1 +
 drivers/event/sw/sw_evdev.c                              | 1 +
 drivers/event/sw/sw_evdev_selftest.c                     | 1 +
 drivers/net/af_packet/rte_eth_af_packet.c                | 1 +
 drivers/net/ark/ark_pktchkr.c                            | 1 +
 drivers/net/ark/ark_pktgen.c                             | 1 +
 drivers/net/atlantic/atl_hw_regs.h                       | 1 +
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c             | 2 ++
 drivers/net/failsafe/failsafe_intr.c                     | 1 +
 drivers/net/hns3/hns3_mp.c                               | 2 ++
 drivers/net/i40e/base/i40e_adminq.h                      | 2 ++
 drivers/net/i40e/i40e_ethdev.c                           | 1 +
 drivers/net/iavf/iavf_ethdev.c                           | 1 +
 drivers/net/ice/ice_dcf_parent.c                         | 1 +
 drivers/net/ice/ice_ddp_package.c                        | 2 ++
 drivers/net/ice/ice_ethdev.c                             | 1 +
 drivers/net/mlx4/mlx4_mp.c                               | 1 +
 drivers/net/null/rte_eth_null.c                          | 2 ++
 drivers/net/octeontx/base/octeontx_bgx.c                 | 1 +
 drivers/net/octeontx/octeontx_ethdev.c                   | 1 +
 drivers/net/octeontx_ep/otx2_ep_vf.c                     | 2 ++
 drivers/net/pcap/pcap_ethdev.c                           | 1 +
 drivers/net/ring/rte_eth_ring.c                          | 2 ++
 drivers/net/softnic/parser.h                             | 1 +
 drivers/net/tap/rte_eth_tap.c                            | 1 +
 drivers/net/vhost/rte_eth_vhost.c                        | 1 +
 drivers/net/virtio/virtio_ethdev.c                       | 1 +
 drivers/net/virtio/virtio_user/vhost_kernel.c            | 1 +
 drivers/net/virtio/virtio_user/vhost_user.c              | 1 +
 drivers/net/virtio/virtio_user/vhost_vdpa.c              | 1 +
 drivers/net/virtio/virtio_user/virtio_user_dev.c         | 1 +
 drivers/net/virtio/virtio_user_ethdev.c                  | 1 +
 drivers/raw/ifpga/base/osdep_rte/osdep_generic.h         | 2 ++
 drivers/raw/skeleton/skeleton_rawdev.c                   | 1 +
 drivers/raw/skeleton/skeleton_rawdev_test.c              | 2 ++
 examples/distributor/main.c                              | 1 +
 examples/dma/dmafwd.c                                    | 1 +
 examples/ethtool/ethtool-app/ethapp.c                    | 2 ++
 examples/eventdev_pipeline/main.c                        | 2 ++
 examples/eventdev_pipeline/pipeline_worker_generic.c     | 2 ++
 examples/eventdev_pipeline/pipeline_worker_tx.c          | 2 ++
 examples/fips_validation/fips_validation.c               | 2 ++
 examples/fips_validation/fips_validation_gcm.c           | 1 +
 examples/fips_validation/main.c                          | 1 +
 examples/ip_pipeline/main.c                              | 1 +
 examples/ip_pipeline/parser.h                            | 1 +
 examples/ipsec-secgw/event_helper.c                      | 2 ++
 examples/ipsec-secgw/flow.c                              | 1 +
 examples/ipsec-secgw/parser.c                            | 1 +
 examples/ipsec-secgw/parser.h                            | 1 +
 examples/ipsec-secgw/rt.c                                | 1 +
 examples/ipsec-secgw/sa.c                                | 1 +
 examples/l3fwd-power/perf_core.c                         | 2 ++
 examples/multi_process/client_server_mp/mp_server/init.c | 1 +
 examples/multi_process/simple_mp/main.c                  | 1 +
 examples/ntb/ntb_fwd.c                                   | 1 +
 examples/packet_ordering/main.c                          | 1 +
 examples/pipeline/cli.c                                  | 1 +
 examples/pipeline/main.c                                 | 1 +
 examples/ptpclient/ptpclient.c                           | 1 +
 examples/qos_meter/main.c                                | 1 +
 examples/qos_sched/init.c                                | 1 +
 examples/rxtx_callbacks/main.c                           | 1 +
 examples/server_node_efd/server/init.c                   | 1 +
 examples/skeleton/basicfwd.c                             | 1 +
 examples/vdpa/main.c                                     | 1 +
 examples/vhost/main.c                                    | 2 ++
 examples/vhost/virtio_net.c                              | 1 +
 examples/vhost_blk/vhost_blk.c                           | 1 +
 lib/bpf/bpf_jit_arm64.c                                  | 1 +
 lib/bpf/bpf_validate.c                                   | 1 +
 lib/compressdev/rte_compressdev_pmd.c                    | 2 ++
 lib/cryptodev/cryptodev_pmd.c                            | 1 +
 lib/distributor/rte_distributor.c                        | 1 +
 lib/dmadev/rte_dmadev.c                                  | 2 ++
 lib/eal/arm/rte_power_intrinsics.c                       | 2 ++
 lib/eal/common/eal_common_debug.c                        | 2 ++
 lib/eal/common/eal_common_dev.c                          | 1 +
 lib/eal/common/eal_common_devargs.c                      | 1 +
 lib/eal/common/eal_common_dynmem.c                       | 1 +
 lib/eal/common/eal_common_lcore.c                        | 1 +
 lib/eal/common/eal_common_memalloc.c                     | 1 +
 lib/eal/common/eal_common_string_fns.c                   | 4 +++-
 lib/eal/common/eal_common_trace.c                        | 1 +
 lib/eal/common/eal_common_trace_ctf.c                    | 1 +
 lib/eal/common/hotplug_mp.c                              | 1 +
 lib/eal/common/malloc_mp.c                               | 1 +
 lib/eal/freebsd/eal.c                                    | 1 +
 lib/eal/include/generic/rte_rwlock.h                     | 2 ++
 lib/eal/include/rte_common.h                             | 3 ---
 lib/eal/linux/eal.c                                      | 1 +
 lib/eal/linux/eal_alarm.c                                | 1 +
 lib/eal/linux/eal_dev.c                                  | 1 +
 lib/eal/linux/eal_vfio_mp_sync.c                         | 1 +
 lib/eal/ppc/rte_power_intrinsics.c                       | 2 ++
 lib/eal/riscv/rte_power_intrinsics.c                     | 2 ++
 lib/eal/unix/eal_unix_timer.c                            | 1 +
 lib/eal/windows/rte_thread.c                             | 2 ++
 lib/efd/rte_efd.c                                        | 2 ++
 lib/ethdev/ethdev_driver.c                               | 2 ++
 lib/ethdev/rte_class_eth.c                               | 1 +
 lib/ethdev/sff_telemetry.c                               | 2 ++
 lib/eventdev/rte_event_eth_rx_adapter.c                  | 2 ++
 lib/eventdev/rte_event_timer_adapter.c                   | 2 ++
 lib/gpudev/gpudev.c                                      | 2 ++
 lib/graph/graph.c                                        | 1 +
 lib/graph/graph_ops.c                                    | 1 +
 lib/graph/graph_stats.c                                  | 1 +
 lib/graph/node.c                                         | 1 +
 lib/ipsec/ipsec_telemetry.c                              | 1 +
 lib/meter/rte_meter.c                                    | 1 +
 lib/metrics/rte_metrics.c                                | 1 +
 lib/node/ethdev_ctrl.c                                   | 2 ++
 lib/pci/rte_pci.c                                        | 1 +
 lib/pdump/rte_pdump.c                                    | 2 ++
 lib/pipeline/rte_swx_ctl.c                               | 1 +
 lib/port/rte_swx_port_fd.c                               | 1 +
 lib/port/rte_swx_port_ring.c                             | 1 +
 lib/power/power_cppc_cpufreq.c                           | 2 ++
 lib/power/rte_power.c                                    | 2 ++
 lib/power/rte_power_pmd_mgmt.c                           | 2 ++
 lib/sched/rte_pie.c                                      | 1 +
 lib/security/rte_security.c                              | 3 +++
 lib/telemetry/telemetry.c                                | 2 ++
 lib/telemetry/telemetry_data.c                           | 3 +++
 lib/telemetry/telemetry_legacy.c                         | 3 ++-
 lib/vhost/vhost.h                                        | 1 +
 166 files changed, 223 insertions(+), 5 deletions(-)

diff --git a/app/test-bbdev/main.c b/app/test-bbdev/main.c
index ff65173fdb..ec830eb32b 100644
--- a/app/test-bbdev/main.c
+++ b/app/test-bbdev/main.c
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include <rte_eal.h>
 #include <rte_common.h>
diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-bbdev/test_bbdev_perf.c
index 8fab52d821..311e5d1a96 100644
--- a/app/test-bbdev/test_bbdev_perf.c
+++ b/app/test-bbdev/test_bbdev_perf.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <math.h>
 
diff --git a/app/test-bbdev/test_bbdev_vector.c b/app/test-bbdev/test_bbdev_vector.c
index f020836f88..f1c1fe09eb 100644
--- a/app/test-bbdev/test_bbdev_vector.c
+++ b/app/test-bbdev/test_bbdev_vector.c
@@ -5,7 +5,9 @@
 #ifdef RTE_EXEC_ENV_FREEBSD
 	#define _WITH_GETLINE
 #endif
+#include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdbool.h>
 #include <rte_malloc.h>
 
diff --git a/app/test-compress-perf/comp_perf_test_cyclecount.c b/app/test-compress-perf/comp_perf_test_cyclecount.c
index a3f6404eb2..7473cb6277 100644
--- a/app/test-compress-perf/comp_perf_test_cyclecount.c
+++ b/app/test-compress-perf/comp_perf_test_cyclecount.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_malloc.h>
 #include <rte_eal.h>
 #include <rte_log.h>
diff --git a/app/test-compress-perf/comp_perf_test_throughput.c b/app/test-compress-perf/comp_perf_test_throughput.c
index 4569599eb9..79cd2b2bf2 100644
--- a/app/test-compress-perf/comp_perf_test_throughput.c
+++ b/app/test-compress-perf/comp_perf_test_throughput.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_malloc.h>
 #include <rte_eal.h>
 #include <rte_log.h>
diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c
index 7d06029488..8964442891 100644
--- a/app/test-compress-perf/comp_perf_test_verify.c
+++ b/app/test-compress-perf/comp_perf_test_verify.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_malloc.h>
 #include <rte_eal.h>
 #include <rte_log.h>
diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index ce9e80bedc..41b8edc2bd 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <unistd.h>
diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index 10793ec82f..bc5e312c81 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -3,6 +3,7 @@
  */
 
 #include <getopt.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <rte_cryptodev.h>
diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
index 6b4d09e623..3f2da13d3a 100644
--- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
+++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include <rte_crypto.h>
 #include <rte_cryptodev.h>
diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c
index cecf30e470..fba66bbde9 100644
--- a/app/test-crypto-perf/cperf_test_throughput.c
+++ b/app/test-crypto-perf/cperf_test_throughput.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2016-2017 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 #include <rte_crypto.h>
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 87f3a90055..98e46c3381 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -4,7 +4,9 @@
 #ifdef RTE_EXEC_ENV_FREEBSD
 	#define _WITH_GETLINE
 #endif
+#include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <rte_malloc.h>
 
diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 5c0dc82290..b691595675 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2016-2017 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 #include <rte_crypto.h>
diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 17e30a8e74..27acd619bc 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <rte_malloc.h>
diff --git a/app/test-eventdev/evt_main.c b/app/test-eventdev/evt_main.c
index b785e603ee..5c7ac2cce9 100644
--- a/app/test-eventdev/evt_main.c
+++ b/app/test-eventdev/evt_main.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
 
diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c
index 8922831da1..6c3e0e5b6a 100644
--- a/app/test-eventdev/evt_options.c
+++ b/app/test-eventdev/evt_options.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <inttypes.h>
 #include <getopt.h>
diff --git a/app/test-eventdev/parser.h b/app/test-eventdev/parser.h
index 696b40a3e2..954371b5b8 100644
--- a/app/test-eventdev/parser.h
+++ b/app/test-eventdev/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_PARSER_H__
 #define __INCLUDE_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #define PARSE_DELIMITER				" \f\n\r\t\v"
diff --git a/app/test-fib/main.c b/app/test-fib/main.c
index 830c32cc44..eafd4e2be0 100644
--- a/app/test-fib/main.c
+++ b/app/test-fib/main.c
@@ -3,6 +3,7 @@
  */
 
 #include <getopt.h>
+#include <stdlib.h>
 #include <string.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
diff --git a/app/test-flow-perf/actions_gen.c b/app/test-flow-perf/actions_gen.c
index 13e1b82389..63f05d87fa 100644
--- a/app/test-flow-perf/actions_gen.c
+++ b/app/test-flow-perf/actions_gen.c
@@ -6,6 +6,7 @@
  * and initializing it with needed data.
  */
 
+#include <stdlib.h>
 #include <sys/types.h>
 #include <rte_malloc.h>
 #include <rte_flow.h>
diff --git a/app/test-pmd/bpf_cmd.c b/app/test-pmd/bpf_cmd.c
index 648e0e9294..46f6b7d6d2 100644
--- a/app/test-pmd/bpf_cmd.c
+++ b/app/test-pmd/bpf_cmd.c
@@ -2,7 +2,9 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
+
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
 #include <rte_flow.h>
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b4fe9dfb17..07566c7a77 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index fb56a234c5..1bc6c00998 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <ctype.h>
+
 #include <cmdline_parse.h>
 #include <cmdline_parse_num.h>
 #include <cmdline_parse_string.h>
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a2939867c4..86054455d2 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3,6 +3,7 @@
  * Copyright 2013-2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/app/test-sad/main.c b/app/test-sad/main.c
index 1024757add..addfc07145 100644
--- a/app/test-sad/main.c
+++ b/app/test-sad/main.c
@@ -7,6 +7,7 @@
 #include <getopt.h>
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
diff --git a/app/test/test.h b/app/test/test.h
index 7115edf469..85f57efbc6 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -5,7 +5,9 @@
 #ifndef _TEST_H_
 #define _TEST_H_
 
+#include <errno.h>
 #include <stddef.h>
+#include <stdlib.h>
 #include <sys/queue.h>
 
 #include <rte_hexdump.h>
diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c b/drivers/baseband/la12xx/bbdev_la12xx.c
index 4d1bd16751..4e47d9342c 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -2,6 +2,7 @@
  * Copyright 2020-2021 NXP
  */
 
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 248e12987f..eeab25941c 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_common.h>
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index af7bc416f9..c01a04fed5 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_common.h>
diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c
index 3969faf16d..3d6f63344a 100644
--- a/drivers/bus/vdev/vdev_params.c
+++ b/drivers/bus/vdev/vdev_params.c
@@ -2,6 +2,7 @@
  * Copyright 2018 Gaëtan Rivet
  */
 
+#include <errno.h>
 #include <string.h>
 
 #include <rte_dev.h>
diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
index 4119e9ee4f..b7285cf137 100644
--- a/drivers/common/cnxk/cnxk_telemetry_nix.c
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <ctype.h>
 #include "cnxk_telemetry.h"
 #include "roc_api.h"
 #include "roc_priv.h"
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
index ae515df84f..b6ae108b10 100644
--- a/drivers/common/cnxk/cnxk_telemetry_npa.c
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <ctype.h>
 #include "cnxk_telemetry.h"
 #include "roc_api.h"
 #include "roc_priv.h"
diff --git a/drivers/common/octeontx/octeontx_mbox.c b/drivers/common/octeontx/octeontx_mbox.c
index f414267e4f..4fd3fda721 100644
--- a/drivers/common/octeontx/octeontx_mbox.c
+++ b/drivers/common/octeontx/octeontx_mbox.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Cavium, Inc
  */
 
+#include <errno.h>
 #include <string.h>
 
 #include <rte_atomic.h>
diff --git a/drivers/crypto/bcmfs/bcmfs_device.c b/drivers/crypto/bcmfs/bcmfs_device.c
index 27720e4eb8..ada7ba342c 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -5,6 +5,7 @@
 
 #include <dirent.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <sys/queue.h>
 
 #include <rte_malloc.h>
diff --git a/drivers/crypto/bcmfs/hw/bcmfs_rm_common.c b/drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
index 9445d28f92..3424294fc9 100644
--- a/drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
+++ b/drivers/crypto/bcmfs/hw/bcmfs_rm_common.c
@@ -3,6 +3,8 @@
  * All rights reserved.
  */
 
+#include <errno.h>
+
 #include "bcmfs_hw_defs.h"
 #include "bcmfs_rm_common.h"
 
diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c
index dd198080bf..c22d732180 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -1,6 +1,9 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Intel Corporation
  */
+#include <ctype.h>
+#include <stdlib.h>
+
 #include <rte_common.h>
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
index 82b4661323..fbe4a374f4 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -3,6 +3,7 @@
  */
 
 #include <inttypes.h>
+#include <stdlib.h>
 
 #include <rte_bus_vdev.h>
 #include <rte_cycles.h>
diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index e209cd5b00..340561b4e6 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -9,6 +9,7 @@
 #endif
 
 #include <stdbool.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_cycles.h>
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 9e14e35d10..f10a699674 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -3,6 +3,7 @@
  */
 
 #include <inttypes.h>
+#include <stdlib.h>
 
 #include <rte_common.h>
 #include <cryptodev_pmd.h>
diff --git a/drivers/event/octeontx/ssovf_evdev_selftest.c b/drivers/event/octeontx/ssovf_evdev_selftest.c
index b55523632a..3d945d67dd 100644
--- a/drivers/event/octeontx/ssovf_evdev_selftest.c
+++ b/drivers/event/octeontx/ssovf_evdev_selftest.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2017 Cavium, Inc
  */
 
+#include <stdlib.h>
+
 #include <rte_atomic.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 8b6890b220..53d637bc6b 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -3,6 +3,7 @@
  */
 
 #include <inttypes.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_bus_vdev.h>
diff --git a/drivers/event/opdl/opdl_test.c b/drivers/event/opdl/opdl_test.c
index 24b92df476..c251478d59 100644
--- a/drivers/event/opdl/opdl_test.c
+++ b/drivers/event/opdl/opdl_test.c
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/queue.h>
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index f93313b31b..309b988d82 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -3,6 +3,7 @@
  */
 
 #include <inttypes.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_bus_vdev.h>
diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c
index cb97a4d615..72d745fbec 100644
--- a/drivers/event/sw/sw_evdev_selftest.c
+++ b/drivers/event/sw/sw_evdev_selftest.c
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/queue.h>
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 1396f32c3d..cbcb46049e 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
 #include <unistd.h>
diff --git a/drivers/net/ark/ark_pktchkr.c b/drivers/net/ark/ark_pktchkr.c
index 12a5abb2f7..e1f336c73c 100644
--- a/drivers/net/ark/ark_pktchkr.c
+++ b/drivers/net/ark/ark_pktchkr.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2015-2018 Atomic Rules LLC
  */
 
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <rte_string_fns.h>
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 6195ef997f..cd2d3adc51 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2015-2018 Atomic Rules LLC
  */
 
+#include <stdlib.h>
 #include <unistd.h>
 #include <pthread.h>
 
diff --git a/drivers/net/atlantic/atl_hw_regs.h b/drivers/net/atlantic/atl_hw_regs.h
index 4f6cd35774..9d63804960 100644
--- a/drivers/net/atlantic/atl_hw_regs.h
+++ b/drivers/net/atlantic/atl_hw_regs.h
@@ -8,6 +8,7 @@
 #ifndef AQ_HW_UTILS_H
 #define AQ_HW_UTILS_H
 
+#include <errno.h>
 #include <rte_common.h>
 #include <rte_io.h>
 #include <rte_byteorder.h>
diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
index bfdbd1ee5d..c38af63bdc 100644
--- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
+++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
@@ -2,6 +2,8 @@
  * Copyright(C) 2022 Marvell.
  */
 
+#include <ctype.h>
+
 #include <rte_telemetry.h>
 
 #include <roc_api.h>
diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c
index 14b87a54ab..969ded6ced 100644
--- a/drivers/net/failsafe/failsafe_intr.c
+++ b/drivers/net/failsafe/failsafe_intr.c
@@ -10,6 +10,7 @@
 #if defined(LINUX)
 #include <sys/epoll.h>
 #endif
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <rte_alarm.h>
diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c
index e74ddea195..7184f9ad58 100644
--- a/drivers/net/hns3/hns3_mp.c
+++ b/drivers/net/hns3/hns3_mp.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2018-2021 HiSilicon Limited.
  */
 
+#include <stdlib.h>
+
 #include <rte_eal.h>
 #include <ethdev_driver.h>
 #include <rte_string_fns.h>
diff --git a/drivers/net/i40e/base/i40e_adminq.h b/drivers/net/i40e/base/i40e_adminq.h
index 6ce262ad4b..75a17b2ac2 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -5,6 +5,8 @@
 #ifndef _I40E_ADMINQ_H_
 #define _I40E_ADMINQ_H_
 
+#include <errno.h>
+
 #include "i40e_osdep.h"
 #include "i40e_status.h"
 #include "i40e_adminq_cmd.h"
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67d79de08d..36ca42aa87 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 506fcff6e3..652f0d00a5 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <sys/queue.h>
 #include <stdio.h>
 #include <errno.h>
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index 2f96dedcce..d69aff60cd 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2020 Intel Corporation
  */
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <pthread.h>
diff --git a/drivers/net/ice/ice_ddp_package.c b/drivers/net/ice/ice_ddp_package.c
index c7b5dc7ee7..8c2844604b 100644
--- a/drivers/net/ice/ice_ddp_package.c
+++ b/drivers/net/ice/ice_ddp_package.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
 #include <rte_tailq.h>
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index b2300790ae..e8304a1f2b 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -5,6 +5,7 @@
 #include <rte_string_fns.h>
 #include <ethdev_pci.h>
 
+#include <ctype.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/drivers/net/mlx4/mlx4_mp.c b/drivers/net/mlx4/mlx4_mp.c
index 1da64910aa..3282afceda 100644
--- a/drivers/net/mlx4/mlx4_mp.c
+++ b/drivers/net/mlx4/mlx4_mp.c
@@ -4,6 +4,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <time.h>
 
 #include <rte_eal.h>
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index bb89c1abc4..4279e86a09 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -3,6 +3,8 @@
  *  All rights reserved.
  */
 
+#include <stdlib.h>
+
 #include <rte_mbuf.h>
 #include <ethdev_driver.h>
 #include <ethdev_vdev.h>
diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
index 1eacecbccc..7aa4cbd1fa 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.c
+++ b/drivers/net/octeontx/base/octeontx_bgx.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Cavium, Inc
  */
 
+#include <errno.h>
 #include <string.h>
 
 #include "octeontx_bgx.h"
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index 3aca53fb98..8419c4e501 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -6,6 +6,7 @@
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
diff --git a/drivers/net/octeontx_ep/otx2_ep_vf.c b/drivers/net/octeontx_ep/otx2_ep_vf.c
index 85e14a998f..94d153bf5c 100644
--- a/drivers/net/octeontx_ep/otx2_ep_vf.c
+++ b/drivers/net/octeontx_ep/otx2_ep_vf.c
@@ -2,6 +2,8 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <errno.h>
+
 #include <rte_common.h>
 #include <rte_cycles.h>
 #include "otx_ep_common.h"
diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index ec29fd6bc5..5029649059 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -4,6 +4,7 @@
  * All rights reserved.
  */
 
+#include <stdlib.h>
 #include <time.h>
 
 #include <pcap.h>
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index cfb81da5fe..77413c4988 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2010-2015 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include "rte_eth_ring.h"
 #include <rte_mbuf.h>
 #include <ethdev_driver.h>
diff --git a/drivers/net/softnic/parser.h b/drivers/net/softnic/parser.h
index 6f408b2485..c17a5d8ef0 100644
--- a/drivers/net/softnic/parser.h
+++ b/drivers/net/softnic/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_SOFTNIC_PARSER_H__
 #define __INCLUDE_SOFTNIC_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #include <rte_ip.h>
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 9e1032fe72..73715f058f 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -30,6 +30,7 @@
 #include <signal.h>
 #include <stdbool.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <sys/uio.h>
 #include <unistd.h>
 #include <arpa/inet.h>
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 7e512d94bf..5ab2b61d90 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2016 IGEL Co., Ltd.
  * Copyright(c) 2016-2018 Intel Corporation
  */
+#include <stdlib.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <stdbool.h>
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index d180162abd..12ddfa6311 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -5,6 +5,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
 
diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c
index 1aed08b2bd..e42bb35935 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -7,6 +7,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <stdlib.h>
 
 #include <rte_memory.h>
 
diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index 198bd63d3c..3c05ac9cc0 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -8,6 +8,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/un.h>
+#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 
diff --git a/drivers/net/virtio/virtio_user/vhost_vdpa.c b/drivers/net/virtio/virtio_user/vhost_vdpa.c
index bd13fe44b4..a0897f8dd1 100644
--- a/drivers/net/virtio/virtio_user/vhost_vdpa.c
+++ b/drivers/net/virtio/virtio_user/vhost_vdpa.c
@@ -6,6 +6,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <rte_memory.h>
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index f9cada05e4..19599aa3f6 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -4,6 +4,7 @@
 
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index a7d7063c2a..3ea8bdbf91 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <fcntl.h>
diff --git a/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h b/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
index 68499e65fb..33041c907e 100644
--- a/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
+++ b/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
@@ -5,6 +5,8 @@
 #ifndef _OSDEP_RTE_GENERIC_H
 #define _OSDEP_RTE_GENERIC_H
 
+#include <stdlib.h>
+
 #include <rte_common.h>
 #include <rte_cycles.h>
 #include <rte_spinlock.h>
diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c
index 16ecae3d92..610f856d15 100644
--- a/drivers/raw/skeleton/skeleton_rawdev.c
+++ b/drivers/raw/skeleton/skeleton_rawdev.c
@@ -5,6 +5,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <stdint.h>
 #include <inttypes.h>
diff --git a/drivers/raw/skeleton/skeleton_rawdev_test.c b/drivers/raw/skeleton/skeleton_rawdev_test.c
index 693b24c415..858e711e6f 100644
--- a/drivers/raw/skeleton/skeleton_rawdev_test.c
+++ b/drivers/raw/skeleton/skeleton_rawdev_test.c
@@ -2,6 +2,8 @@
  * Copyright 2017 NXP
  */
 
+#include <stdlib.h>
+
 #include <rte_common.h>
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 8995806b4e..68f07cc7fb 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <unistd.h>
 #include <signal.h>
diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c
index 67b5a9b22b..b5b50b413c 100644
--- a/examples/dma/dmafwd.c
+++ b/examples/dma/dmafwd.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <getopt.h>
 #include <signal.h>
 #include <stdbool.h>
diff --git a/examples/ethtool/ethtool-app/ethapp.c b/examples/ethtool/ethtool-app/ethapp.c
index 78e86534e8..4ea504ed6a 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2015 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <cmdline_parse.h>
 #include <cmdline_parse_num.h>
 #include <cmdline_parse_string.h>
diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index 3dbef6ed45..8d6c90f15d 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -2,9 +2,11 @@
  * Copyright(c) 2016-2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <getopt.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <signal.h>
 #include <sched.h>
 
diff --git a/examples/eventdev_pipeline/pipeline_worker_generic.c b/examples/eventdev_pipeline/pipeline_worker_generic.c
index c564c808e2..783f68c91e 100644
--- a/examples/eventdev_pipeline/pipeline_worker_generic.c
+++ b/examples/eventdev_pipeline/pipeline_worker_generic.c
@@ -4,6 +4,8 @@
  * Copyright 2017 Cavium, Inc.
  */
 
+#include <stdlib.h>
+
 #include "pipeline_common.h"
 
 static __rte_always_inline int
diff --git a/examples/eventdev_pipeline/pipeline_worker_tx.c b/examples/eventdev_pipeline/pipeline_worker_tx.c
index a82e064c1c..98a52f3892 100644
--- a/examples/eventdev_pipeline/pipeline_worker_tx.c
+++ b/examples/eventdev_pipeline/pipeline_worker_tx.c
@@ -4,6 +4,8 @@
  * Copyright 2017 Cavium, Inc.
  */
 
+#include <stdlib.h>
+
 #include "pipeline_common.h"
 
 static __rte_always_inline void
diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 12b9b03f56..cd905b2c5b 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -2,7 +2,9 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_string_fns.h>
diff --git a/examples/fips_validation/fips_validation_gcm.c b/examples/fips_validation/fips_validation_gcm.c
index 6b3d158629..db8208a5b6 100644
--- a/examples/fips_validation/fips_validation_gcm.c
+++ b/examples/fips_validation/fips_validation_gcm.c
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <time.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #ifdef USE_JANSSON
 #include <jansson.h>
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 8bd5a66889..e6c0b6a3a1 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -5,6 +5,7 @@
 #include <sys/stat.h>
 #include <getopt.h>
 #include <dirent.h>
+#include <stdlib.h>
 
 #include <rte_cryptodev.h>
 #include <rte_malloc.h>
diff --git a/examples/ip_pipeline/main.c b/examples/ip_pipeline/main.c
index c4aba39431..e35d9bce39 100644
--- a/examples/ip_pipeline/main.c
+++ b/examples/ip_pipeline/main.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/examples/ip_pipeline/parser.h b/examples/ip_pipeline/parser.h
index 4538f675d4..5224b18a89 100644
--- a/examples/ip_pipeline/parser.h
+++ b/examples/ip_pipeline/parser.h
@@ -5,6 +5,7 @@
 #ifndef __INCLUDE_PARSER_H__
 #define __INCLUDE_PARSER_H__
 
+#include <ctype.h>
 #include <stdint.h>
 
 #include <rte_ip.h>
diff --git a/examples/ipsec-secgw/event_helper.c b/examples/ipsec-secgw/event_helper.c
index b36f20a3fd..22b1760949 100644
--- a/examples/ipsec-secgw/event_helper.c
+++ b/examples/ipsec-secgw/event_helper.c
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright (C) 2020 Marvell International Ltd.
  */
+#include <stdlib.h>
+
 #include <rte_bitmap.h>
 #include <rte_ethdev.h>
 #include <rte_eventdev.h>
diff --git a/examples/ipsec-secgw/flow.c b/examples/ipsec-secgw/flow.c
index aee97b2fc4..e6a5120e80 100644
--- a/examples/ipsec-secgw/flow.c
+++ b/examples/ipsec-secgw/flow.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <rte_common.h>
 #include <rte_flow.h>
diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.c
index 98dff93b87..98f8176651 100644
--- a/examples/ipsec-secgw/parser.c
+++ b/examples/ipsec-secgw/parser.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2016 Intel Corporation
  */
+#include <stdlib.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
 
diff --git a/examples/ipsec-secgw/parser.h b/examples/ipsec-secgw/parser.h
index a0ff7e1b3f..b5c5d0210f 100644
--- a/examples/ipsec-secgw/parser.h
+++ b/examples/ipsec-secgw/parser.h
@@ -5,6 +5,7 @@
 #ifndef __PARSER_H
 #define __PARSER_H
 
+#include <ctype.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
diff --git a/examples/ipsec-secgw/rt.c b/examples/ipsec-secgw/rt.c
index ec3a375f0f..ce854ccb60 100644
--- a/examples/ipsec-secgw/rt.c
+++ b/examples/ipsec-secgw/rt.c
@@ -5,6 +5,7 @@
 /*
  * Routing Table (RT)
  */
+#include <stdlib.h>
 #include <sys/types.h>
 #include <rte_lpm.h>
 #include <rte_lpm6.h>
diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 5dca578790..396b9f9694 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -5,6 +5,7 @@
 /*
  * Security Associations
  */
+#include <stdlib.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
diff --git a/examples/l3fwd-power/perf_core.c b/examples/l3fwd-power/perf_core.c
index 4705967ea2..41ef6d0c9a 100644
--- a/examples/l3fwd-power/perf_core.c
+++ b/examples/l3fwd-power/perf_core.c
@@ -2,7 +2,9 @@
  * Copyright(c) 2010-2018 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_common.h>
diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c
index a4d7a3e543..65713dbea8 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -4,6 +4,7 @@
 
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/queue.h>
 #include <errno.h>
diff --git a/examples/multi_process/simple_mp/main.c b/examples/multi_process/simple_mp/main.c
index 9d5f1088b0..d73d1358ff 100644
--- a/examples/multi_process/simple_mp/main.c
+++ b/examples/multi_process/simple_mp/main.c
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <stdarg.h>
 #include <errno.h>
diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
index 81964d0308..fa59a3d8fe 100644
--- a/examples/ntb/ntb_fwd.c
+++ b/examples/ntb/ntb_fwd.c
@@ -3,6 +3,7 @@
  */
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <unistd.h>
 #include <signal.h>
diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c
index 99e67ef67b..d2fd6f77e4 100644
--- a/examples/packet_ordering/main.c
+++ b/examples/packet_ordering/main.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2016 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <signal.h>
 #include <getopt.h>
 
diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index ad553f19ab..41eefbaae8 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/examples/pipeline/main.c b/examples/pipeline/main.c
index 8ea19f9dd5..6fb839f4cb 100644
--- a/examples/pipeline/main.c
+++ b/examples/pipeline/main.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 1f1c9c9c52..cdf2da64df 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -9,6 +9,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <rte_eal.h>
 #include <rte_ethdev.h>
diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index a0f78e4ad6..723781fde1 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <getopt.h>
 
 #include <rte_common.h>
diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c
index e8b819ffb9..c8092c385d 100644
--- a/examples/qos_sched/init.c
+++ b/examples/qos_sched/init.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <memory.h>
 
 #include <rte_log.h>
diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c
index 1903d8b095..edf0ab9b08 100644
--- a/examples/rxtx_callbacks/main.c
+++ b/examples/rxtx_callbacks/main.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <getopt.h>
 #include <rte_eal.h>
diff --git a/examples/server_node_efd/server/init.c b/examples/server_node_efd/server/init.c
index 0e5e3b5a98..9c89f6b60d 100644
--- a/examples/server_node_efd/server/init.c
+++ b/examples/server_node_efd/server/init.c
@@ -4,6 +4,7 @@
 
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/queue.h>
 #include <errno.h>
diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c
index 518cd72179..133293cf15 100644
--- a/examples/skeleton/basicfwd.c
+++ b/examples/skeleton/basicfwd.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <rte_eal.h>
 #include <rte_ethdev.h>
diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
index 7e11ef4e26..6ccac6b8dc 100644
--- a/examples/vdpa/main.c
+++ b/examples/vdpa/main.c
@@ -5,6 +5,7 @@
 #include <getopt.h>
 #include <signal.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 7e1666f42a..0fa4753e70 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2017 Intel Corporation
  */
 
+#include <ctype.h>
 #include <arpa/inet.h>
 #include <getopt.h>
 #include <linux/if_ether.h>
@@ -10,6 +11,7 @@
 #include <linux/virtio_ring.h>
 #include <signal.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <sys/eventfd.h>
 #include <sys/param.h>
 #include <unistd.h>
diff --git a/examples/vhost/virtio_net.c b/examples/vhost/virtio_net.c
index 2432a96566..1d4737f9bb 100644
--- a/examples/vhost/virtio_net.c
+++ b/examples/vhost/virtio_net.c
@@ -4,6 +4,7 @@
 
 #include <stdint.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <linux/virtio_net.h>
 
 #include <rte_mbuf.h>
diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 2cab1e6994..3709d7ed06 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -9,6 +9,7 @@
 #include <sched.h>
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <stdbool.h>
 #include <signal.h>
diff --git a/lib/bpf/bpf_jit_arm64.c b/lib/bpf/bpf_jit_arm64.c
index a5a5d46f06..db79ff7385 100644
--- a/lib/bpf/bpf_jit_arm64.c
+++ b/lib/bpf/bpf_jit_arm64.c
@@ -4,6 +4,7 @@
 
 #include <errno.h>
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c
index 9ff86fc970..61cbb42216 100644
--- a/lib/bpf/bpf_validate.c
+++ b/lib/bpf/bpf_validate.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <stdint.h>
diff --git a/lib/compressdev/rte_compressdev_pmd.c b/lib/compressdev/rte_compressdev_pmd.c
index 7f500d76d4..d53bf65f7a 100644
--- a/lib/compressdev/rte_compressdev_pmd.c
+++ b/lib/compressdev/rte_compressdev_pmd.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2017-2018 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_string_fns.h>
 #include <rte_malloc.h>
 #include <rte_kvargs.h>
diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
index 1903ade388..dad4134885 100644
--- a/lib/cryptodev/cryptodev_pmd.c
+++ b/lib/cryptodev/cryptodev_pmd.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <sys/queue.h>
 #include <rte_errno.h>
 #include <rte_string_fns.h>
diff --git a/lib/distributor/rte_distributor.c b/lib/distributor/rte_distributor.c
index 3035b7a999..3969b2ea7e 100644
--- a/lib/distributor/rte_distributor.c
+++ b/lib/distributor/rte_distributor.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/queue.h>
 #include <string.h>
 #include <rte_mbuf.h>
diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 174d4c40ae..60c2c14e84 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -3,7 +3,9 @@
  * Copyright(c) 2021 Intel Corporation
  */
 
+#include <ctype.h>
 #include <inttypes.h>
+#include <stdlib.h>
 
 #include <rte_eal.h>
 #include <rte_lcore.h>
diff --git a/lib/eal/arm/rte_power_intrinsics.c b/lib/eal/arm/rte_power_intrinsics.c
index 78f55b7203..13f6a3264d 100644
--- a/lib/eal/arm/rte_power_intrinsics.c
+++ b/lib/eal/arm/rte_power_intrinsics.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2021 Intel Corporation
  */
 
+#include <errno.h>
+
 #include "rte_power_intrinsics.h"
 
 /**
diff --git a/lib/eal/common/eal_common_debug.c b/lib/eal/common/eal_common_debug.c
index 15418e957f..dcb554af1e 100644
--- a/lib/eal/common/eal_common_debug.c
+++ b/lib/eal/common/eal_common_debug.c
@@ -3,6 +3,8 @@
  */
 
 #include <stdarg.h>
+#include <stdlib.h>
+
 #include <rte_eal.h>
 #include <rte_log.h>
 #include <rte_debug.h>
diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index 9d913e5478..ca87cf0523 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -4,6 +4,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/queue.h>
 
diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
index d5833af373..bde1accf04 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -7,6 +7,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
 
diff --git a/lib/eal/common/eal_common_dynmem.c b/lib/eal/common/eal_common_dynmem.c
index c1e1889f5c..52e52e5986 100644
--- a/lib/eal/common/eal_common_dynmem.c
+++ b/lib/eal/common/eal_common_dynmem.c
@@ -4,6 +4,7 @@
  */
 
 #include <inttypes.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_log.h>
diff --git a/lib/eal/common/eal_common_lcore.c b/lib/eal/common/eal_common_lcore.c
index 11092791a4..06c594b022 100644
--- a/lib/eal/common/eal_common_lcore.c
+++ b/lib/eal/common/eal_common_lcore.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_common.h>
diff --git a/lib/eal/common/eal_common_memalloc.c b/lib/eal/common/eal_common_memalloc.c
index f8770ff835..ab04479c1c 100644
--- a/lib/eal/common/eal_common_memalloc.c
+++ b/lib/eal/common/eal_common_memalloc.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017-2018 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_errno.h>
diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 5fc4ee71dc..9ca2045b18 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -2,8 +2,10 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include <stdio.h>
+#include <ctype.h>
 #include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 #include <rte_string_fns.h>
 #include <rte_errno.h>
diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 036f6ac348..f9b187d15f 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
+#include <stdlib.h>
 #include <fnmatch.h>
 #include <sys/queue.h>
 #include <regex.h>
diff --git a/lib/eal/common/eal_common_trace_ctf.c b/lib/eal/common/eal_common_trace_ctf.c
index 3b83bcdf57..335932a271 100644
--- a/lib/eal/common/eal_common_trace_ctf.c
+++ b/lib/eal/common/eal_common_trace_ctf.c
@@ -3,6 +3,7 @@
  */
 
 #include <inttypes.h>
+#include <stdlib.h>
 #include <time.h>
 
 #include <rte_byteorder.h>
diff --git a/lib/eal/common/hotplug_mp.c b/lib/eal/common/hotplug_mp.c
index bde0de196e..815c1c9c81 100644
--- a/lib/eal/common/hotplug_mp.c
+++ b/lib/eal/common/hotplug_mp.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation
  */
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_eal.h>
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 2b8eb51067..0c2624c62d 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
 
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 26fbc91b26..ee5c929da8 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/lib/eal/include/generic/rte_rwlock.h b/lib/eal/include/generic/rte_rwlock.h
index da9bc3e9c0..6f600db2af 100644
--- a/lib/eal/include/generic/rte_rwlock.h
+++ b/lib/eal/include/generic/rte_rwlock.h
@@ -21,6 +21,8 @@
 extern "C" {
 #endif
 
+#include <errno.h>
+
 #include <rte_common.h>
 #include <rte_atomic.h>
 #include <rte_pause.h>
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index 86c50c55e0..2e22c1b955 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -17,9 +17,6 @@ extern "C" {
 #endif
 
 #include <stdint.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
 #include <limits.h>
 
 #include <rte_config.h>
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 37d29643a5..46bf52cef0 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2012-2014 6WIND S.A.
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c
index 4de67138bc..9a68e4ce68 100644
--- a/lib/eal/linux/eal_alarm.c
+++ b/lib/eal/linux/eal_alarm.c
@@ -3,6 +3,7 @@
  */
 #include <stdio.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <sys/queue.h>
 #include <sys/time.h>
diff --git a/lib/eal/linux/eal_dev.c b/lib/eal/linux/eal_dev.c
index 02ae1cde29..8d51ccbc0d 100644
--- a/lib/eal/linux/eal_dev.c
+++ b/lib/eal/linux/eal_dev.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <signal.h>
diff --git a/lib/eal/linux/eal_vfio_mp_sync.c b/lib/eal/linux/eal_vfio_mp_sync.c
index 4e26781948..157f20e583 100644
--- a/lib/eal/linux/eal_vfio_mp_sync.c
+++ b/lib/eal/linux/eal_vfio_mp_sync.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2018 Intel Corporation
  */
 
+#include <errno.h>
 #include <unistd.h>
 #include <string.h>
 
diff --git a/lib/eal/ppc/rte_power_intrinsics.c b/lib/eal/ppc/rte_power_intrinsics.c
index f00b58ade5..d6bdc58911 100644
--- a/lib/eal/ppc/rte_power_intrinsics.c
+++ b/lib/eal/ppc/rte_power_intrinsics.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2021 Intel Corporation
  */
 
+#include <errno.h>
+
 #include "rte_power_intrinsics.h"
 
 /**
diff --git a/lib/eal/riscv/rte_power_intrinsics.c b/lib/eal/riscv/rte_power_intrinsics.c
index 240e7b6b87..1c86573c19 100644
--- a/lib/eal/riscv/rte_power_intrinsics.c
+++ b/lib/eal/riscv/rte_power_intrinsics.c
@@ -4,6 +4,8 @@
  * Copyright(c) 2022 Semihalf
  */
 
+#include <errno.h>
+
 #include "rte_power_intrinsics.h"
 
 /**
diff --git a/lib/eal/unix/eal_unix_timer.c b/lib/eal/unix/eal_unix_timer.c
index cc50159104..e71602b3a1 100644
--- a/lib/eal/unix/eal_unix_timer.c
+++ b/lib/eal/unix/eal_unix_timer.c
@@ -2,6 +2,7 @@
  * Copyright 2020 Mellanox Technologies, Ltd
  */
 
+#include <errno.h>
 #include <time.h>
 
 #include <rte_cycles.h>
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index 077152568f..63442ece9d 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -3,6 +3,8 @@
  * Copyright (C) 2022 Microsoft Corporation
  */
 
+#include <errno.h>
+
 #include <rte_common.h>
 #include <rte_errno.h>
 #include <rte_thread.h>
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index bbc6fc585d..846c906aea 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -1,9 +1,11 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2016-2017 Intel Corporation
  */
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include <errno.h>
 #include <sys/queue.h>
diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
index a285f213f0..5c0434e8f4 100644
--- a/lib/ethdev/ethdev_driver.c
+++ b/lib/ethdev/ethdev_driver.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_kvargs.h>
 #include <rte_malloc.h>
 
diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c
index 3be84dd45c..838b3a8f9f 100644
--- a/lib/ethdev/rte_class_eth.c
+++ b/lib/ethdev/rte_class_eth.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2018 Gaëtan Rivet
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_class.h>
diff --git a/lib/ethdev/sff_telemetry.c b/lib/ethdev/sff_telemetry.c
index 887f07c47e..ca6d196560 100644
--- a/lib/ethdev/sff_telemetry.c
+++ b/lib/ethdev/sff_telemetry.c
@@ -2,7 +2,9 @@
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <ctype.h>
 #include <errno.h>
+#include <stdlib.h>
 
 #include "rte_ethdev.h"
 #include <rte_common.h>
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index bf8741d2ea..62e2c48c2a 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2017 Intel Corporation.
  * All rights reserved.
  */
+#include <ctype.h>
+#include <stdlib.h>
 #if defined(LINUX)
 #include <sys/epoll.h>
 #endif
diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c
index e0d978d641..d10aefb086 100644
--- a/lib/eventdev/rte_event_timer_adapter.c
+++ b/lib/eventdev/rte_event_timer_adapter.c
@@ -3,9 +3,11 @@
  * All rights reserved.
  */
 
+#include <ctype.h>
 #include <string.h>
 #include <inttypes.h>
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include <rte_memzone.h>
 #include <rte_errno.h>
diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c
index ee3ae80f82..805719d00c 100644
--- a/lib/gpudev/gpudev.c
+++ b/lib/gpudev/gpudev.c
@@ -2,6 +2,8 @@
  * Copyright (c) 2021 NVIDIA Corporation & Affiliates
  */
 
+#include <stdlib.h>
+
 #include <rte_eal.h>
 #include <rte_tailq.h>
 #include <rte_string_fns.h>
diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index d61288647c..3a617cc369 100644
--- a/lib/graph/graph.c
+++ b/lib/graph/graph.c
@@ -4,6 +4,7 @@
 
 #include <fnmatch.h>
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include <rte_common.h>
 #include <rte_debug.h>
diff --git a/lib/graph/graph_ops.c b/lib/graph/graph_ops.c
index 20db58d84e..a3548ec804 100644
--- a/lib/graph/graph_ops.c
+++ b/lib/graph/graph_ops.c
@@ -3,6 +3,7 @@
  */
 
 #include <stdbool.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_errno.h>
diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c
index 65e12d46a3..c0140ba922 100644
--- a/lib/graph/graph_stats.c
+++ b/lib/graph/graph_stats.c
@@ -4,6 +4,7 @@
 
 #include <fnmatch.h>
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include <rte_common.h>
 #include <rte_errno.h>
diff --git a/lib/graph/node.c b/lib/graph/node.c
index ae6eadb260..fc6345de07 100644
--- a/lib/graph/node.c
+++ b/lib/graph/node.c
@@ -4,6 +4,7 @@
 
 #include <stdbool.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_common.h>
diff --git a/lib/ipsec/ipsec_telemetry.c b/lib/ipsec/ipsec_telemetry.c
index 9a91e47122..cfebf454d6 100644
--- a/lib/ipsec/ipsec_telemetry.c
+++ b/lib/ipsec/ipsec_telemetry.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2021 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <rte_ipsec.h>
 #include <rte_telemetry.h>
 #include <rte_malloc.h>
diff --git a/lib/meter/rte_meter.c b/lib/meter/rte_meter.c
index 4549b97d36..6545803d36 100644
--- a/lib/meter/rte_meter.c
+++ b/lib/meter/rte_meter.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <math.h>
 
diff --git a/lib/metrics/rte_metrics.c b/lib/metrics/rte_metrics.c
index 0c7878e65f..6adcda501c 100644
--- a/lib/metrics/rte_metrics.c
+++ b/lib/metrics/rte_metrics.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <rte_common.h>
diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c
index 5294607619..8d2e05a831 100644
--- a/lib/node/ethdev_ctrl.c
+++ b/lib/node/ethdev_ctrl.c
@@ -2,6 +2,8 @@
  * Copyright(C) 2020 Marvell International Ltd.
  */
 
+#include <stdlib.h>
+
 #include <rte_ethdev.h>
 #include <rte_graph.h>
 
diff --git a/lib/pci/rte_pci.c b/lib/pci/rte_pci.c
index 355772ff56..1c5ef951d3 100644
--- a/lib/pci/rte_pci.c
+++ b/lib/pci/rte_pci.c
@@ -3,6 +3,7 @@
  * Copyright 2013-2014 6WIND S.A.
  */
 
+#include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c
index b3a62df591..98dcbc037b 100644
--- a/lib/pdump/rte_pdump.c
+++ b/lib/pdump/rte_pdump.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2016-2018 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
 #include <rte_lcore.h>
diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c
index 710e89a46a..fecc215398 100644
--- a/lib/pipeline/rte_swx_ctl.c
+++ b/lib/pipeline/rte_swx_ctl.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2020 Intel Corporation
  */
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/lib/port/rte_swx_port_fd.c b/lib/port/rte_swx_port_fd.c
index 1ee5086684..4bbad2eaa7 100644
--- a/lib/port/rte_swx_port_fd.c
+++ b/lib/port/rte_swx_port_fd.c
@@ -3,6 +3,7 @@
  */
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <rte_mbuf.h>
diff --git a/lib/port/rte_swx_port_ring.c b/lib/port/rte_swx_port_ring.c
index c62fb3d8c8..c726e50a57 100644
--- a/lib/port/rte_swx_port_ring.c
+++ b/lib/port/rte_swx_port_ring.c
@@ -3,6 +3,7 @@
  */
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
 
 #include <rte_mbuf.h>
 #include <rte_ring.h>
diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c
index ef06fbcd9e..fc9cffef91 100644
--- a/lib/power/power_cppc_cpufreq.c
+++ b/lib/power/power_cppc_cpufreq.c
@@ -3,6 +3,8 @@
  * Copyright(c) 2021 Arm Limited
  */
 
+#include <stdlib.h>
+
 #include <rte_memcpy.h>
 
 #include "power_cppc_cpufreq.h"
diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c
index 0a6614be77..63a43bd8f5 100644
--- a/lib/power/rte_power.c
+++ b/lib/power/rte_power.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <errno.h>
+
 #include <rte_errno.h>
 #include <rte_spinlock.h>
 
diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index a66e08e574..ca1840387c 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <stdlib.h>
+
 #include <rte_lcore.h>
 #include <rte_cycles.h>
 #include <rte_cpuflags.h>
diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c
index c84f75a18c..947e2a059f 100644
--- a/lib/sched/rte_pie.c
+++ b/lib/sched/rte_pie.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index 4f5e4b4d49..b5e9b0d34a 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,6 +4,9 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <ctype.h>
+#include <stdlib.h>
+
 #include <rte_cryptodev.h>
 #include <rte_dev.h>
 #include <rte_telemetry.h>
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index c6fd03a5ab..164ea0601a 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
+#include <stdlib.h>
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include <unistd.h>
 #include <pthread.h>
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index e14ae3c4d4..2581c27413 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -2,6 +2,9 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <errno.h>
+#include <stdlib.h>
+
 #undef RTE_USE_LIBBSD
 #include <rte_string_fns.h>
 
diff --git a/lib/telemetry/telemetry_legacy.c b/lib/telemetry/telemetry_legacy.c
index 8aba44d689..4c1d1c353a 100644
--- a/lib/telemetry/telemetry_legacy.c
+++ b/lib/telemetry/telemetry_legacy.c
@@ -1,7 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2020 Intel Corporation
  */
-
+#include <ctype.h>
+#include <errno.h>
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include <unistd.h>
 #include <sys/socket.h>
diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
index 40fac3b7c6..c06f10bdce 100644
--- a/lib/vhost/vhost.h
+++ b/lib/vhost/vhost.h
@@ -7,6 +7,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <sys/queue.h>
 #include <unistd.h>
 #include <linux/virtio_net.h>
-- 
2.33.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v4 4/4] eal: remove unneeded includes from a public header
  2022-08-27 11:32       ` [PATCH v4 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
@ 2022-08-29  8:29         ` Bruce Richardson
  2022-09-21  9:27         ` David Marchand
  2022-09-21 11:37         ` David Marchand
  2 siblings, 0 replies; 29+ messages in thread
From: Bruce Richardson @ 2022-08-29  8:29 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev

On Sat, Aug 27, 2022 at 02:32:22PM +0300, Dmitry Kozlyuk wrote:
> Do not include <ctype.h>, <errno.h>, and <stdlib.h> from <rte_common.h>,
> because they are not used by this file.
> Include the needed headers directly from the files that need them.
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v4 4/4] eal: remove unneeded includes from a public header
  2022-08-27 11:32       ` [PATCH v4 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
  2022-08-29  8:29         ` Bruce Richardson
@ 2022-09-21  9:27         ` David Marchand
  2022-09-21 11:37         ` David Marchand
  2 siblings, 0 replies; 29+ messages in thread
From: David Marchand @ 2022-09-21  9:27 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev

On Sat, Aug 27, 2022 at 1:33 PM Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> wrote:
> diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
> index bbc6fc585d..846c906aea 100644
> --- a/lib/efd/rte_efd.c
> +++ b/lib/efd/rte_efd.c
> @@ -1,9 +1,11 @@
>  /* SPDX-License-Identifier: BSD-3-Clause
>   * Copyright(c) 2016-2017 Intel Corporation
>   */
> +#include <errno.h>
>  #include <stdio.h>
>  #include <string.h>
>  #include <stdint.h>
> +#include <stdlib.h>
>  #include <inttypes.h>
>  #include <errno.h>
>  #include <sys/queue.h>

errno is included twice.
I will fix while applying.



-- 
David Marchand


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v4 4/4] eal: remove unneeded includes from a public header
  2022-08-27 11:32       ` [PATCH v4 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
  2022-08-29  8:29         ` Bruce Richardson
  2022-09-21  9:27         ` David Marchand
@ 2022-09-21 11:37         ` David Marchand
  2 siblings, 0 replies; 29+ messages in thread
From: David Marchand @ 2022-09-21 11:37 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev, ci

On Sat, Aug 27, 2022 at 1:33 PM Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> wrote:
>
> Do not include <ctype.h>, <errno.h>, and <stdlib.h> from <rte_common.h>,
> because they are not used by this file.
> Include the needed headers directly from the files that need them.
>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> ---

[snip]

>  examples/vdpa/main.c                                     | 1 +
>  examples/vhost/main.c                                    | 2 ++
>  examples/vhost/virtio_net.c                              | 1 +
>  examples/vhost_blk/vhost_blk.c                           | 1 +

We are missing an update of vm_power_manager example:

../../../dpdk/examples/vm_power_manager/parse.c: In function ‘parse_set’:
../../../dpdk/examples/vm_power_manager/parse.c:28:16: error: implicit
declaration of function ‘isblank’
[-Werror=implicit-function-declaration]
   28 |         while (isblank(*str))
      |                ^~~~~~~
../../../dpdk/examples/vm_power_manager/parse.c:9:1: note: include
‘<ctype.h>’ or provide a declaration of ‘isblank’
    8 | #include "parse.h"
  +++ |+#include <ctype.h>
    9 |


I am surprised the CI did not catch this issue.
I suspect some dependencies (probably libvirt-devel) are not installed
in CI environments.


The following diff seems enough to fix the issue, can you double check?


diff --git a/examples/vm_power_manager/channel_monitor.c
b/examples/vm_power_manager/channel_monitor.c
index 97b8def7ca..5fef268662 100644
--- a/examples/vm_power_manager/channel_monitor.c
+++ b/examples/vm_power_manager/channel_monitor.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */

+#include <ctype.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/examples/vm_power_manager/guest_cli/parse.c
b/examples/vm_power_manager/guest_cli/parse.c
index 528df6d6f1..6ed2d5cb49 100644
--- a/examples/vm_power_manager/guest_cli/parse.c
+++ b/examples/vm_power_manager/guest_cli/parse.c
@@ -3,9 +3,13 @@
  * Copyright(c) 2014 6WIND S.A.
  */

+#include <ctype.h>
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include <rte_log.h>
+
 #include "parse.h"

 /*
diff --git a/examples/vm_power_manager/parse.c
b/examples/vm_power_manager/parse.c
index 8a8dcf05fe..5467035994 100644
--- a/examples/vm_power_manager/parse.c
+++ b/examples/vm_power_manager/parse.c
@@ -3,8 +3,13 @@
  * Copyright(c) 2014 6WIND S.A.
  */

+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
 #include <string.h>
+
 #include <rte_log.h>
+
 #include "parse.h"

 /*


-- 
David Marchand


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup
  2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
                         ` (3 preceding siblings ...)
  2022-08-27 11:32       ` [PATCH v4 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
@ 2022-09-21 13:30       ` David Marchand
  4 siblings, 0 replies; 29+ messages in thread
From: David Marchand @ 2022-09-21 13:30 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev, Bruce Richardson, Chengwen Feng, Morten Brørup

On Sat, Aug 27, 2022 at 1:32 PM Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> wrote:
>
> v4: Fix build on ARM and RISC-V (CI).
>
> v3: Fix build (CI).
>
> v2:
>     * Extend and tidy up the macro unit test (Morten).
>     * Remove unneeded includes from rte_common.h (Morten, Bruce).
>
>
> Dmitry Kozlyuk (4):
>   eal: fix pointer arithmetic with an expression argument
>   eal: deduplicate roundup code
>   eal: uninline rte_str_to_size
>   eal: remove unneeded includes from a public header

I fixed the reported issues on last patch, and applied the series.
Thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2022-09-21 13:30 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
2022-08-21 20:50 ` [PATCH 1/3] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-22  7:14   ` Morten Brørup
2022-08-21 20:50 ` [PATCH 2/3] eal: uninline rte_str_to_size Dmitry Kozlyuk
2022-08-22  7:24   ` Morten Brørup
2022-08-22 14:06     ` Bruce Richardson
2022-08-21 20:50 ` [PATCH 3/3] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-22  7:25   ` Morten Brørup
2022-08-22 14:06 ` [PATCH 0/3] eal: small rte_common.h fixes and cleanup Bruce Richardson
2022-08-24  3:52 ` fengchengwen
2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
2022-08-25 15:37   ` [PATCH v2 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-25 15:37   ` [PATCH v2 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-25 15:37   ` [PATCH v2 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
2022-08-25 15:37   ` [PATCH v2 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
2022-08-25 22:33   ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
2022-08-25 22:33     ` [PATCH v3 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-25 22:33     ` [PATCH v3 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-25 22:33     ` [PATCH v3 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
2022-08-25 22:33     ` [PATCH v3 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
2022-08-27 11:32     ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
2022-08-27 11:32       ` [PATCH v4 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-27 11:32       ` [PATCH v4 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-27 11:32       ` [PATCH v4 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
2022-08-27 11:32       ` [PATCH v4 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
2022-08-29  8:29         ` Bruce Richardson
2022-09-21  9:27         ` David Marchand
2022-09-21 11:37         ` David Marchand
2022-09-21 13:30       ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup David Marchand

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).