From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC, PATCH v4 03/16] env: extend interfaces to label variable with context
Date: Fri, 19 Jul 2019 17:25:05 +0900 [thread overview]
Message-ID: <20190719082504.GS21948@linaro.org> (raw)
In-Reply-To: <20190719080919.26134240049@gemini.denx.de>
On Fri, Jul 19, 2019 at 10:09:19AM +0200, Wolfgang Denk wrote:
> Dear Takahiro,
>
> In message <20190717082525.891-4-takahiro.akashi@linaro.org> you wrote:
> > The following interfaces are extended to allow for accepting an additional
> > argument, env_context.
> > env_get() -> env_get_ext()
> > env_set() -> env_get_ext()
>
> Please don't, see previous comments.
NAK again:)
> > Relevant env commands are synced with this change to maintain the semantics
> > of existing U-Boot environment.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> > cmd/nvedit.c | 82 ++++++++++++++++++++++++++++++++++-------------
> > include/exports.h | 3 ++
> > 2 files changed, 62 insertions(+), 23 deletions(-)
> >
> > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > index 49d3b5bdf466..cc80ba712767 100644
> > --- a/cmd/nvedit.c
> > +++ b/cmd/nvedit.c
> > @@ -87,7 +87,7 @@ int get_env_id(void)
> > *
> > * Returns 0 in case of error, or length of printed string
> > */
> > -static int env_print(char *name, int flag)
> > +static int env_print_ext(enum env_context ctx, char *name, int flag)
> > {
> > char *res = NULL;
> > ssize_t len;
> > @@ -96,6 +96,7 @@ static int env_print(char *name, int flag)
> > ENTRY e, *ep;
> >
> > e.key = name;
> > + e.context = ctx;
> > e.data = NULL;
> > hsearch_r(e, FIND, &ep, &env_htab, flag);
> > if (ep == NULL)
> > -#if defined(CONFIG_CMD_NVEDIT_EFI)
> > - if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e')
> > - return do_env_print_efi(cmdtp, flag, --argc, ++argv);
> > -#endif
> > + if (ctx == ENVCTX_UEFI)
> > + return do_env_print_efi(cmdtp, flag, argc, argv);
>
> I don't like this. It doesn't scale. ENVCTX_UEFI is just one
> context among others; it should not need a "if" here to handle.
Unfortunately, this is necessary.
As you know, we want to allow different implementations of UEFI
variables while we want to use "env" commands in the same way.
do_env_print_efi(), for example, is implemented using *UEFI interfaces*,
neither env_*() nor h*_r().
> > +{
> > +#if defined(CONFIG_CMD_NVEDIT_EFI)
> > + if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e')
>
> Please use proper argument handling, options can be combined, so the
> 'e' might not be the second character.
I think there are bunch of code like this in U-Boot. No?
> Also, this should probably changed to support a generic "context"
> specific handling, though "-c context" or such, with U-Boot being
> the default.
Yes, but please note that this option, -e, is already merged
in the upstream.
> This again allows to get rid of all these "if"s
I agree, but only when yet another context be introduced.
Thanks,
-Takahiro Akashi
> > -#if CONFIG_IS_ENABLED(CMD_NVEDIT_EFI)
> > - if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e')
> > - return do_env_set_efi(NULL, flag, --argc, ++argv);
> > -#endif
> > + if (ctx == ENVCTX_UEFI)
> > + return do_env_set_efi(NULL, flag, argc, argv);
>
> Ditto here.
>
> > +#if CONFIG_IS_ENABLED(CMD_NVEDIT_EFI)
> > + if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e')
> > + return _do_env_set(flag, --argc, ++argv, H_INTERACTIVE,
> > + ENVCTX_UEFI);
> > + else
> > +#endif
>
> And here.
>
> > const char * const _argv[3] = { "setenv", argv[1], NULL };
> >
> > - return _do_env_set(0, 2, (char * const *)_argv, H_INTERACTIVE);
> > + return _do_env_set(0, 2, (char * const *)_argv, H_INTERACTIVE,
> > + ENVCTX_UBOOT);
> > } else {
> > const char * const _argv[4] = { "setenv", argv[1], buffer,
> > NULL };
> >
> > - return _do_env_set(0, 3, (char * const *)_argv, H_INTERACTIVE);
> > + return _do_env_set(0, 3, (char * const *)_argv, H_INTERACTIVE,
> > + ENVCTX_UBOOT);
>
> Also here. ENVCTX_UBOOT is not a special context and should not need
> special handling.
>
> 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
> I've got to get something inside me. Some coffee or something. And
> then the world will somehow be better.
> - Terry Pratchett, _Men at Arms_
next prev parent reply other threads:[~2019-07-19 8:25 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 [this message]
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
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=20190719082504.GS21948@linaro.org \
--to=takahiro.akashi@linaro.org \
--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