]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.34/net-stmmac-avoid-sometimes-uninitialized-clang-warni.patch
Linux 4.19.34
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / net-stmmac-avoid-sometimes-uninitialized-clang-warni.patch
CommitLineData
ba172962
SL
1From e0d8bf746be3f96b112c6e7f234916d707a54438 Mon Sep 17 00:00:00 2001
2From: Nathan Chancellor <natechancellor@gmail.com>
3Date: Thu, 7 Mar 2019 11:00:28 -0700
4Subject: net: stmmac: Avoid sometimes uninitialized Clang warnings
5
6[ Upstream commit df103170854e87124ee7bdd2bca64b178e653f97 ]
7
8When building with -Wsometimes-uninitialized, Clang warns:
9
10drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
11drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
12drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
13drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
14drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
15drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
16
17Clang is concerned with the use of stmmac_do_void_callback (which
18stmmac_get_timestamp and stmmac_config_sub_second_increment wrap),
19as it may fail to initialize these values if the if condition was ever
20false (meaning the callbacks don't exist). It's not wrong because the
21callbacks (get_timestamp and config_sub_second_increment respectively)
22are the ones that initialize the variables. While it's unlikely that the
23callbacks are ever going to disappear and make that condition false, we
24can easily avoid this warning by zero initialize the variables.
25
26Link: https://github.com/ClangBuiltLinux/linux/issues/384
27Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
28Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
29Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
30Signed-off-by: David S. Miller <davem@davemloft.net>
31Signed-off-by: Sasha Levin <sashal@kernel.org>
32---
33 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
34 1 file changed, 3 insertions(+), 3 deletions(-)
35
36diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
37index 43ab9e905bed..886176be818e 100644
38--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
39+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
40@@ -474,7 +474,7 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv,
41 struct dma_desc *p, struct sk_buff *skb)
42 {
43 struct skb_shared_hwtstamps shhwtstamp;
44- u64 ns;
45+ u64 ns = 0;
46
47 if (!priv->hwts_tx_en)
48 return;
49@@ -513,7 +513,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
50 {
51 struct skb_shared_hwtstamps *shhwtstamp = NULL;
52 struct dma_desc *desc = p;
53- u64 ns;
54+ u64 ns = 0;
55
56 if (!priv->hwts_rx_en)
57 return;
58@@ -558,8 +558,8 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
59 u32 snap_type_sel = 0;
60 u32 ts_master_en = 0;
61 u32 ts_event_en = 0;
62+ u32 sec_inc = 0;
63 u32 value = 0;
64- u32 sec_inc;
65 bool xmac;
66
67 xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;
68--
692.19.1
70