Re: [PATCH (2) 17/34] getgrouplist.3: Use sizeof consistently

Michael Kerrisk (man-pages)
2020-09-04T15:25:57Z

Hello Alex,

On 9/4/20 4:34 PM, Alejandro Colomar wrote:
>>From 7ca60fc88b831818c1f1722919af220a646761ab Mon Sep 17 00:00:00 2001
> From: Alejandro Colomar <colomar.6.4.3@gmail.com>
> Date: Thu, 3 Sep 2020 21:47:15 +0200
> Subject: [PATCH 17/34] getgrouplist.3: 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. Applied.

Cheers,

Michael

> ---
> man3/getgrouplist.3 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/man3/getgrouplist.3 b/man3/getgrouplist.3
> index 372f2613f..ff8d89e3f 100644
> --- a/man3/getgrouplist.3
> +++ b/man3/getgrouplist.3
> @@ -164,7 +164,7 @@ main(int argc, char *argv[])
>
> ngroups = atoi(argv[2]);
>
> - groups = malloc(sizeof(gid_t) * ngroups);
> + groups = malloc(sizeof(*groups) * ngroups);
> if (groups == NULL) {
> perror("malloc");
> exit(EXIT_FAILURE);
>

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