[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210927140948.GA5809@duo.ucw.cz>
Date: Mon, 27 Sep 2021 16:09:48 +0200
From: Pavel Machek <pavel@....cz>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, linux-leds@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] [v2] led-class-flash: fix -Wrestrict warning
Hi!
> gcc-11 warns when building with W=1:
>
> drivers/leds/led-class-flash.c: In function 'flash_fault_show':
> drivers/leds/led-class-flash.c:210:16: error: 'sprintf' argument 3 overlaps destination object 'buf' [-Werror=restrict]
> 210 | return sprintf(buf, "%s\n", buf);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/leds/led-class-flash.c:187:54: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
> 187 | struct device_attribute *attr, char *buf)
> | ~~~~~~^~~
>
> There is no need for the sprintf() here when a strcat() does
> the same thing without invoking undefined behavior.
Thanks, applied.
Pavel
--
http://www.livejournal.com/~pavelmachek
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists