[PATCH 05/16] net/i40e: remove duplicate code

Stephen Hemminger stephen at networkplumber.org
Fri Nov 15 07:05:42 CET 2024


There are two branches in the cascading if/else that have same
condition and code; remove one. Update the code to follow DPDK
style where all statements in if should have brackets if any
leg requires them.

Link: https://pvs-studio.com/en/blog/posts/cpp/1183/

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 drivers/net/i40e/i40e_fdir.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 47f79ecf11..6861bea99a 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -599,18 +599,16 @@ i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf,
 		} else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV4_UDP) {
 			len = fill_ip4_head(fdir_input, raw_pkt, IPPROTO_UDP,
 					len, ether_type);
-		} else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV4_UDP) {
-			len = fill_ip4_head(fdir_input, raw_pkt, IPPROTO_UDP,
-					len, ether_type);
-		} else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV6)
+		} else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV6) {
 			len = fill_ip6_head(fdir_input, raw_pkt, IPPROTO_ESP,
 					len, ether_type);
-		else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV6_UDP)
+		} else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV6_UDP) {
 			len = fill_ip6_head(fdir_input, raw_pkt, IPPROTO_UDP,
 					len, ether_type);
-		else if (cus_pctype->index == I40E_CUSTOMIZED_IPV6_L2TPV3)
+		} else if (cus_pctype->index == I40E_CUSTOMIZED_IPV6_L2TPV3) {
 			len = fill_ip6_head(fdir_input, raw_pkt, IPPROTO_L2TP,
 					len, ether_type);
+		}
 	} else {
 		PMD_DRV_LOG(ERR, "unknown pctype %u.", fdir_input->pctype);
 		return -1;
-- 
2.45.2



More information about the dev mailing list