Skip to contentSkip to conversation

rpmsg: Use strscpy() instead of strscpy_pad()

PATCH RESEND Applied Thorsten Blum 3 participants 5 messages Apr 29, 2025 – Jun 17, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 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.

---
 drivers/rpmsg/qcom_glink_native.c | 2 +-
 drivers/rpmsg/qcom_smd.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/rpmsg/qcom_glink_native.c +1 -1
index a2f9d85c7156..820a6ca5b1d7 100644
@@ -1663,7 +1663,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
 		}
 
 		rpdev->ept = &channel->ept;
-		strscpy_pad(rpdev->id.name, name, RPMSG_NAME_SIZE);
+		strscpy(rpdev->id.name, name);
 		rpdev->src = RPMSG_ADDR_ANY;
 		rpdev->dst = RPMSG_ADDR_ANY;
 		rpdev->ops = &glink_device_ops;
drivers/rpmsg/qcom_smd.c +1 -1
index 40d386809d6b..3c86c5553de6 100644
@@ -1089,7 +1089,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel)
 
 	/* Assign public information to the rpmsg_device */
 	rpdev = &qsdev->rpdev;
-	strscpy_pad(rpdev->id.name, channel->name, RPMSG_NAME_SIZE);
+	strscpy(rpdev->id.name, channel->name);
 	rpdev->src = RPMSG_ADDR_ANY;
 	rpdev->dst = RPMSG_ADDR_ANY;
 
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 10 lines · Thorsten Blum

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.

Quoted 7 lines

No functional changes intended.

---
 drivers/rpmsg/qcom_glink_native.c | 2 +-
 drivers/rpmsg/qcom_smd.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

I will let Bjorn take care of this one.

Thanks,
Mathieu

Quoted 30 lines
drivers/rpmsg/qcom_glink_native.c +1 -1
index a2f9d85c7156..820a6ca5b1d7 100644
@@ -1663,7 +1663,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
                }
 
                rpdev->ept = &channel->ept;
-               strscpy_pad(rpdev->id.name, name, RPMSG_NAME_SIZE);
+               strscpy(rpdev->id.name, name);
                rpdev->src = RPMSG_ADDR_ANY;
                rpdev->dst = RPMSG_ADDR_ANY;
                rpdev->ops = &glink_device_ops;
drivers/rpmsg/qcom_smd.c +1 -2
index 40d386809d6b..3c86c5553de6 100644
@@ -1089,7 +1089,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel)
 
        /* Assign public information to the rpmsg_device */
        rpdev = &qsdev->rpdev;
-       strscpy_pad(rpdev->id.name, channel->name, RPMSG_NAME_SIZE);
+       strscpy(rpdev->id.name, channel->name);
        rpdev->src = RPMSG_ADDR_ANY;
        rpdev->dst = RPMSG_ADDR_ANY;
 
--

2.49.0

#2 lore raw

Hi Mathieu,

Quoted 13 lines · Mathieu Poirier
Quoted 12 lines · Thorsten Blum

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.

Quoted 8 lines
Quoted 5 lines

---
drivers/rpmsg/qcom_glink_native.c | 2 +-
drivers/rpmsg/qcom_smd.c | 2 +-

2 files changed, 2 insertions(+), 2 deletions(-)

I will let Bjorn take care of this one.

This one didn't make it into the last merge window, did it?

Could you or Bjorn take care of it or should I resend it?

Thanks,
Thorsten

maintainer
#3 lore raw
Quoted 23 lines · Thorsten Blum

Hi Mathieu,

Quoted 20 lines · Mathieu Poirier
Quoted 17 lines · Thorsten Blum

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.

---
drivers/rpmsg/qcom_glink_native.c | 2 +-
drivers/rpmsg/qcom_smd.c | 2 +-

2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 1 line

I will let Bjorn take care of this one.

This one didn't make it into the last merge window, did it?

Could you or Bjorn take care of it or should I resend it?

I looked at it, but needed to convince myself that there were no side effects, and then missed pulling it. It's still in the queue, so I'm taking another look, no need to resend it.

Thanks,
Bjorn

Quoted 3 lines

Thanks,
Thorsten

maintainer Applied
#4 lore raw
In reply to Thorsten Blum
Quoted 10 lines · Thorsten Blum

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.

[...]

Applied, thanks!

[1/1] rpmsg: Use strscpy() instead of strscpy_pad()

      commit: 28b825975b8feb352e996d77f679e790b4d84913

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>