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

From: Dan Carpenter
Date: Tue Jul 23 2024 - 13:06:10 EST


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).

regards,
dan carpenter