[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260127224704.440877-1-thorsten.blum@linux.dev>
Date: Tue, 27 Jan 2026 23:47:01 +0100
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Jens Axboe <axboe@...nel.dk>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] block: Replace snprintf with strscpy in check_partition
Replace snprintf("%s", ...) with the faster and more direct strscpy().
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.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@...ux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
Powered by blists - more mailing lists