Re: [PATCH] led-class-flash: fix -Wrestrict warning

From: Pavel Machek
Date: Mon Sep 27 2021 - 06:31:41 EST


Hi!

> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> 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: signature.asc
Description: PGP signature