* [PATCH] led-class-flash: fix -Wrestrict warning
@ 2021-09-27 10:15 Arnd Bergmann
2021-09-27 10:22 ` Greg Kroah-Hartman
2021-09-27 10:31 ` Pavel Machek
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2021-09-27 10:15 UTC (permalink / raw)
To: Pavel Machek, Andreas Noever, Michael Jamet, Mika Westerberg,
Yehezkel Bernat
Cc: Arnd Bergmann, Greg Kroah-Hartman, Isaac Hazan, Lee Jones,
Rikard Falkeborn, linux-leds, linux-kernel, linux-usb
From: Arnd Bergmann <arnd@arndb.de>
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)
| ~~~~~~^~~
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:277: drivers/leds/led-class-flash.o] Error 1
make[5]: Target '__build' not remade because of errors.
make[4]: *** [scripts/Makefile.build:540: drivers/leds] Error 2
drivers/thunderbolt/xdomain.c: In function 'modalias_show':
drivers/thunderbolt/xdomain.c:733:16: error: 'sprintf' argument 3 overlaps destination object 'buf' [-Werror=restrict]
733 | return sprintf(buf, "%s\n", buf);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/thunderbolt/xdomain.c:727:36: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
727 | char *buf)
| ~~~~~~^~~
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/leds/led-class-flash.c | 2 +-
drivers/thunderbolt/xdomain.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
index 185e17055317..6fe9d700dfef 100644
--- a/drivers/leds/led-class-flash.c
+++ b/drivers/leds/led-class-flash.c
@@ -207,7 +207,7 @@ static ssize_t flash_fault_show(struct device *dev,
mask <<= 1;
}
- return sprintf(buf, "%s\n", buf);
+ return strlen(strcat(buf, "\n"));
}
static DEVICE_ATTR_RO(flash_fault);
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index d66ea4d616fd..eff32499610f 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -730,7 +730,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
/* Full buffer size except new line and null termination */
get_modalias(svc, buf, PAGE_SIZE - 2);
- return sprintf(buf, "%s\n", buf);
+ return strlen(strcat(buf, "\n"));
}
static DEVICE_ATTR_RO(modalias);
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] led-class-flash: fix -Wrestrict warning
2021-09-27 10:15 [PATCH] led-class-flash: fix -Wrestrict warning Arnd Bergmann
@ 2021-09-27 10:22 ` Greg Kroah-Hartman
2021-09-27 13:12 ` Arnd Bergmann
2021-09-27 10:31 ` Pavel Machek
1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-09-27 10:22 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Pavel Machek, Andreas Noever, Michael Jamet, Mika Westerberg,
Yehezkel Bernat, Arnd Bergmann, Isaac Hazan, Lee Jones,
Rikard Falkeborn, linux-leds, linux-kernel, linux-usb
On Mon, Sep 27, 2021 at 12:15:59PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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)
> | ~~~~~~^~~
> cc1: all warnings being treated as errors
> make[5]: *** [scripts/Makefile.build:277: drivers/leds/led-class-flash.o] Error 1
> make[5]: Target '__build' not remade because of errors.
> make[4]: *** [scripts/Makefile.build:540: drivers/leds] Error 2
> drivers/thunderbolt/xdomain.c: In function 'modalias_show':
> drivers/thunderbolt/xdomain.c:733:16: error: 'sprintf' argument 3 overlaps destination object 'buf' [-Werror=restrict]
> 733 | return sprintf(buf, "%s\n", buf);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/thunderbolt/xdomain.c:727:36: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
> 727 | char *buf)
> | ~~~~~~^~~
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/leds/led-class-flash.c | 2 +-
> drivers/thunderbolt/xdomain.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
> index 185e17055317..6fe9d700dfef 100644
> --- a/drivers/leds/led-class-flash.c
> +++ b/drivers/leds/led-class-flash.c
> @@ -207,7 +207,7 @@ static ssize_t flash_fault_show(struct device *dev,
> mask <<= 1;
> }
>
> - return sprintf(buf, "%s\n", buf);
> + return strlen(strcat(buf, "\n"));
> }
> static DEVICE_ATTR_RO(flash_fault);
>
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index d66ea4d616fd..eff32499610f 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -730,7 +730,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
>
> /* Full buffer size except new line and null termination */
> get_modalias(svc, buf, PAGE_SIZE - 2);
> - return sprintf(buf, "%s\n", buf);
> + return strlen(strcat(buf, "\n"));
> }
> static DEVICE_ATTR_RO(modalias);
>
> --
> 2.29.2
>
You also have a thunderbolt change in here as well :(
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] led-class-flash: fix -Wrestrict warning
2021-09-27 10:15 [PATCH] led-class-flash: fix -Wrestrict warning Arnd Bergmann
2021-09-27 10:22 ` Greg Kroah-Hartman
@ 2021-09-27 10:31 ` Pavel Machek
1 sibling, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2021-09-27 10:31 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andreas Noever, Michael Jamet, Mika Westerberg, Yehezkel Bernat,
Arnd Bergmann, Greg Kroah-Hartman, Isaac Hazan, Lee Jones,
Rikard Falkeborn, linux-leds, linux-kernel, linux-usb
[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]
Hi!
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/leds/led-class-flash.c | 2 +-
> drivers/thunderbolt/xdomain.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
> index 185e17055317..6fe9d700dfef 100644
> --- a/drivers/leds/led-class-flash.c
> +++ b/drivers/leds/led-class-flash.c
> @@ -207,7 +207,7 @@ static ssize_t flash_fault_show(struct device *dev,
> mask <<= 1;
> }
>
> - return sprintf(buf, "%s\n", buf);
> + return strlen(strcat(buf, "\n"));
> }
> static DEVICE_ATTR_RO(flash_fault);
>
That's not just a warning. .. the code is crazy. I'll take it if you
split it from the thunderbolt change.
Best regards,
Pavel
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index d66ea4d616fd..eff32499610f 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -730,7 +730,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
>
> /* Full buffer size except new line and null termination */
> get_modalias(svc, buf, PAGE_SIZE - 2);
> - return sprintf(buf, "%s\n", buf);
> + return strlen(strcat(buf, "\n"));
> }
> static DEVICE_ATTR_RO(modalias);
>
> --
> 2.29.2
--
http://www.livejournal.com/~pavelmachek
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] led-class-flash: fix -Wrestrict warning
2021-09-27 10:22 ` Greg Kroah-Hartman
@ 2021-09-27 13:12 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2021-09-27 13:12 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Pavel Machek, Andreas Noever, Michael Jamet, Mika Westerberg,
Yehezkel Bernat, Arnd Bergmann, Isaac Hazan, Lee Jones,
Rikard Falkeborn, linux-leds, Linux Kernel Mailing List,
USB list
On Mon, Sep 27, 2021 at 12:22 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Mon, Sep 27, 2021 at 12:15:59PM +0200, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > 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)
> > | ~~~~~~^~~
> > cc1: all warnings being treated as errors
> > make[5]: *** [scripts/Makefile.build:277: drivers/leds/led-class-flash.o] Error 1
> > make[5]: Target '__build' not remade because of errors.
> > make[4]: *** [scripts/Makefile.build:540: drivers/leds] Error 2
> > drivers/thunderbolt/xdomain.c: In function 'modalias_show':
> > drivers/thunderbolt/xdomain.c:733:16: error: 'sprintf' argument 3 overlaps destination object 'buf' [-Werror=restrict]
> > 733 | return sprintf(buf, "%s\n", buf);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/thunderbolt/xdomain.c:727:36: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
> > 727 | char *buf)
> >
>
> You also have a thunderbolt change in here as well :(
Oh, and I forgot to explain the change, clearly this one was meant to go
into the 'rework, then send' pile of my fixes.
v2 coming in a bit.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-27 13:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 10:15 [PATCH] led-class-flash: fix -Wrestrict warning Arnd Bergmann
2021-09-27 10:22 ` Greg Kroah-Hartman
2021-09-27 13:12 ` Arnd Bergmann
2021-09-27 10:31 ` Pavel Machek
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).