[5/7] table: add explicit casts for C++ compatibility

Message ID 20220204174209.440207-6-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Verify C++ compatibility of public headers |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson Feb. 4, 2022, 5:42 p.m. UTC
  Since C++ doesn't support automatic casting from void * to other types,
we need to explicitly add the casts to any header files in DPDK.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/table/rte_table_hash_func.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
  

Patch

diff --git a/lib/table/rte_table_hash_func.h b/lib/table/rte_table_hash_func.h
index c4c35cc06a..a962ec2f68 100644
--- a/lib/table/rte_table_hash_func.h
+++ b/lib/table/rte_table_hash_func.h
@@ -58,8 +58,8 @@  static inline uint64_t
 rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t crc0;
 
 	crc0 = rte_crc32_u64(seed, k[0] & m[0]);
@@ -72,8 +72,8 @@  static inline uint64_t
 rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -91,8 +91,8 @@  static inline uint64_t
 rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -113,8 +113,8 @@  static inline uint64_t
 rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -139,8 +139,8 @@  static inline uint64_t
 rte_table_hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -165,8 +165,8 @@  static inline uint64_t
 rte_table_hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -192,8 +192,8 @@  static inline uint64_t
 rte_table_hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];
@@ -222,8 +222,8 @@  static inline uint64_t
 rte_table_hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];