Skip to contentSkip to conversation

leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative

PATCH Applied Jiapeng Chong 2 participants 2 messages May 31, 2023 – Jun 8, 2023 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative

The variable 'count' is defined as unsigned type, so the following if statement is invalid, we can modify the type of count to int.

if (count <= 0) {
	dev_err(dev, "No led-sources specified\n");
	return -ENODEV;
}

./drivers/leds/flash/leds-qcom-flash.c:546:5-10: WARNING: Unsigned expression compared with zero: count <= 0.

---
 drivers/leds/flash/leds-qcom-flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/flash/leds-qcom-flash.c +2 -2
index c8d41a3caf38..b089ca1a1901 100644
@@ -538,9 +538,9 @@ static int qcom_flash_register_led_device(struct device *dev,
 	struct led_init_data init_data;
 	struct led_classdev_flash *flash = &led->flash;
 	struct led_flash_setting *brightness, *timeout;
-	u32 count, current_ua, timeout_us;
+	u32 current_ua, timeout_us;
 	u32 channels[4];
-	int i, rc;
+	int i, rc, count;
 
 	count = fwnode_property_count_u32(node, "led-sources");
 	if (count <= 0) {
Signature · 1 line
2.20.1.7.g153144c
maintainer Applied
#1 lore raw
Quoted 7 lines · Jiapeng Chong

The variable 'count' is defined as unsigned type, so the following if statement is invalid, we can modify the type of count to int.

if (count <= 0) {
	dev_err(dev, "No led-sources specified\n");
	return -ENODEV;
}
Quoted 8 lines

./drivers/leds/flash/leds-qcom-flash.c:546:5-10: WARNING: Unsigned expression compared with zero: count <= 0.

---
 drivers/leds/flash/leds-qcom-flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]