Re: [PATCH] thunderbolt: fix -Wrestrict warning
From: Mika Westerberg
Date: Tue Sep 28 2021 - 05:32:42 EST
On Mon, Sep 27, 2021 at 03:16:11PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> gcc-11 warns when building with W=1:
>
> 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)
> | ~~~~~~^~~
>
> There is no need for the sprintf() here when a strcat() does
> the same thing.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Applied, thanks!