From: Jens Axboe <axboe@kernel.dk>
To: 303146950@qq.com
Cc: kouwenqi@kylinos.cn, linux-btrace@vger.kernel.org
Subject: Re: [PATCH v3] blkparse: Fix a potential coredump issue
Date: Thu, 20 Mar 2025 05:07:18 -0600 [thread overview]
Message-ID: <329d38f9-3853-4228-a2d7-44c2078dd859@kernel.dk> (raw)
In-Reply-To: <tencent_D844947035F128017DDC0AA43ECF482BA808@qq.com>
On 3/19/25 7:49 PM, 303146950@qq.com wrote:
> 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!
You are right, I was apparently smoking crack there for a second!
--
Jens Axboe
next prev parent reply other threads:[~2025-03-20 11:07 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
2025-03-20 11:07 ` Jens Axboe [this message]
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=329d38f9-3853-4228-a2d7-44c2078dd859@kernel.dk \
--to=axboe@kernel.dk \
--cc=303146950@qq.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox