From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Thorsten Blum <thorsten.blum@linux.dev>,
Jens Axboe <axboe@kernel.dk>, Damien Le Moal <dlemoal@kernel.org>,
Chaitanya Kulkarni <kch@nvidia.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Zheng Qixing <zhengqixing@huawei.com>,
Yu Kuai <yukuai3@huawei.com>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] null_blk: Use strscpy() instead of strscpy_pad() in null_add_dev()
Date: Thu, 10 Apr 2025 18:11:42 +0200 [thread overview]
Message-ID: <075de7dd-f3a2-4806-9e4c-9dfd38d12f69@linux.dev> (raw)
In-Reply-To: <20250410154727.883207-1-thorsten.blum@linux.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@linux.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@linux.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
next prev parent reply other threads:[~2025-04-10 16:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 15:47 [PATCH] null_blk: Use strscpy() instead of strscpy_pad() in null_add_dev() Thorsten Blum
2025-04-10 16:11 ` Zhu Yanjun [this message]
2025-04-11 0:01 ` Damien Le Moal
2025-04-11 13:10 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=075de7dd-f3a2-4806-9e4c-9dfd38d12f69@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=johannes.thumshirn@wdc.com \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=thorsten.blum@linux.dev \
--cc=yukuai3@huawei.com \
--cc=zhengqixing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox