diff mbox series

[1/9] occ-sensors: Remove NULL checks after dereference

Message ID 20180319045420.22046-2-cyril.bur@au1.ibm.com
State Accepted
Headers show
Series Coverity fixes | expand

Commit Message

Cyril Bur March 19, 2018, 4:54 a.m. UTC
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@au1.ibm.com>
---
 hw/occ-sensor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

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--)