Skip to content

Commit c8a8df4

Browse files
tobluxandersson
authored andcommitted
rpmsg: Use strscpy() instead of strscpy_pad()
kzalloc() already zero-initializes the destination buffer, making strscpy() sufficient for safely copying the name. The additional NUL- padding performed by strscpy_pad() is unnecessary. The size parameter is optional, and strscpy() automatically determines the size of the destination buffer using sizeof() when the argument is omitted. RPMSG_NAME_SIZE is equal to sizeof(rpdev->id.name) and can be removed - remove it. No functional changes intended. Signed-off-by: Thorsten Blum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 214ae22 commit c8a8df4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/rpmsg/qcom_glink_native.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
16631663
}
16641664

16651665
rpdev->ept = &channel->ept;
1666-
strscpy_pad(rpdev->id.name, name, RPMSG_NAME_SIZE);
1666+
strscpy(rpdev->id.name, name);
16671667
rpdev->src = RPMSG_ADDR_ANY;
16681668
rpdev->dst = RPMSG_ADDR_ANY;
16691669
rpdev->ops = &glink_device_ops;

drivers/rpmsg/qcom_smd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel)
10891089

10901090
/* Assign public information to the rpmsg_device */
10911091
rpdev = &qsdev->rpdev;
1092-
strscpy_pad(rpdev->id.name, channel->name, RPMSG_NAME_SIZE);
1092+
strscpy(rpdev->id.name, channel->name);
10931093
rpdev->src = RPMSG_ADDR_ANY;
10941094
rpdev->dst = RPMSG_ADDR_ANY;
10951095

0 commit comments

Comments
 (0)