Skip to content

Commit 0a0624a

Browse files
arndbwesteri
authored andcommitted
thunderbolt: Fix -Wrestrict warning
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 <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent 641cdbe commit 0a0624a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/thunderbolt/xdomain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
730730

731731
/* Full buffer size except new line and null termination */
732732
get_modalias(svc, buf, PAGE_SIZE - 2);
733-
return sprintf(buf, "%s\n", buf);
733+
return strlen(strcat(buf, "\n"));
734734
}
735735
static DEVICE_ATTR_RO(modalias);
736736

0 commit comments

Comments
 (0)