[5/8] net/nfp: fix unreachable loop flow

Message ID 20240314070536.3169210-6-chaoyong.he@corigine.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series fix some coverity issues |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He March 14, 2024, 7:05 a.m. UTC
  CI found the loop flow in 'nfp_net_flow_calculate_items()' will never
execute more than once.

Coverity issue: 414941
Fixes: c91c6512d876 ("net/nfp: support Ethernet flow item")
Cc: stable@dpdk.org

Signed-off-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/nfp_net_flow.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index ff6ce3ee45..251974edb4 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -180,6 +180,7 @@  static int
 nfp_net_flow_calculate_items(const struct rte_flow_item items[],
 		uint32_t *match_len)
 {
+	int ret = -EINVAL;
 	const struct rte_flow_item *item;
 
 	for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) {
@@ -187,7 +188,8 @@  nfp_net_flow_calculate_items(const struct rte_flow_item items[],
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_ETH detected");
 			*match_len = sizeof(struct nfp_net_cmsg_match_eth);
-			return 0;
+			ret = 0;
+			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected");
 			*match_len = sizeof(struct nfp_net_cmsg_match_v4);
@@ -203,7 +205,7 @@  nfp_net_flow_calculate_items(const struct rte_flow_item items[],
 		}
 	}
 
-	return -EINVAL;
+	return ret;
 }
 
 static int