]>
Commit | Line | Data |
---|---|---|
ba172962 SL |
1 | From e0d8bf746be3f96b112c6e7f234916d707a54438 Mon Sep 17 00:00:00 2001 |
2 | From: Nathan Chancellor <natechancellor@gmail.com> | |
3 | Date: Thu, 7 Mar 2019 11:00:28 -0700 | |
4 | Subject: net: stmmac: Avoid sometimes uninitialized Clang warnings | |
5 | ||
6 | [ Upstream commit df103170854e87124ee7bdd2bca64b178e653f97 ] | |
7 | ||
8 | When building with -Wsometimes-uninitialized, Clang warns: | |
9 | ||
10 | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] | |
11 | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:495:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] | |
12 | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] | |
13 | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:532:3: warning: variable 'ns' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] | |
14 | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] | |
15 | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:741:3: warning: variable 'sec_inc' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] | |
16 | ||
17 | Clang is concerned with the use of stmmac_do_void_callback (which | |
18 | stmmac_get_timestamp and stmmac_config_sub_second_increment wrap), | |
19 | as it may fail to initialize these values if the if condition was ever | |
20 | false (meaning the callbacks don't exist). It's not wrong because the | |
21 | callbacks (get_timestamp and config_sub_second_increment respectively) | |
22 | are the ones that initialize the variables. While it's unlikely that the | |
23 | callbacks are ever going to disappear and make that condition false, we | |
24 | can easily avoid this warning by zero initialize the variables. | |
25 | ||
26 | Link: https://github.com/ClangBuiltLinux/linux/issues/384 | |
27 | Suggested-by: Nick Desaulniers <ndesaulniers@google.com> | |
28 | Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> | |
29 | Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> | |
30 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
31 | Signed-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 | ||
36 | diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |
37 | index 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 | -- | |
69 | 2.19.1 | |
70 |