From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: "Keller, Jacob E" <jacob.e.keller@intel.com>,
Sangbeom Kim <sbkim73@samsung.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-samsung-soc@vger.kernel.org"
<linux-samsung-soc@vger.kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Subject: Re: [RFT] regulator: s2mps11: Simplify expression used in BUILD_BUG_ON for some of preprocessors
Date: Thu, 18 Feb 2016 09:25:37 +0900 [thread overview]
Message-ID: <56C50F81.8030202@samsung.com> (raw)
In-Reply-To: <02874ECE860811409154E81DA85FBB58579A1F19@ORSMSX115.amr.corp.intel.com>
On 18.02.2016 05:37, Keller, Jacob E wrote:
> Hi,
>
>> -----Original Message-----
>> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
>> owner@vger.kernel.org] On Behalf Of Krzysztof Kozlowski
>> Sent: Wednesday, February 17, 2016 12:11 AM
>> To: Sangbeom Kim <sbkim73@samsung.com>; Krzysztof Kozlowski
>> <k.kozlowski@samsung.com>; Liam Girdwood <lgirdwood@gmail.com>;
>> Mark Brown <broonie@kernel.org>; linux-kernel@vger.kernel.org; linux-
>> samsung-soc@vger.kernel.org
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Subject: [RFT] regulator: s2mps11: Simplify expression used in
>> BUILD_BUG_ON for some of preprocessors
>>
>> Apparently some preprocessors have problems with interpreting
>> BUILD_BUG_ON such as:
>> var = ARRAY_SIZE(s2mps15_regulators);
>> BUILD_BUG_ON(S2MPS_REGULATOR_MAX < var);
>> so let make it more obvious for them.
>>
>
> Doesn't have much to do with the preprocessor, but rather exactly how the compiler optimizes the variable. Some kernel configurations also impact this, and it heavily depends on whether the compiler actually optimizes away the variable. BUILD_BUG_ON may work a lot of the time, depending heavily on the compiler.
>
> BUILD_BUG_ON only works for constant expressions, so it is safer to put the value in directly, because using a variable will only work if the compiler optimizes the use of a variable away entirely. In this case it is somewhat surprising that it doesn't, but would depend on what compiler version and what kernel build rules you were using. For example allmodconfig ends up selecting everything yes if it's not a module for kernel build options and results in some BUILD_BUG_ON failures because of that)
Right, thanks for detailed explanation. Arnd confirmed that patch fixes
encountered issue (gcc 4.9 with UBSAN).
I'll change the commit message and re-submit.
Best regards,
Krzysztof
next prev parent reply other threads:[~2016-02-18 0:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 8:10 [RFT] regulator: s2mps11: Simplify expression used in BUILD_BUG_ON for some of preprocessors Krzysztof Kozlowski
2016-02-17 20:37 ` Keller, Jacob E
2016-02-18 0:25 ` Krzysztof Kozlowski [this message]
2016-02-18 20:12 ` Applied "regulator: s2mps11: Simplify expression used in BUILD_BUG_ON" to the regulator tree Mark Brown
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=56C50F81.8030202@samsung.com \
--to=k.kozlowski@samsung.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=sbkim73@samsung.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