[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <075de7dd-f3a2-4806-9e4c-9dfd38d12f69@linux.dev>
Date: Thu, 10 Apr 2025 18:11:42 +0200
From: Zhu Yanjun <yanjun.zhu@...ux.dev>
To: Thorsten Blum <thorsten.blum@...ux.dev>, Jens Axboe <axboe@...nel.dk>,
Damien Le Moal <dlemoal@...nel.org>, Chaitanya Kulkarni <kch@...dia.com>,
Johannes Thumshirn <johannes.thumshirn@....com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@....com>,
Zheng Qixing <zhengqixing@...wei.com>, Yu Kuai <yukuai3@...wei.com>
Cc: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] null_blk: Use strscpy() instead of strscpy_pad() in
null_add_dev()
On 10.04.25 17:47, Thorsten Blum wrote:
> 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
Looks good to me. The destination buffer is indeed has a fixed length,
it is DISK_NAME_LEN.
Reviewed-by: Zhu Yanjun <yanjun.zhu@...ux.dev>
Zhu Yanjun
> 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@...ux.dev>
> ---
> drivers/block/null_blk/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index 3bb9cee0a9b5..aa163ae9b2aa 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -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);
--
Best Regards,
Yanjun.Zhu
Powered by blists - more mailing lists