Re: [PATCH v3] blkparse: Fix a potential coredump issue
[email protected] Thu, 20 Mar 2025 09:49:54 +0800
| Newsgroups | org.kernel.vger.linux-btrace |
|---|---|
| Message-ID | <[email protected]> |
From: Kou Wenqi <[email protected]> On 3/19/25 7:10 AM, [email protected] 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