Re: [PATCH (2) 27/34] shm_open.3: Use sizeof consistently

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

Hello Alex,

On 9/4/20 4:55 PM, Alejandro Colomar wrote:
>>From d3f439e697c9a384cad55e84a584493088eb4291 Mon Sep 17 00:00:00 2001
> From: Alejandro Colomar <colomar.6.4.3@gmail.com>
> Date: Thu, 3 Sep 2020 21:55:48 +0200
> Subject: [PATCH 27/34] shm_open.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. Patch applied.

Cheers,

Michael

> ---
> man3/shm_open.3 | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/man3/shm_open.3 b/man3/shm_open.3
> index bba4eb826..24cc6a403 100644
> --- a/man3/shm_open.3
> +++ b/man3/shm_open.3
> @@ -382,7 +382,7 @@ main(int argc, char *argv[])
>
> /* Map the object into the caller\(aqs address space */
>
> - struct shmbuf *shmp = mmap(NULL, sizeof(struct shmbuf),
> + struct shmbuf *shmp = mmap(NULL, sizeof(*shmp),
> PROT_READ | PROT_WRITE,
> MAP_SHARED, fd, 0);
> if (shmp == MAP_FAILED)
> @@ -471,7 +471,7 @@ main(int argc, char *argv[])
> if (fd == \-1)
> errExit("shm_open");
>
> - struct shmbuf *shmp = mmap(NULL, sizeof(struct shmbuf),
> + struct shmbuf *shmp = mmap(NULL, sizeof(*shmp),
> PROT_READ | PROT_WRITE,
> MAP_SHARED, fd, 0);
> if (shmp == MAP_FAILED)
>

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