Re: [PATCH][next] iio: pressure: bmp280-core: Make read-only const array conversion_time_max static

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/07/2024 18:04, Dan Carpenter wrote:
On Mon, Jul 22, 2024 at 09:01:11PM +0100, Jonathan Cameron wrote:
On Mon, 22 Jul 2024 16:17:38 +0100
Colin Ian King <colin.i.king@xxxxxxxxx> wrote:

Don't populate the read-only array conversion_time_max on the stack at
run time, instead make it static.

Signed-off-by: Colin Ian King <colin.i.king@xxxxxxxxx>

I'm almost 100% the compiler can hoist this off the stack if it feels like
it but sure, it might not and adding the static keyword probably obliges
it to do so.

You would wish the compiler would do this correctly, but it doesn't.
(Or it didn't the last time anyone checked).

From what I understand, a const variable that's not static is either put in register or on the stack since it's implicitly an auto variable, hence it's populated with the initialization data at run time. Making it static will populate it at compile time. Assuming anything else is problematic.

Colin


regards,
dan carpenter






[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux