missing parentheses?
PATCH 1/1 missing parentheses?
Add missing parentheses.
Signed-off-by Roel Kluin <[email protected]>
---
The original code looks odd, but I am not sure whether my patch is correct. So please review.
drivers/hwmon/lm63.c +2 -2
@@ -219,9 +219,9 @@ static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy, char *buf) {struct lm63_data *data =lm63_update_device (dev); -return sprintf (buf,"%d\n" , data->pwm1_value >=2 * data->pwm1_freq ? +return sprintf (buf,"%d\n" , data->pwm1_value >=2 * (data->pwm1_freq ?255 : (data->pwm1_value *255 + data->pwm1_freq) / - (2 * data->pwm1_freq)); + (2 * data->pwm1_freq))); } static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Roel,
Quoted 6 lines · Roel Kluin
Add missing parentheses.
Signed-off-by Roel Kluin <[email protected]>---
The original code looks odd, but I am not sure whether my patch is correct. So please review.
The original code looks good to me and your patch doesn't.
Quoted 6 lines
drivers/hwmon/lm63.c +0
-0
drivers/hwmon/lm63.c static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy, · line 224
Quoted 8 lines
drivers/hwmon/lm63.c +2
-2@@ -219,9 +219,9 @@ static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy, char *buf) {struct lm63_data *data =lm63_update_device (dev); -return sprintf (buf,"%d\n" , data->pwm1_value >=2 * data->pwm1_freq ? +return sprintf (buf,"%d\n" , data->pwm1_value >=2 * (data->pwm1_freq ?255 : (data->pwm1_value *255 + data->pwm1_freq) / - (2 * data->pwm1_freq)); + (2 * data->pwm1_freq)));
The correct parentheses would be:
return sprintf(buf, "%d\n", (data->pwm1_value >= 2 * data->pwm1_freq) ? 255 : ((data->pwm1_value * 255 + data->pwm1_freq) / (2 * data->pwm1_freq)));
Which I think is equivalent to what we already have, since the ?:
operator has low precedence.
Quoted 3 lines
drivers/hwmon/lm63.c +0
-0} static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors