From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Vasileios Amoiridis <vassilisamir@gmail.com>,
linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] iio: pressure: bmp280-core: Make read-only const array conversion_time_max static
Date: Tue, 23 Jul 2024 18:40:20 +0100 [thread overview]
Message-ID: <f799b77b-ff17-4379-9b95-ab7d8ab521dc@gmail.com> (raw)
In-Reply-To: <abc73704-17c5-40c4-a92c-b69c571a006f@suswa.mountain>
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@gmail.com> 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@gmail.com>
>>
>> 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
>
prev parent reply other threads:[~2024-07-23 17:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 15:17 [PATCH][next] iio: pressure: bmp280-core: Make read-only const array conversion_time_max static Colin Ian King
2024-07-22 20:01 ` Jonathan Cameron
2024-07-23 17:04 ` Dan Carpenter
2024-07-23 17:40 ` Colin King (gmail) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f799b77b-ff17-4379-9b95-ab7d8ab521dc@gmail.com \
--to=colin.i.king@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vassilisamir@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox