From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC, PATCH v4 11/16] env: save a context immediately if 'autosave' variable is changed
Date: Fri, 19 Jul 2019 10:48:50 +0200 [thread overview]
Message-ID: <20190719084850.6E185240049@gemini.denx.de> (raw)
In-Reply-To: <20190717082525.891-12-takahiro.akashi@linaro.org>
Dear Takahiro,
In message <20190717082525.891-12-takahiro.akashi@linaro.org> you wrote:
> By definition, when any variable with VARSTORAGE_NON_VOLATILE_AUTOSAVE
> is modified with env_save_ext(), the associated context should be written
> back to storage immediately.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
> cmd/nvedit.c | 34 ++++++++++++++++++++++++++++++++--
> 1 file changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index cc80ba712767..9896a4141a2a 100644
> --- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -271,8 +271,27 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag,
>
> /* Delete only ? */
> if (argc < 3 || argv[2] == NULL) {
> - int rc = hdelete_r(name, &env_htab, env_flag);
> - return !rc;
> + uint32_t flags;
> +
> + int rc = hdelete_ext(name, &env_htab, ctx, &flags, env_flag);
> + if (!rc) {
> + debug("Failed to delete from hash table\n");
> + return 1;
> + }
> +
> + if (env_flags_parse_varstorage_from_binflags(flags)
> + == env_flags_varstorage_non_volatile_autosave) {
> + int ret;
> +
> + ret = env_save_ext(ctx);
> + if (ret) {
> + printf("## Error saving variables, ret = %d\n",
> + ret);
> + return 1;
> + }
> + }
> +
> + return 0;
I think your logic of using hdelete() here to provide flag
information is not correct. The existing code stores flag
information independent of the actual existence of the variable.
Your code breaks this.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Quantum Mechanics is God's version of "Trust me."
next prev parent reply other threads:[~2019-07-19 8:48 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-17 8:25 [U-Boot] [RFC, PATCH v4 00/16] efi_loader: non-volatile variables support AKASHI Takahiro
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 01/16] hashtable: extend interfaces to handle entries with context AKASHI Takahiro
2019-07-19 6:58 ` Wolfgang Denk
2019-07-19 7:44 ` AKASHI Takahiro
2019-07-19 9:49 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 02/16] env: extend interfaces to import/export U-Boot environment per context AKASHI Takahiro
2019-07-19 7:38 ` Wolfgang Denk
2019-07-19 8:15 ` AKASHI Takahiro
2019-07-19 10:04 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 03/16] env: extend interfaces to label variable with context AKASHI Takahiro
2019-07-19 8:09 ` Wolfgang Denk
2019-07-19 8:25 ` AKASHI Takahiro
2019-07-19 13:06 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 04/16] env: flash: add U-Boot environment context support AKASHI Takahiro
2019-07-19 8:14 ` Wolfgang Denk
2019-07-19 8:30 ` AKASHI Takahiro
2019-07-19 13:11 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 05/16] env: fat: " AKASHI Takahiro
2019-07-19 8:21 ` Wolfgang Denk
2019-07-19 8:35 ` AKASHI Takahiro
2019-07-19 13:14 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 06/16] env: add variable storage attribute support AKASHI Takahiro
2019-07-19 8:35 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 07/16] env: add/expose attribute helper functions for hashtable AKASHI Takahiro
2019-07-19 8:36 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 08/16] hashtable: import/export entries with flags AKASHI Takahiro
2019-07-19 8:38 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 09/16] hashtable: extend hdelete_ext for autosave AKASHI Takahiro
2019-07-19 8:41 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 10/16] env: save non-volatile variables only AKASHI Takahiro
2019-07-19 8:45 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 11/16] env: save a context immediately if 'autosave' variable is changed AKASHI Takahiro
2019-07-19 8:48 ` Wolfgang Denk [this message]
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 12/16] env: extend interfaces to get/set attributes AKASHI Takahiro
2019-07-19 8:50 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 13/16] cmd: env: show variable storage attribute in "env flags" command AKASHI Takahiro
2019-07-19 9:05 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC,PATCH v4 14/16] env: fat: support UEFI context AKASHI Takahiro
2019-07-19 9:08 ` Wolfgang Denk
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 15/16] env, efi_loader: define flags for well-known global UEFI variables AKASHI Takahiro
2019-07-17 8:25 ` [U-Boot] [RFC, PATCH v4 16/16] efi_loader: variable: rework with new extended env interfaces AKASHI Takahiro
2019-07-17 18:53 ` Heinrich Schuchardt
2019-07-18 0:13 ` AKASHI Takahiro
2019-07-17 19:05 ` [U-Boot] [RFC, PATCH v4 00/16] efi_loader: non-volatile variables support Heinrich Schuchardt
2019-07-18 0:04 ` AKASHI Takahiro
2019-07-19 6:50 ` Wolfgang Denk
2019-07-19 7:36 ` AKASHI Takahiro
2019-07-19 9:41 ` 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=20190719084850.6E185240049@gemini.denx.de \
--to=wd@denx.de \
--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