Tom reported the following covervity scan error: *** CID 542488: Control flow issues (NO_EFFECT) /drivers/led/led-uclass.c: 277 in led_get_function_name() 271 return uc_plat->label; 272 273 /* Now try to detect function label name */ 274 func = dev_read_string(dev, "function"); 275 cp = dev_read_u32(dev, "color", &color); 276 // prevent coverity scan error CID 541279: (TAINTED_SCALAR) >>> CID 542488: Control flow issues (NO_EFFECT) >>> This less-than-zero comparison of an unsigned value is never true. "color < 0U". 277 if (color < LED_COLOR_ID_WHITE || color >= LED_COLOR_ID_MAX) 278 cp = -EINVAL; 279
see: https://lists.denx.de/pipermail/u-boot/2025-February/581567.html Fix it. Signed-off-by: Heiko Schocher <[email protected]> --- Azure build: https://dev.azure.com/hs0298/hs/_build/results?buildId=171&view=results drivers/led/led-uclass.c | 2 +- dts/upstream/include/dt-bindings/leds/common.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 22f61d12d38..e2edcc43f30 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -274,7 +274,7 @@ static const char *led_get_function_name(struct udevice *dev) func = dev_read_string(dev, "function"); cp = dev_read_u32(dev, "color", &color); // prevent coverity scan error CID 541279: (TAINTED_SCALAR) - if (color < LED_COLOR_ID_WHITE || color >= LED_COLOR_ID_MAX) + if (color >= LED_COLOR_ID_MAX) cp = -EINVAL; if (cp == 0 || func) { diff --git a/dts/upstream/include/dt-bindings/leds/common.h b/dts/upstream/include/dt-bindings/leds/common.h index 4f017bea012..9e5ac5196e2 100644 --- a/dts/upstream/include/dt-bindings/leds/common.h +++ b/dts/upstream/include/dt-bindings/leds/common.h @@ -21,7 +21,10 @@ #define LEDS_BOOST_ADAPTIVE 1 #define LEDS_BOOST_FIXED 2 -/* Standard LED colors */ +/* + * Standard LED colors, LED_COLOR_ID_WHITE must be the + * first one and start with value 0 + */ #define LED_COLOR_ID_WHITE 0 #define LED_COLOR_ID_RED 1 #define LED_COLOR_ID_GREEN 2 -- 2.20.1

