Skip to content
Commit 811b5440 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Pavel Machek
Browse files

led-class-flash: fix -Wrestrict warning



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.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
parent 6880fa6c
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment