Skip to content

Commit cbe99c5

Browse files
arndbjacek-anaszewski
authored andcommitted
leds: ktd2692: avoid harmless maybe-uninitialized warning
gcc gets confused about the control flow in ktd2692_parse_dt(), causing it to warn about what seems like a potential bug: drivers/leds/leds-ktd2692.c: In function 'ktd2692_probe': drivers/leds/leds-ktd2692.c:244:15: error: '*((void *)&led_cfg+8)' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/leds/leds-ktd2692.c:225:7: error: 'led_cfg.flash_max_microamp' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/leds/leds-ktd2692.c:232:3: error: 'led_cfg.movie_max_microamp' may be used uninitialized in this function [-Werror=maybe-uninitialized] The code is fine, and slightly reworking it in an equivalent way lets gcc figure that out too, which gets rid of the warning. Fixes: 77e7915 ("leds: ktd2692: Add missing of_node_put") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
1 parent 4e552c8 commit cbe99c5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎drivers/leds/leds-ktd2692.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,15 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
270270
return -ENXIO;
271271

272272
led->ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_ASIS);
273-
if (IS_ERR(led->ctrl_gpio)) {
274-
ret = PTR_ERR(led->ctrl_gpio);
273+
ret = PTR_ERR_OR_ZERO(led->ctrl_gpio);
274+
if (ret) {
275275
dev_err(dev, "cannot get ctrl-gpios %d\n", ret);
276276
return ret;
277277
}
278278

279279
led->aux_gpio = devm_gpiod_get(dev, "aux", GPIOD_ASIS);
280-
if (IS_ERR(led->aux_gpio)) {
281-
ret = PTR_ERR(led->aux_gpio);
280+
ret = PTR_ERR_OR_ZERO(led->aux_gpio);
281+
if (ret) {
282282
dev_err(dev, "cannot get aux-gpios %d\n", ret);
283283
return ret;
284284
}

0 commit comments

Comments
 (0)