igb: zero hwtstamp by default
Subsystems (3)
PATCH 1/1 igb: zero hwtstamp by default
From: Tom Rix <[email protected]>
Clang static analysis reports this representative issue igb_ptp.c:997:3: warning: The left operand of '+' is a
garbage value ktime_add_ns(shhwtstamps.hwtstamp, adjust);
^ ~~~~~~~~~~~~~~~~~~~~
shhwtstamps.hwtstamp is set by a call to igb_ptp_systim_to_hwtstamp(). In the switch-statement for the hw type, the hwtstamp is zeroed for matches but not the default case. Move the memset out of switch-statement. This degarbages the default case and reduces the size.
Some whitespace cleanup of empty lines
--- drivers/net/ethernet/intel/igb/igb_ptp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_ptp.c +2 -4
@@ -165,23 +165,21 @@ static void igb_ptp_systim_to_hwtstamp(struct igb_adapter *adapter,unsigned long flags;u64 ns; +memset (hwtstamps,0 ,sizeof (*hwtstamps)); +switch (adapter->hw.mac.type) {case e1000_82576:case e1000_82580:case e1000_i354:case e1000_i350:spin_lock_irqsave (&adapter->tmreg_lock, flags); - ns =timecounter_cyc2time (&adapter->tc, systim); -spin_unlock_irqrestore (&adapter->tmreg_lock, flags); -memset (hwtstamps,0 ,sizeof (*hwtstamps)); hwtstamps->hwtstamp =ns_to_ktime (ns);break ;case e1000_i210:case e1000_i211: -memset (hwtstamps,0 ,sizeof (*hwtstamps));/* Upper 32 bits contain s, lower 32 bits contain ns. */ hwtstamps->hwtstamp =ktime_set (systim >>32 , systim &0xFFFFFFFF );
Signature · 1 line
2.26.3
Quoted 27 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of trix at redhat.com
Sent: Sunday, March 13, 2022 8:32 PM
To: Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; davem at davemloft.net; kuba at kernel.org; nathan at kernel.org; ndesaulniers at google.com
Cc: netdev at vger.kernel.org; llvm at lists.linux.dev; intel-wired- lan at lists.osuosl.org; linux-kernel at vger.kernel.org; Tom Rix <[email protected]>
Subject: [Intel-wired-lan] [PATCH] igb: zero hwtstamp by defaultFrom: Tom Rix <[email protected]>
Clang static analysis reports this representative issue igb_ptp.c:997:3: warning: The left operand of '+' is a
garbage valuektime_add_ns(shhwtstamps.hwtstamp, adjust);
^ ~~~~~~~~~~~~~~~~~~~~shhwtstamps.hwtstamp is set by a call to
igb_ptp_systim_to_hwtstamp(). In the switch-statement for the hw type, the hwtstamp is zeroed for matches but not the default case. Move the memset out of switch-statement. This degarbages the default case and reduces the size.
Quoted 7 lines
Some whitespace cleanup of empty lines
Signed-off-by Tom Rix <[email protected]>--- drivers/net/ethernet/intel/igb/igb_ptp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)