Skip to contentSkip to conversation

sparc: vio: Replace snprintf with strscpy in vio_create_one

PATCH In review Thorsten Blum 2 participants 2 messages Jan 31 – Feb 6 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: vio: Replace snprintf with strscpy in vio_create_one

Replace snprintf("%s", ...) with the faster and more direct strscpy().

---
 arch/sparc/kernel/vio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sparc/kernel/vio.c +2 -2
index 1a1a9d6b8f2e..8c7dd72ef334 100644
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/irq.h>
 #include <linux/export.h>
 #include <linux/init.h>
@@ -378,8 +379,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
 	 * the parent doesn't require the MD node info.
 	 */
 	if (node_name != NULL) {
-		(void) snprintf(vdev->node_name, VIO_MAX_NAME_LEN, "%s",
-				node_name);
+		strscpy(vdev->node_name, node_name);
 
 		err = mdesc_get_node_info(hp, mp, node_name,
 					  &vdev->md_node_info);
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Thorsten Blum

Replace snprintf("%s", ...) with the faster and more direct strscpy().

---
 arch/sparc/kernel/vio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sparc/kernel/vio.c +1 -0
index 1a1a9d6b8f2e..8c7dd72ef334 100644
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/irq.h>
 #include <linux/export.h>
 #include <linux/init.h>

arch/sparc/kernel/vio.c static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, · line 385

Quoted 9 lines
arch/sparc/kernel/vio.c +1 -2
@@ -378,8 +379,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
 	 * the parent doesn't require the MD node info.
 	 */
 	if (node_name != NULL) {
-		(void) snprintf(vdev->node_name, VIO_MAX_NAME_LEN, "%s",
-				node_name);
+		strscpy(vdev->node_name, node_name);
 
 		err = mdesc_get_node_info(hp, mp, node_name,
 					  &vdev->md_node_info);

Picking this up to my for-next.

Thanks,
Andreas