Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1567003 > unrolled thread

[PATCH] leds: ktd2692: avoid harmless maybe-uninitialized warning

Started byArnd Bergmann <arnd@arndb.de>
First post2017-01-25 23:30 +0100
Last post2017-01-26 21:30 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] leds: ktd2692: avoid harmless maybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2017-01-25 23:30 +0100
    Re: [PATCH] leds: ktd2692: avoid harmless maybe-uninitialized warning Pavel Machek <pavel@ucw.cz> - 2017-01-25 23:40 +0100
    Re: [PATCH] leds: ktd2692: avoid harmless maybe-uninitialized warning Jacek Anaszewski <jacek.anaszewski@gmail.com> - 2017-01-26 21:30 +0100

#1567003 — [PATCH] leds: ktd2692: avoid harmless maybe-uninitialized warning

FromArnd Bergmann <arnd@arndb.de>
Date2017-01-25 23:30 +0100
Subject[PATCH] leds: ktd2692: avoid harmless maybe-uninitialized warning
Message-ID<t3EeK-7H4-15@gated-at.bofh.it>
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: 77e7915b15bb ("leds: ktd2692: Add missing of_node_put")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/leds/leds-ktd2692.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c
index bf23ba191ad0..45296aaca9da 100644
--- a/drivers/leds/leds-ktd2692.c
+++ b/drivers/leds/leds-ktd2692.c
@@ -270,15 +270,15 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
 		return -ENXIO;
 
 	led->ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_ASIS);
-	if (IS_ERR(led->ctrl_gpio)) {
-		ret = PTR_ERR(led->ctrl_gpio);
+	ret = PTR_ERR_OR_ZERO(led->ctrl_gpio);
+	if (ret) {
 		dev_err(dev, "cannot get ctrl-gpios %d\n", ret);
 		return ret;
 	}
 
 	led->aux_gpio = devm_gpiod_get(dev, "aux", GPIOD_ASIS);
-	if (IS_ERR(led->aux_gpio)) {
-		ret = PTR_ERR(led->aux_gpio);
+	ret = PTR_ERR_OR_ZERO(led->aux_gpio);
+	if (ret) {
 		dev_err(dev, "cannot get aux-gpios %d\n", ret);
 		return ret;
 	}
-- 
2.9.0

[toc] | [next] | [standalone]


#1567014

FromPavel Machek <pavel@ucw.cz>
Date2017-01-25 23:40 +0100
Message-ID<t3Eoq-7Ku-21@gated-at.bofh.it>
In reply to#1567003

[Multipart message — attachments visible in raw view] — view raw

On Wed 2017-01-25 23:22:36, Arnd Bergmann wrote:
> 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: 77e7915b15bb ("leds: ktd2692: Add missing of_node_put")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[toc] | [prev] | [next] | [standalone]


#1567690

FromJacek Anaszewski <jacek.anaszewski@gmail.com>
Date2017-01-26 21:30 +0100
Message-ID<t3YQa-3pI-17@gated-at.bofh.it>
In reply to#1567003
Hi Arnd,

Thanks for the patch, applied.

Best regards,
Jacek Anaszewski

On 01/25/2017 11:22 PM, Arnd Bergmann wrote:
> 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: 77e7915b15bb ("leds: ktd2692: Add missing of_node_put")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/leds/leds-ktd2692.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c
> index bf23ba191ad0..45296aaca9da 100644
> --- a/drivers/leds/leds-ktd2692.c
> +++ b/drivers/leds/leds-ktd2692.c
> @@ -270,15 +270,15 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
>  		return -ENXIO;
>  
>  	led->ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_ASIS);
> -	if (IS_ERR(led->ctrl_gpio)) {
> -		ret = PTR_ERR(led->ctrl_gpio);
> +	ret = PTR_ERR_OR_ZERO(led->ctrl_gpio);
> +	if (ret) {
>  		dev_err(dev, "cannot get ctrl-gpios %d\n", ret);
>  		return ret;
>  	}
>  
>  	led->aux_gpio = devm_gpiod_get(dev, "aux", GPIOD_ASIS);
> -	if (IS_ERR(led->aux_gpio)) {
> -		ret = PTR_ERR(led->aux_gpio);
> +	ret = PTR_ERR_OR_ZERO(led->aux_gpio);
> +	if (ret) {
>  		dev_err(dev, "cannot get aux-gpios %d\n", ret);
>  		return ret;
>  	}
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web