From: Pavel Machek <pavel@ucw.cz>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] led-class-flash: fix -Wrestrict warning
Date: Mon, 27 Sep 2021 16:09:48 +0200 [thread overview]
Message-ID: <20210927140948.GA5809@duo.ucw.cz> (raw)
In-Reply-To: <20210927131557.1587062-1-arnd@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
prev parent reply other threads:[~2021-09-27 14:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-27 13:15 [PATCH] [v2] led-class-flash: fix -Wrestrict warning Arnd Bergmann
2021-09-27 14:09 ` Pavel Machek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210927140948.GA5809@duo.ucw.cz \
--to=pavel@ucw.cz \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).