Skip to contentSkip to conversation

mempool: fix ignore return value Coverity issue

PATCH In review David Hunt 3 participants 3 messages Nov 5, 2020 – Nov 13, 2020

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 mempool: fix ignore return value Coverity issue

Coverity flags that rte_mempool_ops_dequeue_bulk() is called without checking the return value.

This ignoring is intentional, so this patch gets the return code, then uses RTE_SET_USED so that Coverity will be happy.

Coverity issue: 363744

Fixes 449c49b93a6b ("mempool: support handler operations")
---
 lib/librte_mempool/rte_mempool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/librte_mempool/rte_mempool.c +3 -1
index b9f3fbd61..2980b1a00 100644
@@ -270,9 +270,11 @@ rte_mempool_free_memchunks(struct rte_mempool *mp)
 {
 	struct rte_mempool_memhdr *memhdr;
 	void *elt;
+	int ret;
 
 	while (!STAILQ_EMPTY(&mp->elt_list)) {
-		rte_mempool_ops_dequeue_bulk(mp, &elt, 1);
+		ret = rte_mempool_ops_dequeue_bulk(mp, &elt, 1);
+		RTE_SET_USED(ret); /* Intentionally ignored */
 		(void)elt;
 		STAILQ_REMOVE_HEAD(&mp->elt_list, next);
 		mp->populated_size--;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · David Hunt

Coverity flags that rte_mempool_ops_dequeue_bulk() is called without checking the return value.

This ignoring is intentional, so this patch gets the return code, then uses RTE_SET_USED so that Coverity will be happy.

Coverity issue: 363744

Fixes 449c49b93a6b ("mempool: support handler operations")

Thanks David!

#2 lore raw

05/11/2020 14:58, Olivier Matz:

Quoted 11 lines · David Hunt
Quoted 10 lines

Coverity flags that rte_mempool_ops_dequeue_bulk() is called without checking the return value.

This ignoring is intentional, so this patch gets the return code, then uses RTE_SET_USED so that Coverity will be happy.

Coverity issue: 363744

Fixes 449c49b93a6b ("mempool: support handler operations")
Quoted 5 lines
Quoted 1 line

Thanks David!

This patch is doing nothing else than shutting up Coverity. Is there any value adding this comment in the code?
Would it be cleaner to mark it as false positive in Coverity itself?