Message ID | 1453903507-3427225-8-git-send-email-arnd@arndb.de |
---|---|
State | New |
Headers | show |
Series | None | expand |
Le 27/01/2016 15:04, Arnd Bergmann a écrit : > The macb_clk_init function returns three clock pointers, unless > the it fails to get the first ones. We correctly handle the > failure case by propagating the error from macb_probe, but > gcc does not realize this and incorrectly warns about a later > use of those: > > In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: > drivers/net/ethernet/cadence/macb.c: In function 'macb_probe': > include/linux/clk.h:484:2: error: 'tx_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized] > clk_disable(clk); > ^ > drivers/net/ethernet/cadence/macb.c:2822:28: note: 'tx_clk' was declared here > struct clk *pclk, *hclk, *tx_clk; > ^ > In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: > include/linux/clk.h:484:2: error: 'hclk' may be used uninitialized in this function [-Werror=maybe-uninitialized] > clk_disable(clk); > ^ > drivers/net/ethernet/cadence/macb.c:2822:21: note: 'hclk' was declared here > struct clk *pclk, *hclk, *tx_clk; > ^ > > This shuts up the misleading warnings by ensuring that the > macb_clk_init() always stores something into all three pointers. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Okay Arnd, thanks! Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> > --- > drivers/net/ethernet/cadence/macb.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c > index 9d9984a87d42..d3aa74f9db79 100644 > --- a/drivers/net/ethernet/cadence/macb.c > +++ b/drivers/net/ethernet/cadence/macb.c > @@ -2268,6 +2268,7 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, > { > int err; > > + *tx_clk = *hclk = NULL; > *pclk = devm_clk_get(&pdev->dev, "pclk"); > if (IS_ERR(*pclk)) { > err = PTR_ERR(*pclk); > -- Nicolas Ferre
Le 27/01/2016 16:51, Nicolas Ferre a écrit : > Le 27/01/2016 15:04, Arnd Bergmann a écrit : >> The macb_clk_init function returns three clock pointers, unless >> the it fails to get the first ones. We correctly handle the >> failure case by propagating the error from macb_probe, but >> gcc does not realize this and incorrectly warns about a later >> use of those: >> >> In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: >> drivers/net/ethernet/cadence/macb.c: In function 'macb_probe': >> include/linux/clk.h:484:2: error: 'tx_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized] >> clk_disable(clk); >> ^ >> drivers/net/ethernet/cadence/macb.c:2822:28: note: 'tx_clk' was declared here >> struct clk *pclk, *hclk, *tx_clk; >> ^ >> In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: >> include/linux/clk.h:484:2: error: 'hclk' may be used uninitialized in this function [-Werror=maybe-uninitialized] >> clk_disable(clk); >> ^ >> drivers/net/ethernet/cadence/macb.c:2822:21: note: 'hclk' was declared here >> struct clk *pclk, *hclk, *tx_clk; >> ^ >> >> This shuts up the misleading warnings by ensuring that the >> macb_clk_init() always stores something into all three pointers. >> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > Okay Arnd, thanks! > > Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Oh, crap: actually this warning has just been fixed by Sudip Mukherjee and is already queued by David here: https://patchwork.ozlabs.org/patch/572610/ So, sorry, I've shot too fast: NACK... Bye, >> --- >> drivers/net/ethernet/cadence/macb.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c >> index 9d9984a87d42..d3aa74f9db79 100644 >> --- a/drivers/net/ethernet/cadence/macb.c >> +++ b/drivers/net/ethernet/cadence/macb.c >> @@ -2268,6 +2268,7 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, >> { >> int err; >> >> + *tx_clk = *hclk = NULL; >> *pclk = devm_clk_get(&pdev->dev, "pclk"); >> if (IS_ERR(*pclk)) { >> err = PTR_ERR(*pclk); >> > > -- Nicolas Ferre
Hello. On 1/27/2016 5:04 PM, Arnd Bergmann wrote: > The macb_clk_init function returns three clock pointers, unless > the it fails to get the first ones. We correctly handle the s/the//. > failure case by propagating the error from macb_probe, but > gcc does not realize this and incorrectly warns about a later > use of those: > > In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: > drivers/net/ethernet/cadence/macb.c: In function 'macb_probe': Hm, didn't these 2 lines get swapped by chance? > include/linux/clk.h:484:2: error: 'tx_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized] > clk_disable(clk); > ^ > drivers/net/ethernet/cadence/macb.c:2822:28: note: 'tx_clk' was declared here > struct clk *pclk, *hclk, *tx_clk; > ^ > In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: > include/linux/clk.h:484:2: error: 'hclk' may be used uninitialized in this function [-Werror=maybe-uninitialized] > clk_disable(clk); > ^ > drivers/net/ethernet/cadence/macb.c:2822:21: note: 'hclk' was declared here > struct clk *pclk, *hclk, *tx_clk; > ^ > > This shuts up the misleading warnings by ensuring that the > macb_clk_init() always stores something into all three pointers. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> [...] MBR, Sergei
On Wednesday 27 January 2016 17:04:47 Nicolas Ferre wrote: > > > > Okay Arnd, thanks! > > > > Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> > > Oh, crap: actually this warning has just been fixed by Sudip Mukherjee > and is already queued by David here: > https://patchwork.ozlabs.org/patch/572610/ > > So, sorry, I've shot too fast: NACK... Ok, thanks for pointing this out. Arnd
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 9d9984a87d42..d3aa74f9db79 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -2268,6 +2268,7 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, { int err; + *tx_clk = *hclk = NULL; *pclk = devm_clk_get(&pdev->dev, "pclk"); if (IS_ERR(*pclk)) { err = PTR_ERR(*pclk);
The macb_clk_init function returns three clock pointers, unless the it fails to get the first ones. We correctly handle the failure case by propagating the error from macb_probe, but gcc does not realize this and incorrectly warns about a later use of those: In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: drivers/net/ethernet/cadence/macb.c: In function 'macb_probe': include/linux/clk.h:484:2: error: 'tx_clk' may be used uninitialized in this function [-Werror=maybe-uninitialized] clk_disable(clk); ^ drivers/net/ethernet/cadence/macb.c:2822:28: note: 'tx_clk' was declared here struct clk *pclk, *hclk, *tx_clk; ^ In file included from /git/arm-soc/drivers/net/ethernet/cadence/macb.c:12:0: include/linux/clk.h:484:2: error: 'hclk' may be used uninitialized in this function [-Werror=maybe-uninitialized] clk_disable(clk); ^ drivers/net/ethernet/cadence/macb.c:2822:21: note: 'hclk' was declared here struct clk *pclk, *hclk, *tx_clk; ^ This shuts up the misleading warnings by ensuring that the macb_clk_init() always stores something into all three pointers. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/ethernet/cadence/macb.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.0