net/nfp: fix misuse of function return values

Message ID 20250122013320.1704468-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Stephen Hemminger
Headers
Series net/nfp: fix misuse of function return values |

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/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Chaoyong He Jan. 22, 2025, 1:33 a.m. UTC
From: Zerun Fu <zerun.fu@corigine.com>

The 'nfp_ct_offload_add()' return 0 means the result is right
while return negative number means the wrong result.

The caller assigns the 'int' variable to the 'bool' variable.
So the negative number will be transform to 'true'. This will
cause an error because 'true' will be regard as no problem.

Fixes: b4ae16eae01c ("net/nfp: support to add and delete flows to firmware")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_conntrack.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_conntrack.c b/drivers/net/nfp/flower/nfp_conntrack.c
index 0b21e4ee5b..439a1a1b0e 100644
--- a/drivers/net/nfp/flower/nfp_conntrack.c
+++ b/drivers/net/nfp/flower/nfp_conntrack.c
@@ -1440,6 +1440,7 @@  nfp_ct_do_flow_merge(struct nfp_ct_zone_entry *ze,
 		struct nfp_ct_flow_entry *pre_ct_entry,
 		struct nfp_ct_flow_entry *post_ct_entry)
 {
+	int err;
 	bool ret;
 	uint64_t new_cookie[2];
 	uint8_t cnt_same_item = 0;
@@ -1508,9 +1509,10 @@  nfp_ct_do_flow_merge(struct nfp_ct_zone_entry *ze,
 	}
 
 	/* Send to firmware */
-	ret = nfp_ct_offload_add(pre_ct_entry->dev, merge_entry);
-	if (ret != 0) {
+	err = nfp_ct_offload_add(pre_ct_entry->dev, merge_entry);
+	if (err != 0) {
 		PMD_DRV_LOG(ERR, "Send the merged flow to firmware failed.");
+		ret = false;
 		goto merge_table_del;
 	}