From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161972AbcBRAZq (ORCPT ); Wed, 17 Feb 2016 19:25:46 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:27279 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161199AbcBRAZo (ORCPT ); Wed, 17 Feb 2016 19:25:44 -0500 X-AuditID: cbfec7f5-f79b16d000005389-12-56c50f8590f9 Subject: Re: [RFT] regulator: s2mps11: Simplify expression used in BUILD_BUG_ON for some of preprocessors To: "Keller, Jacob E" , Sangbeom Kim , Liam Girdwood , Mark Brown , "linux-kernel@vger.kernel.org" , "linux-samsung-soc@vger.kernel.org" References: <1455696653-27023-1-git-send-email-k.kozlowski@samsung.com> <02874ECE860811409154E81DA85FBB58579A1F19@ORSMSX115.amr.corp.intel.com> Cc: Arnd Bergmann From: Krzysztof Kozlowski Message-id: <56C50F81.8030202@samsung.com> Date: Thu, 18 Feb 2016 09:25:37 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: <02874ECE860811409154E81DA85FBB58579A1F19@ORSMSX115.amr.corp.intel.com> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsVy+t/xK7qt/EfDDP41Mln8nXSM3WLqwyds FieOLWSxeP3C0OLblQ4mi8u75rBZzDi/j8ni4oovTA4cHr9/TWL02DnrLrvH4j0vmTw2repk 8+jbsorR4/MmuQC2KC6blNSczLLUIn27BK6MX7OmMhV84Ktoa2plbGDcxdPFyMkhIWAicWr1 UmYIW0ziwr31bF2MXBxCAksZJWYsms8C4TxllNjV9psdpEpYIFvi2ZQ7jCAJEYFVTBJXD2xj hKiayCix79V5JpAqZgFFia6tX8DmsgkYS2xevoQNxOYV0JJY8O47mM0ioCqx49BfsBpRgQiJ w51d7BA1ghI/Jt9jAbE5BcIkHnxZytrFyAE0U0/i/kUtiPHyEpvXvGWewCgwC0nHLISqWUiq FjAyr2IUTS1NLihOSs810itOzC0uzUvXS87P3cQICfyvOxiXHrM6xCjAwajEw7vhxZEwIdbE suLK3EOMEhzMSiK8vnxHw4R4UxIrq1KL8uOLSnNSiw8xSnOwKInzztz1PkRIID2xJDU7NbUg tQgmy8TBKdXAWN1+8WTexcCJz+YvUpnZ/Mxmvv7/L98ONJ78MPnHpZjlk2S2qAaaiz7ZmnPt ce9B/dLELfLr9I+uZgy878zVqXzu2O6NjRGBc/xUfupN/3k4LKru028R6QcpaqvvTd7yRVsl PX/l009qq9rWctcUlu6eZ7om5JVVbWLoRQbR8xNEI0/ZLdD29ldiKc5INNRiLipOBABbLumz eAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ; Krzysztof Kozlowski >> ; Liam Girdwood ; >> Mark Brown ; linux-kernel@vger.kernel.org; linux- >> samsung-soc@vger.kernel.org >> Cc: Arnd Bergmann >> 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