linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative
@ 2023-05-31  5:35 Jiapeng Chong
  2023-06-08 17:13 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2023-05-31  5:35 UTC (permalink / raw)
  To: pavel; +Cc: lee, linux-leds, linux-kernel, Jiapeng Chong, Abaci Robot

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.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5344
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/leds/flash/leds-qcom-flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c
index c8d41a3caf38..b089ca1a1901 100644
--- a/drivers/leds/flash/leds-qcom-flash.c
+++ b/drivers/leds/flash/leds-qcom-flash.c
@@ -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) {
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative
  2023-05-31  5:35 [PATCH] leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative Jiapeng Chong
@ 2023-06-08 17:13 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2023-06-08 17:13 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: pavel, linux-leds, linux-kernel, Abaci Robot

On Wed, 31 May 2023, Jiapeng Chong wrote:

> 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.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5344
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  drivers/leds/flash/leds-qcom-flash.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-08 17:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31  5:35 [PATCH] leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative Jiapeng Chong
2023-06-08 17:13 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).