hash: cast away atomic qualification

Message ID 1713283609-32101-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series hash: cast away atomic qualification |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Tyler Retzlaff April 16, 2024, 4:06 p.m. UTC
  rte_free accepts only non-cva qualified arguments so cast away
RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when
calling rte_free.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon May 16, 2024, 5:08 p.m. UTC | #1
16/04/2024 18:06, Tyler Retzlaff:
> rte_free accepts only non-cva qualified arguments so cast away
> RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when
> calling rte_free.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Please add an explanation about the case where it does not compile.
  
Tyler Retzlaff May 22, 2024, 4:33 p.m. UTC | #2
rte_free accepts only non-cva qualified arguments so cast away
RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when
calling rte_free.

Without this change using enable_stdatomic=true with LLVM or MSVC will
result in a warning being emitted for discarding the atomic
qualification.

v2:
  * update commit message to indicate the conditions under
    which a warning will be issued without this patch.

Tyler Retzlaff (1):
  hash: cast away atomic qualification

 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf9464..b31a3d9 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -481,7 +481,7 @@  struct rte_hash *
 	rte_free(buckets);
 	rte_free(buckets_ext);
 	rte_free(k);
-	rte_free(tbl_chng_cnt);
+	rte_free((void *)(uintptr_t)tbl_chng_cnt);
 	rte_free(ext_bkt_to_free);
 	return NULL;
 }
@@ -526,7 +526,7 @@  struct rte_hash *
 	rte_free(h->key_store);
 	rte_free(h->buckets);
 	rte_free(h->buckets_ext);
-	rte_free(h->tbl_chng_cnt);
+	rte_free((void *)(uintptr_t)h->tbl_chng_cnt);
 	rte_free(h->ext_bkt_to_free);
 	rte_free(h->hash_rcu_cfg);
 	rte_free(h);