U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Robert P. J. Day <rpjday@crashcourse.ca>
To: u-boot@lists.denx.de
Subject: [U-Boot] abbreviating header files with CONFIG_IS_ENABLED()?
Date: Fri, 20 May 2016 07:38:12 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.2.20.1605200724500.6796@localhost.localdomain> (raw)


  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.

                 reply	other threads:[~2016-05-20 11:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=alpine.LFD.2.20.1605200724500.6796@localhost.localdomain \
    --to=rpjday@crashcourse.ca \
    --cc=u-boot@lists.denx.de \
    /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