]> www.infradead.org Git - nvme.git/commitdiff
null_blk: Use strscpy() instead of strscpy_pad() in null_add_dev()
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 10 Apr 2025 15:47:23 +0000 (17:47 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 11 Apr 2025 13:10:46 +0000 (07:10 -0600)
blk_mq_alloc_disk() already zero-initializes the destination buffer,
making strscpy() sufficient for safely copying the disk's name. The
additional NUL-padding performed by strscpy_pad() is unnecessary.

If the destination buffer has a fixed length, strscpy() automatically
determines its size using sizeof() when the argument is omitted. This
makes the explicit size argument unnecessary.

The source string is also NUL-terminated and meets the __must_be_cstr()
requirement of strscpy().

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20250410154727.883207-1-thorsten.blum@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/null_blk/main.c

index 3bb9cee0a9b55afc39b5512e2842ed9695260a23..aa163ae9b2aa5c3140b6e110d210cc8fe8950cea 100644 (file)
@@ -2031,7 +2031,7 @@ static int null_add_dev(struct nullb_device *dev)
        nullb->disk->minors = 1;
        nullb->disk->fops = &null_ops;
        nullb->disk->private_data = nullb;
-       strscpy_pad(nullb->disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
+       strscpy(nullb->disk->disk_name, nullb->disk_name);
 
        if (nullb->dev->zoned) {
                rv = null_register_zoned_dev(nullb);