From: 303146950@qq.com
To: axboe@kernel.dk
Cc: 303146950@qq.com, kouwenqi@kylinos.cn, linux-btrace@vger.kernel.org
Subject: Re: [PATCH v3] blkparse: Fix a potential coredump issue
Date: Thu, 20 Mar 2025 09:49:54 +0800 [thread overview]
Message-ID: <tencent_D844947035F128017DDC0AA43ECF482BA808@qq.com> (raw)
In-Reply-To: <1962cea3-e413-441c-b98a-ded4a6a4fe68@kernel.dk>
From: Kou Wenqi <kouwenqi@kylinos.cn>
On 3/19/25 7:10 AM, axboe@kernel.dk wrote:
> Nit picking, but the idiomatic way would be to make it calloc(size, 1)
> not the other way around. The first one is the size, the 2nd one is the
> number of them.
Thank you for reviewing the patch!
I wanted to double-check the calloc usage
to ensure alignment with the project's conventions.
The man page defines calloc as:
void *calloc(size_t nmemb, size_t size);
where nmemb is the number of elements, and size is the size of each element.
In the submitted code,
split = calloc(1, sizeof(*iot)) follows this order: nmemb=1 and size=sizeof(...).
I also reviewed existing code in blktrace and saw consistent usage like calloc(1, size),
which matches the man page’s parameter order.
Could you clarify if there’s a specific reason or project-specific idiom
for reversing the parameters (e.g., calloc(size, 1) instead)?
I’m happy to adjust it if there’s a stylistic preference or guideline I’ve overlooked.
Thanks again for your guidance!
--
Kou Wenqi
next prev parent reply other threads:[~2025-03-20 1:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 13:02 [PATCH v3] blkparse: Fix a potential coredump issue 303146950
2025-03-19 13:10 ` Jens Axboe
2025-03-20 1:49 ` 303146950 [this message]
2025-03-20 11:07 ` Jens Axboe
2025-03-20 11:07 ` 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=tencent_D844947035F128017DDC0AA43ECF482BA808@qq.com \
--to=303146950@qq.com \
--cc=axboe@kernel.dk \
--cc=kouwenqi@kylinos.cn \
--cc=linux-btrace@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.