linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: st: avoid uninitialized variable use
@ 2015-11-12 14:24 Arnd Bergmann
  2015-11-16  8:27 ` Gabriel Fernandez
  2015-11-20 18:59 ` Stephen Boyd
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2015-11-12 14:24 UTC (permalink / raw)
  To: linux-arm-kernel

quadfs_pll_fs660c32_round_rate prints a few structure members
that are never initialized, and also doesn't print the only one
it cares about. We get a gcc warning about the ones that
are printed:

clk/st/clkgen-fsyn.c:560:93: warning: 'params.sdiv' may be used uninitialized in this function
clk/st/clkgen-fsyn.c:560:93: warning: 'params.mdiv' may be used uninitialized in this function
clk/st/clkgen-fsyn.c:560:93: warning: 'params.pe' may be used uninitialized in this function
clk/st/clkgen-fsyn.c:560:93: warning: 'params.nsdiv' may be used uninitialized in this function

This changes the code to no longer print uninitialized data, and
for good measure it also prints the ndiv member that is being
set.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 5f7aa9071e93 ("clk: st: Support for QUADFS inside ClockGenB/C/D/E/F")

diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c
index 576cd0354d48..ccb324d97160 100644
--- a/drivers/clk/st/clkgen-fsyn.c
+++ b/drivers/clk/st/clkgen-fsyn.c
@@ -549,19 +549,20 @@ static int clk_fs660c32_vco_get_params(unsigned long input,
 	return 0;
 }
 
-static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw, unsigned long rate
-		, unsigned long *prate)
+static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw,
+					   unsigned long rate,
+					   unsigned long *prate)
 {
 	struct stm_fs params;
 
-	if (!clk_fs660c32_vco_get_params(*prate, rate, &params))
-		clk_fs660c32_vco_get_rate(*prate, &params, &rate);
+	if (clk_fs660c32_vco_get_params(*prate, rate, &params))
+		return rate;
 
-	pr_debug("%s: %s new rate %ld [sdiv=0x%x,md=0x%x,pe=0x%x,nsdiv3=%u]\n",
+	clk_fs660c32_vco_get_rate(*prate, &params, &rate);
+
+	pr_debug("%s: %s new rate %ld [ndiv=%u]\n",
 		 __func__, clk_hw_get_name(hw),
-		 rate, (unsigned int)params.sdiv,
-		 (unsigned int)params.mdiv,
-		 (unsigned int)params.pe, (unsigned int)params.nsdiv);
+		 rate, (unsigned int)params.ndiv);
 
 	return rate;
 }

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] clk: st: avoid uninitialized variable use
  2015-11-12 14:24 [PATCH] clk: st: avoid uninitialized variable use Arnd Bergmann
@ 2015-11-16  8:27 ` Gabriel Fernandez
  2015-11-20 18:59 ` Stephen Boyd
  1 sibling, 0 replies; 5+ messages in thread
From: Gabriel Fernandez @ 2015-11-16  8:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 12 November 2015 at 15:24, Arnd Bergmann <arnd@arndb.de> wrote:
> quadfs_pll_fs660c32_round_rate prints a few structure members
> that are never initialized, and also doesn't print the only one
> it cares about. We get a gcc warning about the ones that
> are printed:
>
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.sdiv' may be used uninitialized in this function
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.mdiv' may be used uninitialized in this function
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.pe' may be used uninitialized in this function
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.nsdiv' may be used uninitialized in this function
>
> This changes the code to no longer print uninitialized data, and
> for good measure it also prints the ndiv member that is being
> set.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 5f7aa9071e93 ("clk: st: Support for QUADFS inside ClockGenB/C/D/E/F")
>
> diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c
> index 576cd0354d48..ccb324d97160 100644
> --- a/drivers/clk/st/clkgen-fsyn.c
> +++ b/drivers/clk/st/clkgen-fsyn.c
> @@ -549,19 +549,20 @@ static int clk_fs660c32_vco_get_params(unsigned long input,
>         return 0;
>  }
>
> -static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw, unsigned long rate
> -               , unsigned long *prate)
> +static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw,
> +                                          unsigned long rate,
> +                                          unsigned long *prate)
>  {
>         struct stm_fs params;
>
> -       if (!clk_fs660c32_vco_get_params(*prate, rate, &params))
> -               clk_fs660c32_vco_get_rate(*prate, &params, &rate);
> +       if (clk_fs660c32_vco_get_params(*prate, rate, &params))
> +               return rate;
>
> -       pr_debug("%s: %s new rate %ld [sdiv=0x%x,md=0x%x,pe=0x%x,nsdiv3=%u]\n",
> +       clk_fs660c32_vco_get_rate(*prate, &params, &rate);
> +
> +       pr_debug("%s: %s new rate %ld [ndiv=%u]\n",
>                  __func__, clk_hw_get_name(hw),
> -                rate, (unsigned int)params.sdiv,
> -                (unsigned int)params.mdiv,
> -                (unsigned int)params.pe, (unsigned int)params.nsdiv);
> +                rate, (unsigned int)params.ndiv);
>
>         return rate;
>  }
>
>
Acked-by: Gabriel Fernandez <gabriel.fernandez@linaro.org>

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] clk: st: avoid uninitialized variable use
  2015-11-12 14:24 [PATCH] clk: st: avoid uninitialized variable use Arnd Bergmann
  2015-11-16  8:27 ` Gabriel Fernandez
@ 2015-11-20 18:59 ` Stephen Boyd
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2015-11-20 18:59 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/12, Arnd Bergmann wrote:
> quadfs_pll_fs660c32_round_rate prints a few structure members
> that are never initialized, and also doesn't print the only one
> it cares about. We get a gcc warning about the ones that
> are printed:
> 
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.sdiv' may be used uninitialized in this function
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.mdiv' may be used uninitialized in this function
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.pe' may be used uninitialized in this function
> clk/st/clkgen-fsyn.c:560:93: warning: 'params.nsdiv' may be used uninitialized in this function
> 
> This changes the code to no longer print uninitialized data, and
> for good measure it also prints the ndiv member that is being
> set.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 5f7aa9071e93 ("clk: st: Support for QUADFS inside ClockGenB/C/D/E/F")
> 
> diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c
> index 576cd0354d48..ccb324d97160 100644
> --- a/drivers/clk/st/clkgen-fsyn.c

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] clk: st: avoid uninitialized variable use
  2016-01-25 15:54 Arnd Bergmann
@ 2016-01-30  1:20 ` Stephen Boyd
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2016-01-30  1:20 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/25, Arnd Bergmann wrote:
> My previous patch fixed some warnings about printing a couple
> of variables that are always uninitialized in quadfs_pll_fs660c32_set_rate(),
> but I now got a warning that only shows up in some configurations (i.e.
> without gcc -Os) about the params.ndiv being used uninitialized in the
> error case:
> 
> drivers/clk/st/clkgen-fsyn.c: In function 'quadfs_pll_fs660c32_set_rate':
> drivers/clk/st/clkgen-fsyn.c:584:75: warning: 'params.ndiv' may be used uninitialized in this function [-Wmaybe-uninitialized]
> drivers/clk/st/clkgen-fsyn.c:574:16: note: 'params.ndiv' was declared here
> 
> This changes the error handling so we bail for invalid arguments rather
> than continuing with uninitialized data.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] clk: st: avoid uninitialized variable use
@ 2016-01-25 15:54 Arnd Bergmann
  2016-01-30  1:20 ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2016-01-25 15:54 UTC (permalink / raw)
  To: linux-arm-kernel

My previous patch fixed some warnings about printing a couple
of variables that are always uninitialized in quadfs_pll_fs660c32_set_rate(),
but I now got a warning that only shows up in some configurations (i.e.
without gcc -Os) about the params.ndiv being used uninitialized in the
error case:

drivers/clk/st/clkgen-fsyn.c: In function 'quadfs_pll_fs660c32_set_rate':
drivers/clk/st/clkgen-fsyn.c:584:75: warning: 'params.ndiv' may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/clk/st/clkgen-fsyn.c:574:16: note: 'params.ndiv' was declared here

This changes the error handling so we bail for invalid arguments rather
than continuing with uninitialized data.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/clk/st/clkgen-fsyn.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c
index ccb324d97160..dec4eaaecc00 100644
--- a/drivers/clk/st/clkgen-fsyn.c
+++ b/drivers/clk/st/clkgen-fsyn.c
@@ -574,12 +574,16 @@ static int quadfs_pll_fs660c32_set_rate(struct clk_hw *hw, unsigned long rate,
 	struct stm_fs params;
 	long hwrate = 0;
 	unsigned long flags = 0;
+	int ret;
 
 	if (!rate || !parent_rate)
 		return -EINVAL;
 
-	if (!clk_fs660c32_vco_get_params(parent_rate, rate, &params))
-		clk_fs660c32_vco_get_rate(parent_rate, &params, &hwrate);
+	ret = clk_fs660c32_vco_get_params(parent_rate, rate, &params);
+	if (ret)
+		return ret;
+
+	clk_fs660c32_vco_get_rate(parent_rate, &params, &hwrate);
 
 	pr_debug("%s: %s new rate %ld [ndiv=0x%x]\n",
 		 __func__, clk_hw_get_name(hw),
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-30  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 14:24 [PATCH] clk: st: avoid uninitialized variable use Arnd Bergmann
2015-11-16  8:27 ` Gabriel Fernandez
2015-11-20 18:59 ` Stephen Boyd
2016-01-25 15:54 Arnd Bergmann
2016-01-30  1:20 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).