From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert P. J. Day Date: Fri, 20 May 2016 07:38:12 -0400 (EDT) Subject: [U-Boot] abbreviating header files with CONFIG_IS_ENABLED()? Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de just want to make sure i'm interpreting the use of this macro correctly in that, if i look in include/image.h, i see (abbreviated snippet): #if IMAGE_ENABLE_FIT # ifdef CONFIG_SPL_BUILD # ifdef CONFIG_SPL_CRC32_SUPPORT # define IMAGE_ENABLE_CRC32 1 # endif # ifdef CONFIG_SPL_MD5_SUPPORT # define IMAGE_ENABLE_MD5 1 # endif # ifdef CONFIG_SPL_SHA1_SUPPORT # define IMAGE_ENABLE_SHA1 1 # endif # ifdef CONFIG_SPL_SHA256_SUPPORT # define IMAGE_ENABLE_SHA256 1 # endif # else # define CONFIG_CRC32 /* FIT images need CRC32 support */ # define CONFIG_MD5 /* and MD5 */ # define CONFIG_SHA1 /* and SHA1 */ # define CONFIG_SHA256 /* and SHA256 */ # define IMAGE_ENABLE_CRC32 1 # define IMAGE_ENABLE_MD5 1 # define IMAGE_ENABLE_SHA1 1 # define IMAGE_ENABLE_SHA256 1 # endif ... #ifndef IMAGE_ENABLE_CRC32 #define IMAGE_ENABLE_CRC32 0 #endif ... snip ... which i *assume* could be written with more brevity as: #if IMAGE_ENABLE_FIT # ifdef CONFIG_SPL_BUILD # define IMAGE_ENABLE_CRC32 CONFIG_IS_ENABLED(SPL_CRC32_SUPPORT) # define IMAGE_ENABLE_MD5 CONFIG_IS_ENABLED(SPL_MD5_SUPPORT) # define IMAGE_ENABLE_SHA1 CONFIG_IS_ENABLED(SPL_SHA1_SUPPORT) # define IMAGE_ENABLE_SHA256 CONFIG_IS_ENABLED(SPL_SHA256_SUPPORT) # else ... snip ... that sort of thing. if i'm reading that correctly, i can do a bit of cleanup this weekend and submit a patch for whatever looks obvious. rday p.s. i mentioned this before in that i have one nitpick with some of the usage of this in that, in the above, *i* would have used: #ifdef CONFIG_FIT rather than: #define IMAGE_ENABLE_FIT CONFIG_IS_ENABLED(FIT) ... #if IMAGE_ENABLE_FIT that is, i would use the CONFIG_* checks for preprocessor work, and reserve the IMAGE_ENABLE_* conditionals exclusively for run-time testing, just for consistency. but that's just me.