Skip to contentSkip to conversation

iavf: Remove useless else if

PATCH Superseded Jiapeng Chong 2 participants 2 messages May 19, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iavf: Remove useless else if

The assignment of the else and if branches is the same, so the if else here is redundant, so we remove it.

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

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -2
index 2de4baff4c20..cf8538cebfe0 100644
@@ -2200,8 +2200,6 @@ 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
 		vlan_ethertype = ETH_P_8021Q;
 
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 8 lines · Jiapeng Chong

The assignment of the else and if branches is the same, so the if else here is redundant, so we remove it.

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

nit: This should be targeted at net-next.

Subject: [PATCH net-next] ...

Quoted 9 lines
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
index 2de4baff4c20..cf8538cebfe0 100644

drivers/net/ethernet/intel/iavf/iavf_main.c iavf_set_vlan_offload_features(struct iavf_adapter *adapter, · line 2204

Quoted 5 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -2
@@ -2200,8 +2200,6 @@ 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;

I agree that the assignment is the same.
But the current arrangement does very obviously handle NETIF_F_HW_VLAN_CTAG_TX, whereas in the new arrangement it's unclear if it is handled or forgotten.

Perhaps a comment is warranted here?
Something like this?

drivers/net/ethernet/intel/iavf/iavf_main.c iavf_set_vlan_offload_features(struct iavf_adapter *adapter, · line 2203

Quoted 1 line
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
 	else
		/* This covers both the default and the
		 * (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX case.
		 */
Quoted 6 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
 		vlan_ethertype = ETH_P_8021Q;
 
Signature · 1 line
2.20.1.7.g153144c