[1/2] mempool: replace GCC pragma with cast

Message ID 20240401170257.121047-2-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series mempool: patches |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger April 1, 2024, 5:01 p.m. UTC
  Building mempool with MSVC generates a warning
because of this pragma (same with clang when debug is enabled).
The issue the pragma was working around can be better solved
by using an additional cast.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/mempool/rte_mempool.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
  

Comments

Tyler Retzlaff April 1, 2024, 5:21 p.m. UTC | #1
On Mon, Apr 01, 2024 at 10:01:52AM -0700, Stephen Hemminger wrote:
> Building mempool with MSVC generates a warning
> because of this pragma (same with clang when debug is enabled).
> The issue the pragma was working around can be better solved
> by using an additional cast.
> 
> Fixes: af75078fece3 ("first public release")
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  

Patch

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 12390a2c81..734e8a2feb 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -1056,10 +1056,6 @@  rte_mempool_dump_cache(FILE *f, const struct rte_mempool *mp)
 	return count;
 }
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
 /* check and update cookies or panic (internal) */
 void rte_mempool_check_cookies(const struct rte_mempool *mp,
 	void * const *obj_table_const, unsigned n, int free)
@@ -1074,7 +1070,7 @@  void rte_mempool_check_cookies(const struct rte_mempool *mp,
 
 	/* Force to drop the "const" attribute. This is done only when
 	 * DEBUG is enabled */
-	tmp = (void *) obj_table_const;
+	tmp = (void *)(uintptr_t)obj_table_const;
 	obj_table = tmp;
 
 	while (n--) {
@@ -1183,10 +1179,6 @@  mempool_audit_cookies(struct rte_mempool *mp)
 #define mempool_audit_cookies(mp) do {} while(0)
 #endif
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic error "-Wcast-qual"
-#endif
-
 /* check cookies before and after objects */
 static void
 mempool_audit_cache(const struct rte_mempool *mp)