Re: [PATCH (2) 13/34] cmsg.3: Use sizeof consistently

Michael Kerrisk (man-pages)
2020-09-04T15:18:46Z

Hi Alex,On 9/4/20 3:50 PM, Alejandro Colomar wrote:
>>From ba70b1e8addad4ef9f2a490d2069b112d09ba9f1 Mon Sep 17 00:00:00 2001
> From: Alejandro Colomar <colomar.6.4.3@gmail.com>
> Date: Thu, 3 Sep 2020 21:44:41 +0200
> Subject: [PATCH 13/34] cmsg.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

Patch applied. Thanks.

Cheers,

Michael

> Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
> ---
> man3/cmsg.3 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/man3/cmsg.3 b/man3/cmsg.3
> index 99ee950f9..3d6288901 100644
> --- a/man3/cmsg.3
> +++ b/man3/cmsg.3
> @@ -203,7 +203,7 @@ for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
> cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
> if (cmsg\->cmsg_level == IPPROTO_IP
> && cmsg\->cmsg_type == IP_TTL) {
> - memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(int));
> + memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl));
> break;
> }
> }
>

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