Skip to contentSkip to conversation

can: pch_can: move setting of errc to before use

PATCH In review Tom Rix 2 participants 2 messages Jul 21, 2022

Subsystems (3)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 can: pch_can: move setting of errc to before use

clang build fails with
drivers/net/can/pch_can.c:501:17: error: variable 'errc' is uninitialized when used here [-Werror,-Wuninitialized]

                cf->data[6] = errc & PCH_TEC;

The commit in the fixes moved the use without moving the setting. So move the setting of errc to before the use.

Fixes 3a5c7e4611dd ("can: pch_can: do not report txerr and rxerr during bus-off")
---
 drivers/net/can/pch_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/pch_can.c +1 -1
index 50f6719b3aa4..32804fed116c 100644
@@ -489,6 +489,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
 	if (!skb)
 		return;
 
+	errc = ioread32(&priv->regs->errc);
 	if (status & PCH_BUS_OFF) {
 		pch_can_set_tx_all(priv, 0);
 		pch_can_set_rx_all(priv, 0);
@@ -502,7 +503,6 @@ static void pch_can_error(struct net_device *ndev, u32 status)
 		cf->data[7] = (errc & PCH_REC) >> 8;
 	}
 
-	errc = ioread32(&priv->regs->errc);
 	/* Warning interrupt. */
 	if (status & PCH_EWARN) {
 		state = CAN_STATE_ERROR_WARNING;
Signature · 1 line
2.27.0
#1 lore raw
Quoted 9 lines · Tom Rix

clang build fails with
drivers/net/can/pch_can.c:501:17: error: variable 'errc' is uninitialized when used here [-Werror,-Wuninitialized]

                cf->data[6] = errc & PCH_TEC;

The commit in the fixes moved the use without moving the setting. So move the setting of errc to before the use.

Fixes 3a5c7e4611dd ("can: pch_can: do not report txerr and rxerr during bus-off")

Sorry, you are a couple minutes late. You are actually the third to submit the same patch:
https://lore.kernel.org/linux-can/[email protected]/
https://lore.kernel.org/linux-can/[email protected]/

But thanks for this!

Yours sincerely,
Vincent Mailhol