U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 2/2] env/sf.c: honour CONFIG_SPL_SAVEENV
Date: Fri, 8 May 2020 18:59:09 -0400	[thread overview]
Message-ID: <20200508225909.GU12564@bill-the-cat> (raw)
In-Reply-To: <20200326230200.12617-3-rasmus.villemoes@prevas.dk>

On Fri, Mar 27, 2020 at 12:02:00AM +0100, Rasmus Villemoes wrote:

> Deciding whether to compile the env_sf_save() function based solely on
> CONFIG_SPL_BUILD is wrong: For U-Boot proper, it leads to a build
> warning in case CONFIG_CMD_SAVEENV=n (because the initialization of
> the .save member is guarded by CONFIG_CMD_SAVEENV, while the
> env_sf_save() function is built if !CONFIG_SPL_BUILD - and even
> without the CONFIG_CMD_SAVEENV guard, the env_save_ptr() macro would
> just expand to NULL, with no reference to env_sf_save visible to the
> compiler). And for SPL, when one selects CONFIG_SPL_SAVEENV, one
> obviously expects to actually be able to save the environment.
> 
> The compiler warning can be fixed by using a "<something> ?
> env_sf_save : NULL" construction instead of a macro that just eats its
> argument and expands to NULL. That way, if <something> is false,
> env_sf_save gets eliminated as dead code, but the compiler still sees
> the reference to it.
> 
> For <something>, we can use CONFIG_IS_ENABLED(SAVEENV), which is true
> precisely:
> 
> - For U-Boot proper, when CONFIG_CMD_SAVEENV is set (because
>   CONFIG_SAVEENV is a hidden config symbol that gets set if and only
>   if CONFIG_CMD_SAVEENV is set).
> - For SPL, when CONFIG_SPL_SAVEENV is set.
> 
> As a bonus, this also removes quite a few preprocessor conditionals.
> 
> This has been run-time tested on a mpc8309-derived board to verify
> that saving the environment does indeed work in SPL with these patches
> applied.
> 
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200508/966d2d32/attachment.sig>

  reply	other threads:[~2020-05-08 22:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19  9:47 [PATCH 0/5] CMD_SAVEENV ifdef cleanup Rasmus Villemoes
2020-02-19  9:47 ` [PATCH 1/5] env: add SAVEENV as an alias of the CMD_SAVEENV symbol Rasmus Villemoes
2020-04-24 17:08   ` Tom Rini
2020-02-19  9:47 ` [PATCH 2/5] env_internal.h: add alternative ENV_SAVE_PTR macro Rasmus Villemoes
2020-04-24 17:08   ` Tom Rini
2020-02-19  9:47 ` [PATCH 3/5] env/fat.c: remove private CMD_SAVEENV logic Rasmus Villemoes
2020-02-19 13:27   ` Wolfgang Denk
2020-02-20 14:22     ` Rasmus Villemoes
2020-02-21 16:14       ` Wolfgang Denk
2020-02-21 16:19         ` Tom Rini
2020-02-24 14:49           ` Rasmus Villemoes
2020-04-24 17:08   ` Tom Rini
2020-02-19  9:47 ` [PATCH 4/5] env/ext4.c: remove CONFIG_CMD_SAVEENV ifdef Rasmus Villemoes
2020-04-24 17:08   ` Tom Rini
2020-02-19  9:47 ` [PATCH 5/5] env/sf.c: drop private CMD_SAVEENV logic Rasmus Villemoes
2020-04-24 17:08   ` Tom Rini
2020-02-19 13:25 ` [PATCH 0/5] CMD_SAVEENV ifdef cleanup Wolfgang Denk
2020-02-19 13:43   ` Rasmus Villemoes
2020-03-24 19:42 ` Rasmus Villemoes
2020-03-25  7:50   ` Wolfgang Denk
2020-03-25 11:37     ` Rasmus Villemoes
2020-03-26 14:31       ` Wolfgang Denk
2020-03-26 16:04         ` Rasmus Villemoes
2020-03-26 23:01 ` [PATCH v2 0/2] allow CONFIG_SPL_SAVEENV to work with ENV_IS_IN_SPI_FLASH Rasmus Villemoes
2020-03-26 23:01   ` [PATCH v2 1/2] env: add SAVEENV as an alias of the CMD_SAVEENV symbol Rasmus Villemoes
2020-05-08 22:59     ` Tom Rini
2020-03-26 23:02   ` [PATCH v2 2/2] env/sf.c: honour CONFIG_SPL_SAVEENV Rasmus Villemoes
2020-05-08 22:59     ` Tom Rini [this message]
2020-05-09 18:56       ` Rasmus Villemoes
2020-05-09 20:54         ` Tom Rini
2020-05-11  6:49           ` Rasmus Villemoes
2020-05-11 16:06             ` Tom Rini
2020-03-27 16:31   ` [PATCH v2 0/2] allow CONFIG_SPL_SAVEENV to work with ENV_IS_IN_SPI_FLASH Wolfgang Denk
2020-03-27 20:06     ` Rasmus Villemoes
2020-03-30 10:40       ` Wolfgang Denk

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=20200508225909.GU12564@bill-the-cat \
    --to=trini@konsulko.com \
    --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