]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: Replace snprintf with strscpy in check_partition
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 27 Jan 2026 22:47:01 +0000 (23:47 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 28 Jan 2026 12:28:13 +0000 (05:28 -0700)
Replace snprintf("%s", ...) with the faster and more direct strscpy().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/partitions/core.c

index 815ed33caa1b86d22dccf2bf1593f5c85aad7597..079057ab535a675ace81f889ddf33eee3c9a6af6 100644 (file)
@@ -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");