hwmon: (acpi_power_meter) Remove unnecessary if statement
Guenter Roeck
maintainerPATCH 3/4 hwmon: (acpi_power_meter) Remove unnecessary if statement
An unsigned value is never smaller than 0. Remove the check for it.
--- drivers/hwmon/acpi_power_meter.c | 2 -- 1 file changed, 2 deletions(-)
drivers/hwmon/acpi_power_meter.c +0 -2
@@ -308,8 +308,6 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,return res; temp /=1000 ; -if (temp <0 ) -return -EINVAL ;mutex_lock (&resource->lock); resource->trip[attr->index -7 ] = temp;
Signature · 7 lines
1.7.9.7 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 12 lines · Guenter Roeck
An unsigned value is never smaller than 0. Remove the check for it.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/acpi_power_meter.c | 2 -- 1 file changed, 2 deletions(-)drivers/hwmon/acpi_power_meter.c +0
-0
drivers/hwmon/acpi_power_meter.c static ssize_t set_trip(struct device *dev, struct device_attribute *devattr, · line 313
Quoted 8 lines
drivers/hwmon/acpi_power_meter.c +0
-2@@ -308,8 +308,6 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,return res; temp /=1000 ; -if (temp <0 ) -return -EINVAL ;mutex_lock (&resource->lock); resource->trip[attr->index -7 ] = temp;
That being said, DIV_ROUND_CLOSEST would be better to use than /=, and some clamping on the value would be good to have too, as you can't always fit an unsigned long into an int (there may even be other constraints, I don't know.)
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 24 lines · Jean Delvare
Quoted 12 lines · Guenter Roeck
An unsigned value is never smaller than 0. Remove the check for it.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/acpi_power_meter.c | 2 -- 1 file changed, 2 deletions(-)drivers/hwmon/acpi_power_meter.c +0
-0drivers/hwmon/acpi_power_meter.c static ssize_t set_trip(struct device *dev, struct device_attribute *devattr, · line 313
Quoted 8 lines
drivers/hwmon/acpi_power_meter.c +0
-2@@ -308,8 +308,6 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,return res; temp /=1000 ; -if (temp <0 ) -return -EINVAL ;mutex_lock (&resource->lock); resource->trip[attr->index -7 ] = temp;Acked-by Jean Delvare <[email protected]>
Quoted 4 lines
That being said,
DIV_ROUND_CLOSESTwould be better to use than /=, and some clamping on the value would be good to have too, as you can't always fit an unsigned long into an int (there may even be other constraints, I don't know.)
I thought about doing that as separate patch, but since the above doesn't really fix a bug anyway, it does not hurt to put it together into one. I'll do that and resubmit.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors