Skip to contentSkip to conversation

e1000: Remove redundant statement

PATCH In review luo penghao 4 participants 6 messages Oct 18, 2021 – Oct 21, 2021

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

PATCH 1/1 e1000: Remove redundant statement

This statement is redundant in the context, because there will be an identical statement next. otherwise, the variable initialization is actually unnecessary.

The clang_analyzer complains as follows:

drivers/net/ethernet/intel/e1000/e1000_ethtool.c:1218:2 warning:

Value stored to 'ctrl_reg' is never read.

---
 drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -2
index 0a57172..8951f2a 100644
@@ -1215,8 +1215,6 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
 		e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
 	}
 
-	ctrl_reg = er32(CTRL);
-
 	/* force 1000, set loopback */
 	e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);
 
Signature · 1 line
2.15.2
#1 lore raw

PATCH 1/1 e1000: Remove redundant statement

Quoted 21 lines · luo penghao

This statement is redundant in the context, because there will be an identical statement next. otherwise, the variable initialization is actually unnecessary.

The clang_analyzer complains as follows:

drivers/net/ethernet/intel/e1000/e1000_ethtool.c:1218:2 warning:

Value stored to 'ctrl_reg' is never read.

---
  drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 2 --
  1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -0
index 0a57172..8951f2a 100644

drivers/net/ethernet/intel/e1000/e1000_ethtool.c static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) · line 1218

Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
@@ -1215,8 +1215,6 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
  		e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
  	}
 
-	ctrl_reg = er32(CTRL);

Thanks for your patch, but this change is not safe. you're removing a read that could do two things. The first is that the read "flushes" the write just above to PCI (it's a PCI barrier), and the second is that the read can have some side effects.

If this change must be done, the code should be to remove the assignment to ctrl_reg, but leave the read, so the line would just look like:

        er32(CTRL);

This will get rid of the warning and not change the flow from the hardware perspective.

Quoted 6 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
-
  	/* force 1000, set loopback */
  	e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);
 
#2 lore raw

PATCH 1/1 e1000: Remove redundant statement

Quoted 17 lines · jesse.brandeburg at intel.com
Quoted 16 lines · luo penghao

This statement is redundant in the context, because there will be an identical statement next. otherwise, the variable initialization is actually unnecessary.

The clang_analyzer complains as follows:

drivers/net/ethernet/intel/e1000/e1000_ethtool.c:1218:2 warning:

Value stored to 'ctrl_reg' is never read.

---
? drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 2 -- ? 1 file changed, 2 deletions(-)

Quoted 11 lines

drivers/net/ethernet/intel/e1000/e1000_ethtool.c static int e1000_integrated_phy_loopback(struct · line 1218

Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
index 0a57172..8951f2a 100644
@@ -1215,8 +1215,6 @@ static int e1000_integrated_phy_loopback(struct 
 e1000_adapter *adapter)
 ????????? e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
 ????? }
-??? ctrl_reg = er32(CTRL);

Please see my reply below.

Quoted 5 lines

Thanks for your patch, but this change is not safe. you're removing a read that could do two things. The first is that the read "flushes" the write just above to PCI (it's a PCI barrier), and the second is that the read can have some side effects.

Quoted 10 lines

If this change must be done, the code should be to remove the assignment to ctrl_reg, but leave the read, so the line would just look like:
?????? er32(CTRL);

This will get rid of the warning and not change the flow from the hardware perspective.

Quoted 3 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
-

????? /* force 1000, set loopback */
????? e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);

my previous mail seems to have not made it to netdev/patchwork, so re-sending.

NAK. Please respin if you must make this change.

reviewer Reviewed-by on v1 1/1
#3 lore raw
In reply to luo penghao

On Mon, Oct 18, 2021 at 08:53:05AM +0000, luo penghao wrote:

nit: s/linux-next/net-next/ in subject

Quoted 9 lines

This statement is redundant in the context, because there will be an identical statement next. otherwise, the variable initialization is actually unnecessary.

The clang_analyzer complains as follows:

drivers/net/ethernet/intel/e1000/e1000_ethtool.c:1218:2 warning:

Value stored to 'ctrl_reg' is never read.

I agree this does seem to be the case.

Quoted 2 lines
Quoted 21 lines
---
 drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -2
index 0a57172..8951f2a 100644
@@ -1215,8 +1215,6 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
 		e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
 	}
 
-	ctrl_reg = er32(CTRL);
-
 	/* force 1000, set loopback */
 	e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);
 
Signature · 1 line
2.15.2
#4 lore raw

Apologies for the duplicates, mail from my intel account going out through outlook.com is not being delivered.

Quoted 8 lines · Simon Horman
Quoted 1 line

Value stored to 'ctrl_reg' is never read.

I agree this does seem to be the case.

Quoted 2 lines

Thanks for the review, but (davem/kuba) please do not apply.

Quoted 5 lines

drivers/net/ethernet/intel/e1000/e1000_ethtool.c static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) · line 1218

Quoted 5 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
@@ -1215,8 +1215,6 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
              e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
      }
 
-     ctrl_reg = er32(CTRL);

Thanks for your patch, but this change is not safe. you're removing a read that could do two things. The first is that the read "flushes" the write just above to PCI (it's a PCI barrier), and the second is that the read can have some side effects.

If this change must be done, the code should be to remove the assignment to ctrl_reg, but leave the read, so the line would just look like:

        er32(CTRL);

This will get rid of the warning and not change the flow from the hardware perspective.

Quoted 4 lines

drivers/net/ethernet/intel/e1000/e1000_ethtool.c static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) · line 1220

Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
-
      /* force 1000, set loopback */
      e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);
 

Please do not apply this.

reviewer
#5 lore raw
Quoted 7 lines · Jesse Brandeburg

Apologies for the duplicates, mail from my intel account going out through outlook.com is not being delivered.

Quoted 2 lines · Simon Horman
Quoted 1 line

Value stored to 'ctrl_reg' is never read.

Quoted 8 lines
Quoted 6 lines

I agree this does seem to be the case.

Quoted 2 lines

Thanks for the review, but (davem/kuba) please do not apply.

Thanks, and sorry for misunderstanding the patch.

Quoted 27 lines
Quoted 6 lines

drivers/net/ethernet/intel/e1000/e1000_ethtool.c static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) · line 1218

Quoted 6 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
@@ -1215,8 +1215,6 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
              e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
      }
 
-     ctrl_reg = er32(CTRL);

Thanks for your patch, but this change is not safe. you're removing a read that could do two things. The first is that the read "flushes" the write just above to PCI (it's a PCI barrier), and the second is that the read can have some side effects.

If this change must be done, the code should be to remove the assignment to ctrl_reg, but leave the read, so the line would just look like:

        er32(CTRL);

This will get rid of the warning and not change the flow from the hardware perspective.

Quoted 4 lines

drivers/net/ethernet/intel/e1000/e1000_ethtool.c static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) · line 1220

Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_ethtool.c +0 -1
-
      /* force 1000, set loopback */
      e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);
 

Please do not apply this.