Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1377550 > unrolled thread

[patch] ARM: qcom: silence an uninitialized variable warning

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-04-13 08:50 +0200
Last post2016-04-14 11:10 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [patch] ARM: qcom: silence an uninitialized variable warning Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-13 08:50 +0200
    Re: [patch] ARM: qcom: silence an uninitialized variable warning Tim Bird <tim.bird@sonymobile.com> - 2016-04-14 02:50 +0200
    Re: [patch] ARM: qcom: silence an uninitialized variable warning Arnd Bergmann <arnd@arndb.de> - 2016-04-14 04:00 +0200
      Re: [patch] ARM: qcom: silence an uninitialized variable warning Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-14 11:10 +0200

#1377550 — [patch] ARM: qcom: silence an uninitialized variable warning

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-04-13 08:50 +0200
Subject[patch] ARM: qcom: silence an uninitialized variable warning
Message-ID<rnmMG-5bA-15@gated-at.bofh.it>
It's harmless but, if "enable" isn't set, then we pass uninitialized
values to qcom_coincell_chgr_config().  The values aren't used, but
let's silence the warning anyway.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/misc/qcom-coincell.c b/drivers/misc/qcom-coincell.c
index 7b4a2da..829a61d 100644
--- a/drivers/misc/qcom-coincell.c
+++ b/drivers/misc/qcom-coincell.c
@@ -94,7 +94,8 @@ static int qcom_coincell_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct qcom_coincell chgr;
-	u32 rset, vset;
+	u32 rset = 0;
+	u32 vset = 0;
 	bool enable;
 	int rc;
 

[toc] | [next] | [standalone]


#1378371

FromTim Bird <tim.bird@sonymobile.com>
Date2016-04-14 02:50 +0200
Message-ID<rnDDP-1uB-5@gated-at.bofh.it>
In reply to#1377550

On 04/12/2016 11:45 PM, Dan Carpenter wrote:
> It's harmless but, if "enable" isn't set, then we pass uninitialized
> values to qcom_coincell_chgr_config().  The values aren't used, but
> let's silence the warning anyway.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/misc/qcom-coincell.c b/drivers/misc/qcom-coincell.c
> index 7b4a2da..829a61d 100644
> --- a/drivers/misc/qcom-coincell.c
> +++ b/drivers/misc/qcom-coincell.c
> @@ -94,7 +94,8 @@ static int qcom_coincell_probe(struct platform_device *pdev)
>  {
>  	struct device_node *node = pdev->dev.of_node;
>  	struct qcom_coincell chgr;
> -	u32 rset, vset;
> +	u32 rset = 0;
> +	u32 vset = 0;
>  	bool enable;
>  	int rc;
>  
> 
Looks OK to me.  Thanks for the warning cleanup!

Acked-by: Tim Bird
 -- Tim

[toc] | [prev] | [next] | [standalone]


#1378390

FromArnd Bergmann <arnd@arndb.de>
Date2016-04-14 04:00 +0200
Message-ID<rnEJz-2fa-1@gated-at.bofh.it>
In reply to#1377550
On Wednesday 13 April 2016, Dan Carpenter wrote:
> It's harmless but, if "enable" isn't set, then we pass uninitialized
> values to qcom_coincell_chgr_config().  The values aren't used, but
> let's silence the warning anyway.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

I haven't seen this warning in my tests, which means it probably doesn't show up
in the usual configurations. Are you sure this doesn't just happen with
CONFIG_PROFILE_ALL_BRANCHES, CONFIG_CC_OPTIMIZE_FOR_SIZE or CONFIG_GCOV_PROFILE_ALL,
or with versions of gcc before 4.9?

	Arnd

> diff --git a/drivers/misc/qcom-coincell.c b/drivers/misc/qcom-coincell.c
> index 7b4a2da..829a61d 100644
> --- a/drivers/misc/qcom-coincell.c
> +++ b/drivers/misc/qcom-coincell.c
> @@ -94,7 +94,8 @@ static int qcom_coincell_probe(struct platform_device *pdev)
>  {
>  	struct device_node *node = pdev->dev.of_node;
>  	struct qcom_coincell chgr;
> -	u32 rset, vset;
> +	u32 rset = 0;
> +	u32 vset = 0;
>  	bool enable;
>  	int rc;
>  
> 

[toc] | [prev] | [next] | [standalone]


#1378628

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-04-14 11:10 +0200
Message-ID<rnLrJ-7Nv-35@gated-at.bofh.it>
In reply to#1378390
On Thu, Apr 14, 2016 at 03:53:03AM +0200, Arnd Bergmann wrote:
> On Wednesday 13 April 2016, Dan Carpenter wrote:
> > It's harmless but, if "enable" isn't set, then we pass uninitialized
> > values to qcom_coincell_chgr_config().  The values aren't used, but
> > let's silence the warning anyway.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> I haven't seen this warning in my tests, which means it probably doesn't show up
> in the usual configurations. Are you sure this doesn't just happen with
> CONFIG_PROFILE_ALL_BRANCHES, CONFIG_CC_OPTIMIZE_FOR_SIZE or CONFIG_GCOV_PROFILE_ALL,
> or with versions of gcc before 4.9?
> 

This is a smatch stuff I'm working on.  Realistically, I have to make
Smatch warn when we pass uninitialized values to a function.  I can't
make smatch do the extra analysis to test if the values are used or not.

regards,
dan carpenter

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web