net: remove conditional returns with no effect
Subsystems (15)
v2 cover net: remove conditional returns with no effect
Hello,
This series removes conditional returns where both branches return the same value, so the check has no effect. As suggested by Jakub, the netdev patches of the treewide v1 series [1] are posted separately.
All patches are generated by the Coccinelle script, which you can find in v1.
The patch grouping is unchanged from v1. If you would rather split, merge or drop any of the patches, just let me know and I will address it in the next version.
---
Changes from v1 [1]
- Collect Reviewed-by tags
- Change base to net-next/main
- Filter only netdev patches
[1] https://lore.kernel.org/all/[email protected]/
---
Sang-Heon Jeon (4):
dpll: zl3073x: remove conditional return with no effect
net: ethernet: remove conditional return with no effect
net: remove conditional return with no effect
net: intel: remove conditional return with no effect
drivers/dpll/zl3073x/dpll.c | 6 +----- drivers/dpll/zl3073x/out.c | 8 ++------ drivers/net/ethernet/amazon/ena/ena_netdev.c | 6 +----- drivers/net/ethernet/aquantia/atlantic/aq_macsec.c | 6 +----- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 6 +----- drivers/net/ethernet/freescale/gianfar.c | 6 +----- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 +------- drivers/net/ethernet/intel/igb/e1000_i210.c | 6 +----- drivers/net/ethernet/intel/igc/igc_phy.c | 6 +----- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 7 +------ drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c | 6 +----- drivers/net/ethernet/renesas/rtsn.c | 7 +------ drivers/net/phy/microchip_t1.c | 6 +----- drivers/net/pse-pd/tps23881.c | 6 +----- 14 files changed, 15 insertions(+), 75 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/4 dpll: zl3073x: remove conditional return with no effect
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.
--- drivers/dpll/zl3073x/dpll.c | 6 +----- drivers/dpll/zl3073x/out.c | 8 ++------ 2 files changed, 3 insertions(+), 11 deletions(-)
drivers/dpll/zl3073x/dpll.c +1 -5
@@ -2272,11 +2272,7 @@ zl3073x_dpll_init_fine_phase_adjust(struct zl3073x_dev *zldev)if (rc)return rc; - rc =zl3073x_write_u8 (zldev,ZL_REG_SYNTH_PHASE_SHIFT_CTRL ,0x01 ); -if (rc) -return rc; - -return rc; +return zl3073x_write_u8 (zldev,ZL_REG_SYNTH_PHASE_SHIFT_CTRL ,0x01 ); }/**
drivers/dpll/zl3073x/out.c +2 -6
@@ -85,12 +85,8 @@ int zl3073x_out_state_fetch(struct zl3073x_dev *zldev, u8 index)if (rc)return rc; - rc =zl3073x_read_u32 (zldev,ZL_REG_OUTPUT_PHASE_COMP , - &out->phase_comp); -if (rc) -return rc; - -return rc; +return zl3073x_read_u32 (zldev,ZL_REG_OUTPUT_PHASE_COMP , + &out->phase_comp); }/**
Signature · 1 line
2.43.0
PATCH v2 2/4 net: ethernet: remove conditional return with no effect
In reply to Sang-Heon JeonBoth branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 6 +----- drivers/net/ethernet/aquantia/atlantic/aq_macsec.c | 6 +----- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 6 +----- drivers/net/ethernet/freescale/gianfar.c | 6 +----- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 7 +------ drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c | 6 +----- drivers/net/ethernet/renesas/rtsn.c | 7 +------ 7 files changed, 7 insertions(+), 37 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +1 -5
@@ -2303,11 +2303,7 @@ static int ena_open(struct net_device *netdev)return rc; } - rc =ena_up (adapter); -if (rc) -return rc; - -return rc; +return ena_up (adapter); }/* ena_close - Disables a network interface
drivers/net/ethernet/aquantia/atlantic/aq_macsec.c +1 -5
@@ -735,11 +735,7 @@ static int aq_set_rxsc(struct aq_nic_s *nic, const u32 rxsc_idx) sc_record.valid =1 ; sc_record.fresh =1 ; - ret =aq_mss_set_ingress_sc_record (hw, &sc_record, hw_sc_idx); -if (ret) -return ret; - -return ret; +return aq_mss_set_ingress_sc_record (hw, &sc_record, hw_sc_idx); }static int aq_mdo_add_rxsc (struct macsec_context *ctx)
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +1 -5
@@ -3935,11 +3935,7 @@ static int dpaa2_switch_port_init(struct ethsw_port_priv *port_priv, u16 port)if (err)return err; - err =dpaa2_switch_port_trap_mac_addr (port_priv, ll_mac, ll_mask); -if (err) -return err; - -return err; +return dpaa2_switch_port_trap_mac_addr (port_priv, ll_mac, ll_mask); }static void dpaa2_switch_ctrl_if_teardown (struct ethsw_core *ethsw)
drivers/net/ethernet/freescale/gianfar.c +1 -5
@@ -2877,11 +2877,7 @@ static int gfar_enet_open(struct net_device *dev)if (err)return err; - err =startup_gfar (dev); -if (err) -return err; - -return err; +return startup_gfar (dev); }/* Stops the kernel queue, and halts the controller */
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +1 -6
@@ -2478,7 +2478,6 @@ static int netxen_parse_md_template(struct netxen_adapter *adapter)static int netxen_collect_minidump (struct netxen_adapter *adapter) { -int ret =0 ;struct netxen_minidump_template_hdr *hdr; hdr = (struct netxen_minidump_template_hdr *) adapter->mdump.md_template;
@@ -2486,11 +2485,7 @@ netxen_collect_minidump(struct netxen_adapter *adapter) hdr->driver_timestamp =ktime_get_seconds (); hdr->driver_info_word2 = adapter->fw_version; hdr->driver_info_word3 =NXRD32 (adapter,CRB_DRIVER_VERSION ); - ret =netxen_parse_md_template (adapter); -if (ret) -return ret; - -return ret; +return netxen_parse_md_template (adapter); }
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c +1 -5
@@ -1618,11 +1618,7 @@ static int qlcnic_83xx_check_hw_status(struct qlcnic_adapter *p_dev)if (err)return err; - err =qlcnic_83xx_check_heartbeat (p_dev); -if (err) -return err; - -return err; +return qlcnic_83xx_check_heartbeat (p_dev); } static int qlcnic_83xx_poll_reg(struct qlcnic_adapter *p_dev, u32 addr,
drivers/net/ethernet/renesas/rtsn.c +1 -6
@@ -685,7 +685,6 @@ static void rtsn_set_rate(struct rtsn_private *priv)static int rtsn_rmac_init (struct rtsn_private *priv) {const u8 *mac_addr = priv->ndev->dev_addr; -int ret;/* Set MAC address */ rtsn_write (priv,MRMAC0 , (mac_addr[0 ] <<8 ) | mac_addr[1 ]);
@@ -702,11 +701,7 @@ static int rtsn_rmac_init(struct rtsn_private *priv)/* Link verification */ rtsn_modify (priv,MLVC ,MLVC_PLV ,MLVC_PLV ); - ret =rtsn_reg_wait (priv,MLVC ,MLVC_PLV ,0 ); -if (ret) -return ret; - -return ret; +return rtsn_reg_wait (priv,MLVC ,MLVC_PLV ,0 ); }static int rtsn_hw_init (struct rtsn_private *priv)
Signature · 1 line
2.43.0
PATCH v2 3/4 net: remove conditional return with no effect
In reply to Sang-Heon JeonBoth branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.
--- drivers/net/phy/microchip_t1.c | 6 +----- drivers/net/pse-pd/tps23881.c | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-)
drivers/net/phy/microchip_t1.c +1 -5
@@ -1028,11 +1028,7 @@ static int lan87xx_read_status(struct phy_device *phydev)if (rc <0 )return rc; - rc =genphy_read_status_fixed (phydev); -if (rc <0 ) -return rc; - -return rc; +return genphy_read_status_fixed (phydev); }static int lan87xx_config_aneg (struct phy_device *phydev)
drivers/net/pse-pd/tps23881.c +1 -5
@@ -1520,11 +1520,7 @@ static int tps23881_i2c_probe(struct i2c_client *client) "failed to register PSE controller\n"); } - ret =tps23881_setup_irq (priv, client->irq); -if (ret) -return ret; - -return ret; +return tps23881_setup_irq (priv, client->irq); }static const struct i2c_device_id tps23881_id[] = {
Signature · 1 line
2.43.0
PATCH v2 4/4 net: intel: remove conditional return with no effect
In reply to Sang-Heon JeonBoth branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 +------- drivers/net/ethernet/intel/igb/e1000_i210.c | 6 +----- drivers/net/ethernet/intel/igc/igc_phy.c | 6 +----- 3 files changed, 3 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -7
@@ -4864,16 +4864,10 @@ static void i40e_control_rx_q(struct i40e_pf *pf, int pf_q, bool enable)**/ int i40e_control_wait_rx_q (struct i40e_pf *pf,int pf_q,bool enable) { -int ret =0 ; -i40e_control_rx_q (pf, pf_q, enable);/* wait for the change to finish */ - ret =i40e_pf_rxq_wait (pf, pf_q, enable); -if (ret) -return ret; - -return ret; +return i40e_pf_rxq_wait (pf, pf_q, enable); }/**
drivers/net/ethernet/intel/igb/e1000_i210.c +1 -5
@@ -756,11 +756,7 @@ static s32 __igb_access_xmdio_reg(struct e1000_hw *hw, u16 address,return ret_val;/* Recalibrate the device back to 0 */ - ret_val = hw->phy.ops.write_reg (hw,E1000_MMDAC ,0 ); -if (ret_val) -return ret_val; - -return ret_val; +return hw->phy.ops.write_reg (hw,E1000_MMDAC ,0 ); }/**
drivers/net/ethernet/intel/igc/igc_phy.c +1 -5
@@ -675,11 +675,7 @@ static s32 __igc_access_xmdio_reg(struct igc_hw *hw, u16 address,return ret_val;/* Recalibrate the device back to 0 */ - ret_val = hw->phy.ops.write_reg (hw,IGC_MMDAC ,0 ); -if (ret_val) -return ret_val; - -return ret_val; +return hw->phy.ops.write_reg (hw,IGC_MMDAC ,0 ); }/**
Signature · 1 line
2.43.0
Re: [Intel-wired-lan] [PATCH net-next v2 4/4] net: intel: remove conditional return with no effect
Quoted 7 lines · Sang-Heon Jeon
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from
scripts/coccinelle/misc/cond_return_no_effect.cocci.Signed-off-by Sang-Heon Jeon <[email protected]>
Nice cleanup.
Quoted 62 lines
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 +------- drivers/net/ethernet/intel/igb/e1000_i210.c | 6 +----- drivers/net/ethernet/intel/igc/igc_phy.c | 6 +----- 3 files changed, 3 insertions(+), 17 deletions(-)drivers/net/ethernet/intel/i40e/i40e_main.c +1
-7@@ -4864,16 +4864,10 @@ static void i40e_control_rx_q(struct i40e_pf *pf, int pf_q, bool enable)**/ int i40e_control_wait_rx_q (struct i40e_pf *pf,int pf_q,bool enable) { -int ret =0 ; -i40e_control_rx_q (pf, pf_q, enable);/* wait for the change to finish */ - ret =i40e_pf_rxq_wait (pf, pf_q, enable); -if (ret) -return ret; - -return ret; +return i40e_pf_rxq_wait (pf, pf_q, enable); }/** drivers/net/ethernet/intel/igb/e1000_i210.c +1
-5@@ -756,11 +756,7 @@ static s32 __igb_access_xmdio_reg(struct e1000_hw *hw, u16 address,return ret_val;/* Recalibrate the device back to 0 */ - ret_val = hw->phy.ops.write_reg (hw,E1000_MMDAC ,0 ); -if (ret_val) -return ret_val; - -return ret_val; +return hw->phy.ops.write_reg (hw,E1000_MMDAC ,0 ); }/** drivers/net/ethernet/intel/igc/igc_phy.c +1
-5@@ -675,11 +675,7 @@ static s32 __igc_access_xmdio_reg(struct igc_hw *hw, u16 address,return ret_val;/* Recalibrate the device back to 0 */ - ret_val = hw->phy.ops.write_reg (hw,IGC_MMDAC ,0 ); -if (ret_val) -return ret_val; - -return ret_val; +return hw->phy.ops.write_reg (hw,IGC_MMDAC ,0 ); }/**
Re: [PATCH net-next v2 1/4] dpll: zl3073x: remove conditional return with no effect
In reply to Sang-Heon Jeon25. července 2026 17:08:49 SELČ, Sang-Heon Jeon <[email protected]> napsal:
Quoted 38 lines
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from
scripts/coccinelle/misc/cond_return_no_effect.cocci.Signed-off-by Sang-Heon Jeon <[email protected]>---
drivers/dpll/zl3073x/dpll.c| 6 +-----drivers/dpll/zl3073x/out.c| 8 ++------2 files changed, 3 insertions(+), 11 deletions(-)drivers/dpll/zl3073x/dpll.c +1
-5@@ -2272,11 +2272,7 @@ zl3073x_dpll_init_fine_phase_adjust(struct zl3073x_dev *zldev)if (rc)return rc; - rc =zl3073x_write_u8 (zldev,ZL_REG_SYNTH_PHASE_SHIFT_CTRL ,0x01 ); -if (rc) -return rc; - -return rc; +return zl3073x_write_u8 (zldev,ZL_REG_SYNTH_PHASE_SHIFT_CTRL ,0x01 ); }/** drivers/dpll/zl3073x/out.c +0
-1@@ -85,12 +85,8 @@ int zl3073x_out_state_fetch(struct zl3073x_dev *zldev, u8 index)if (rc)return rc; - rc = zl3073x_read_u32(zldev, ZL_REG_OUTPUT_PHASE_COMP,
drivers/dpll/zl3073x/out.c int zl3073x_out_state_fetch(struct zl3073x_dev *zldev, u8 index) · line 92
Quoted 10 lines
drivers/dpll/zl3073x/out.c +2
-5- &out->phase_comp); -if (rc) -return rc; - -return rc; +return zl3073x_read_u32 (zldev,ZL_REG_OUTPUT_PHASE_COMP , + &out->phase_comp); }/**
Re: [PATCH net-next v2 2/4] net: ethernet: remove conditional return with no effect
In reply to Sang-Heon JeonQuoted 9 lines · Sang-Heon Jeon
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from
scripts/coccinelle/misc/cond_return_no_effect.cocci.Signed-off-by Sang-Heon Jeon <[email protected]>Reviewed-by Niklas Söderlund <[email protected]>Reviewed-by Arthur Kiyanovski <[email protected]>
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Sun, 26 Jul 2026 00:08:48 +0900 you wrote:
Hello,
This series removes conditional returns where both branches return the same value, so the check has no effect. As suggested by Jakub, the netdev patches of the treewide v1 series [1] are posted separately.
All patches are generated by the Coccinelle script, which you can find in v1.
[...]
Here is the summary with links:
- [net-next,v2,1/4] dpll: zl3073x: remove conditional return with no effect
https://git.kernel.org/netdev/net-next/c/87579b8cda9e - [net-next,v2,2/4] net: ethernet: remove conditional return with no effect https://git.kernel.org/netdev/net-next/c/66084e9510a9 - [net-next,v2,3/4] net: remove conditional return with no effect https://git.kernel.org/netdev/net-next/c/cd833378bafa - [net-next,v2,4/4] net: intel: remove conditional return with no effect https://git.kernel.org/netdev/net-next/c/1f35011c281a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html