Skip to contentSkip to conversation

ARM: qcom: silence an uninitialized variable warning

PATCH In review Dan Carpenter 3 participants 4 messages Apr 13, 2016 – Apr 14, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: qcom: silence an uninitialized variable warning

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.

drivers/misc/qcom-coincell.c +2 -1
index 7b4a2da..829a61d 100644
@@ -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;
 
#1 lore raw
Quoted 12 lines · Dan Carpenter

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.

drivers/misc/qcom-coincell.c +0 -0
index 7b4a2da..829a61d 100644

drivers/misc/qcom-coincell.c static int qcom_coincell_probe(struct platform_device *pdev) · line 101

Quoted 9 lines
drivers/misc/qcom-coincell.c +2 -1
@@ -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

maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

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.

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

Quoted 15 lines
drivers/misc/qcom-coincell.c +2 -1
index 7b4a2da..829a61d 100644
@@ -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;
 
#3 lore raw
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Dan Carpenter

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.

Quoted 7 lines
Quoted 1 line

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