Skip to contentSkip to conversation

iavf: Remove useless else if

PATCH In review Jiapeng Chong 2 participants 2 messages Sep 9, 2022 – Sep 12, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iavf: Remove useless else if

The assignment of the else and else if branches is the same, so the else if here is redundant, so we remove it and add a comment to make the code here readable.

./drivers/net/ethernet/intel/iavf/iavf_main.c:2211:6-8: WARNING: possible condition with no effect (if == else).

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -3
index 1671e52b6ba2..e105ffeca074 100644
@@ -2208,9 +2208,7 @@ iavf_set_vlan_offload_features(struct iavf_adapter *adapter,
 		vlan_ethertype = ETH_P_8021Q;
 	else if (prev_features & (NETIF_F_HW_VLAN_STAG_RX | NETIF_F_HW_VLAN_STAG_TX))
 		vlan_ethertype = ETH_P_8021AD;
-	else if (prev_features & (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX))
-		vlan_ethertype = ETH_P_8021Q;
-	else
+	else /* contains prev_features & (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX) */
 		vlan_ethertype = ETH_P_8021Q;
 
 	if (!(features & (NETIF_F_HW_VLAN_STAG_RX | NETIF_F_HW_VLAN_CTAG_RX)))
Signature · 1 line
2.20.1.7.g153144c
maintainer
#1 lore raw
Quoted 5 lines · Jiapeng Chong

The assignment of the else and else if branches is the same, so the else if here is redundant, so we remove it and add a comment to make the code here readable.

./drivers/net/ethernet/intel/iavf/iavf_main.c:2211:6-8: WARNING: possible condition with no effect (if == else).

This was already nacked by Jakub [1].

Thanks,
Tony

Quoted 3 lines

[1] https://lore.kernel.org/netdev/[email protected]/