Skip to content

Commit

Permalink
occ-sensors: Remove NULL checks after dereference
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
cyrilbur-ibm authored and stewartsmith committed Mar 27, 2018
1 parent 8c02243 commit 5630c81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw/occ-sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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--)
Expand Down

0 comments on commit 5630c81

Please sign in to comment.