[Skiboot] [PATCH 1/9] occ-sensors: Remove NULL checks after dereference
Cyril Bur
cyril.bur at au1.ibm.com
Mon Mar 19 15:54:12 AEDT 2018
Both scale_sensor() and scale_energy() take the value to scale as a
pointer. These functions do not NULL check the pointer before the first
time they dereference it, which is fine since passing NULL would be
completely pointless.
Both functions do perform a pointless NULL check later on. This
confuses coverity and really doesn't make much sense at all. Since
calling these functions with NULL as the sensor parameter makes no
sense, and currently theres a dereference before the check, just remove
the check.
Fixes: CID 264276 and 264275
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
hw/occ-sensor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c
index 090e0f07..fffcccb2 100644
--- a/hw/occ-sensor.c
+++ b/hw/occ-sensor.c
@@ -154,7 +154,7 @@ static void scale_sensor(struct occ_sensor_name *md, u64 *sensor)
for (i = labs(exp); i > 0; i--)
*sensor *= 10;
} else {
- for (i = labs(exp); sensor && i > 0; i--)
+ for (i = labs(exp); i > 0; i--)
*sensor /= 10;
}
}
@@ -171,7 +171,7 @@ static void scale_energy(struct occ_sensor_name *md, u64 *sensor)
exp = factor & 0xFF;
if (exp > 0) {
- for (i = labs(exp); sensor && i > 0; i--)
+ for (i = labs(exp); i > 0; i--)
*sensor /= 10;
} else {
for (i = labs(exp); i > 0; i--)
--
2.16.2
More information about the Skiboot
mailing list