public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: Replace snprintf with strscpy in check_partition
@ 2026-01-27 22:47 Thorsten Blum
  2026-01-28 12:28 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-01-27 22:47 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Thorsten Blum, linux-block, linux-kernel

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

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 block/partitions/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/partitions/core.c b/block/partitions/core.c
index 815ed33caa1b..079057ab535a 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -7,6 +7,7 @@
 #include <linux/fs.h>
 #include <linux/major.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/ctype.h>
 #include <linux/vmalloc.h>
 #include <linux/raid/detect.h>
@@ -130,7 +131,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
 	state->pp_buf[0] = '\0';
 
 	state->disk = hd;
-	snprintf(state->name, BDEVNAME_SIZE, "%s", hd->disk_name);
+	strscpy(state->name, hd->disk_name);
 	snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name);
 	if (isdigit(state->name[strlen(state->name)-1]))
 		sprintf(state->name, "p");
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: Replace snprintf with strscpy in check_partition
  2026-01-27 22:47 [PATCH] block: Replace snprintf with strscpy in check_partition Thorsten Blum
@ 2026-01-28 12:28 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2026-01-28 12:28 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: linux-block, linux-kernel


On Tue, 27 Jan 2026 23:47:01 +0100, Thorsten Blum wrote:
> Replace snprintf("%s", ...) with the faster and more direct strscpy().
> 
> 

Applied, thanks!

[1/1] block: Replace snprintf with strscpy in check_partition
      commit: f46ebb910989a1db244f95bd1f937907591aa2ee

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-28 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 22:47 [PATCH] block: Replace snprintf with strscpy in check_partition Thorsten Blum
2026-01-28 12:28 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox