Skip to contentSkip to conversation

thermal: Fix test of unsigned in thermal_cooling_device_cur_state_store()

PATCH In review Roel Kluin 2 participants 2 messages Dec 15, 2009 – Dec 16, 2009 Thermal

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 thermal: Fix test of unsigned in thermal_cooling_device_cur_state_store()

state is unsigned long so the test did not work.

---
Found using coccinelle: http://coccinelle.lip6.fr/

Is this the best way to fix this?

drivers/thermal/thermal_sys.c +1 -1
index 6f8d8f9..800e0c5 100644
@@ -374,7 +374,7 @@ thermal_cooling_device_cur_state_store(struct device *dev,
 	if (!sscanf(buf, "%ld\n", &state))
 		return -EINVAL;
 
-	if (state < 0)
+	if ((long)state < 0)
 		return -EINVAL;
 
 	result = cdev->ops->set_cur_state(cdev, state);
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Roel Kluin

state is unsigned long so the test did not work.

Quoted 18 lines

---
Found using coccinelle: http://coccinelle.lip6.fr/

Is this the best way to fix this?

drivers/thermal/thermal_sys.c +1 -1
index 6f8d8f9..800e0c5 100644
@@ -374,7 +374,7 @@ thermal_cooling_device_cur_state_store(struct device *dev,
 	if (!sscanf(buf, "%ld\n", &state))
 		return -EINVAL;
 
-	if (state < 0)
+	if ((long)state < 0)
 		return -EINVAL;
 
 	result = cdev->ops->set_cur_state(cdev, state);