Re: [PATCH (2) 30/34] aio.7: Use sizeof consistently

Michael Kerrisk (man-pages)
2020-09-04T18:10:29Z

Hi Alex,

On 9/4/20 5:04 PM, Alejandro Colomar wrote:
>>From 33a09662331be9666c2f69dc60a792d9deee761e Mon Sep 17 00:00:00 2001
> From: Alejandro Colomar <colomar.6.4.3@gmail.com>
> Date: Thu, 3 Sep 2020 21:57:28 +0200
> Subject: [PATCH 30/34] aio.7: Use sizeof consistently
>
> Use ``sizeof`` consistently through all the examples in the following
> way:
>
> - Use the name of the variable instead of its type as argument for
> ``sizeof``.
>
> Rationale:
> https://www.kernel.org/doc/html/v5.8/process/coding-style.html#allocating-memory
>
> Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>

Thanks. Patch applied.

Cheers,

Michael

> ---
> man7/aio.7 | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/man7/aio.7 b/man7/aio.7
> index dd05dce83..d3ab3f422 100644
> --- a/man7/aio.7
> +++ b/man7/aio.7
> @@ -311,11 +311,11 @@ main(int argc, char *argv[])
>
> /* Allocate our arrays */
>
> - ioList = calloc(numReqs, sizeof(struct ioRequest));
> + ioList = calloc(numReqs, sizeof(*ioList));
> if (ioList == NULL)
> errExit("calloc");
>
> - aiocbList = calloc(numReqs, sizeof(struct aiocb));
> + aiocbList = calloc(numReqs, sizeof(*aiocbList));
> if (aiocbList == NULL)
> errExit("calloc");
>

--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/