Skip to contentSkip to conversation

regulator: remove unnecessary code

PATCH Superseded Gustavo A. R. Silva 2 participants 2 messages Feb 21, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: remove unnecessary code

The name of an array used by itself will always return the array's address. So it makes no sense to evaluate it, since the test will always evaluate as true.

Addresses-Coverity-ID: 751412

---
 drivers/regulator/da9055-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/da9055-regulator.c +1 -1
index d029c94..a118f63 100644
@@ -612,7 +612,7 @@ static int da9055_regulator_probe(struct platform_device *pdev)
 	config.driver_data = regulator;
 	config.regmap = da9055->regmap;
 
-	if (pdata && pdata->regulators) {
+	if (pdata) {
 		config.init_data = pdata->regulators[pdev->id];
 	} else {
 		ret = da9055_regulator_dt_init(pdev, regulator, &config,
Signature · 1 line
2.5.0
maintainer
#1 lore raw

drivers/regulator/da9055-regulator.c static int da9055_regulator_probe(struct platform_device *pdev) · line 615

Quoted 6 lines · Gustavo A. R. Silva

The name of an array used by itself will always return the array's address. So it makes no sense to evaluate it, since the test will always evaluate as true.

drivers/regulator/da9055-regulator.c +1 -1
-	if (pdata && pdata->regulators) {
+	if (pdata) {

This isn't actually helping anything, it just makes the code potentially less robust if someone changes regulators to be allocated separately. There's no cost to having the check in the code, the compiler should notice if it's always true.