[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a59be19-252e-0285-6d9f-5f9a9f0388b5@gmail.com>
Date: Tue, 29 Sep 2020 15:57:22 +0200
From: Alejandro Colomar <colomar.6.4.3@...il.com>
To: mtk.manpages@...il.com
Cc: Stefan Puiu <stefan.puiu@...il.com>,
lnx-man <linux-man@...r.kernel.org>,
lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 12/24] getgrent_r.3: Use sizeof() to get buffer size
(instead of hardcoding macro name)
On 2020-09-29 15:38, Michael Kerrisk (man-pages) wrote:
>> 2.- Use sizeof() everywhere, and the macro for the initializer.
>>
>> pros:
>> - It is valid as long as the buffer is an array.
>> cons:
>> - If the code gets into a function, and the buffer is then a pointer,
>> it will definitively produce a silent bug.
>
> Sigh! I just did exactly the last point in a test program I've been writing...
>
> M
>
Hmmm, maybe you would like to comment on this LKML thread I started
yesterday:
https://lore.kernel.org/lkml/71c25cb0-9fa2-4e97-c93c-44eadfd781fb@gmail.com
Concretely, point 4 is about this.
I'd push 'array_bytes()' to all "libc"s I can, so that it's then common
enough to use it everywhere, even in the man.
I'd also recommend reading this StackOverflow answer I wrote last year:
https://stackoverflow.com/a/57537491/6872717
Cheers,
Alex
Powered by blists - more mailing lists