Skip to contentSkip to conversation

PM / OPP: silence an uninitialized variable warning

PATCH In review Dan Carpenter 2 participants 3 messages May 16, 2018

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

PATCH 1/1 PM / OPP: silence an uninitialized variable warning

Smatch complains that "rate" can be uninitialized here.

drivers/opp/of.c +2 -1
index 7026e9f484ea..afc844806db0 100644
@@ -317,7 +317,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev,
 
 	/* Check if the OPP supports hardware's hierarchy of versions or not */
 	if (!_opp_is_supported(dev, opp_table, np)) {
-		dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate);
+		dev_dbg(dev, "OPP not supported by hardware: %lu\n",
+			new_opp->rate);
 		goto free_opp;
 	}
 
#1 lore raw
Quoted 9 lines · Dan Carpenter

Smatch complains that "rate" can be uninitialized here.

drivers/opp/of.c +0 -0
index 7026e9f484ea..afc844806db0 100644

drivers/opp/of.c static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, · line 323

Quoted 8 lines
drivers/opp/of.c +2 -1
@@ -317,7 +317,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev,
 
 	/* Check if the OPP supports hardware's hierarchy of versions or not */
 	if (!_opp_is_supported(dev, opp_table, np)) {
-		dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate);
+		dev_dbg(dev, "OPP not supported by hardware: %lu\n",
+			new_opp->rate);
 		goto free_opp;
 	}

Well, I never got that warning nor did the buildbot report me anything like that. Not sure how you got that :)

But AFAICT, there is indeed a path where this can happen and I am not sure the proposed solution is the most readable one. I would rather initialize rate to 0 while defining it at the top.

Signature · 1 line
viresh
#2 lore raw
In reply to Dan Carpenter
Quoted 22 lines · Viresh Kumar
Quoted 9 lines · Dan Carpenter

Smatch complains that "rate" can be uninitialized here.

drivers/opp/of.c +0 -0
index 7026e9f484ea..afc844806db0 100644

drivers/opp/of.c static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, · line 323

Quoted 8 lines
drivers/opp/of.c +2 -1
@@ -317,7 +317,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev,
 
 	/* Check if the OPP supports hardware's hierarchy of versions or not */
 	if (!_opp_is_supported(dev, opp_table, np)) {
-		dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate);
+		dev_dbg(dev, "OPP not supported by hardware: %lu\n",
+			new_opp->rate);
 		goto free_opp;
 	}

Well, I never got that warning nor did the buildbot report me anything like that. Not sure how you got that :)

Quoted 4 lines

But AFAICT, there is indeed a path where this can happen and I am not sure the proposed solution is the most readable one. I would rather initialize rate to 0 while defining it at the top.

Sure. No problem. I'll resend.

regards,
dan carpenter