[U-Boot] abbreviating header files with CONFIG_IS_ENABLED()?
Robert P. J. Day
rpjday at crashcourse.ca
Fri May 20 13:38:12 CEST 2016
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.
More information about the U-Boot
mailing list