From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] env: Group environment variables
Date: Thu, 05 Nov 2009 20:57:31 +0100 [thread overview]
Message-ID: <20091105195731.5BA593F6EC@gemini.denx.de> (raw)
In-Reply-To: <1257352452-11748-1-git-send-email-jschmoller@xes-inc.com>
Dear John,
In message <1257352452-11748-1-git-send-email-jschmoller@xes-inc.com> you wrote:
> This patch groups environment variables using a non-invasive protocol.
> Grouping is achieved by setting a "grouping" variable to a string of
> variables, and setting the master grouping variable, "env_groups" to
> the list of these grouping variables.
>
> For instance,
> setenv net ipaddr netmask gatewayip serverip
> setenv boot bootcmd bootdelay bootargs
> setenv env_groups net boot
>
> would print 4 variables grouped under net, 3 variables grouped under
> boot, and the rest of the variables grouped under "other". If env_groups
> is not defined, print behaves normally.
First of all: thanks for the patch.
> I'm interesetd in seeing peoples opinions of this implementation of grouping
> environment variables. My major concerns about this implementation are
I have to admit that I did not actually test the code yet. I just read
it a bit...
> 1) Using parse_line() requires placing several potentially large char array
> (CONFIG_SYS_CBSIZE in size) on the stack. Parse_line() does seem to be the
> right tool for the job, though.
I am not sure about this. Keep in mind that parse_line() processes a
maximum of CONFIG_SYS_MAXARGS arguments only, which on most boards is
only 16 (and on some boards even less).
> 2) Trying to figure out which enviroment variables have already been printed
> in groups is less than elegant. Currently, it's a brute-force approach of
> looking through every entry until a variable is found in a group or not.
> Suggestions for cleaner algorithms here would be appreciated.
The repeated scanning and comparing doesn't make much sense to me.
Probably it makes more sense to use a more suitable data structure
here. How about performing a linear scan of the environment only
once and convert it into a more easily processable data structure, say
a hash table or a binary tree or whatever, and then operate on this.
Here you can easily add additional flags like a pointer which group the
variable belongs to (if any).
Also, this would make it easier for example to print a sorted list.
Eventually we should _always_ do that, i. e. replace the standard
copy operation as done in env_relocate*() by a function that not only
copies the environment, but converts it into a new internal
representation. This might be beneficial to accelerate access to
variables, too.
=> print only a list of groups
> If env_groups is defined, none of the grouping variables will be printed.
> This seemed to clutter up the printenv output.
I don't think this is a wise decision. Having "magic" variables which
cannot be seen an idea I dislike. I think the standard "printenv"
(without args) should print the grouping variables as first block.
Also, it would be nice if "prontenv" now would allow to print a group,
i. e. in your example something as "printenv net pci" should be
supported.
> Grouping environment variables will almost certainly lead to a reqirement for
> bumping up CONFIG_SYS_MAXARGS.
...which raises the question why there is such a static limit in the
first place. Yes, it was trivial to implement, but maybe this can be
improved? Artificial limits on line lengths and numbers of arguments
are a nice thing - to remove :-)
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
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
"The question of whether a computer can think is no more interesting
than the question of whether a submarine can swim"
- Edsgar W. Dijkstra
next prev parent reply other threads:[~2009-11-05 19:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-04 16:34 [U-Boot] [RFC] env: Group environment variables John Schmoller
2009-11-04 17:55 ` Mike Frysinger
2009-11-04 18:17 ` John Schmoller
2009-11-04 20:36 ` Mike Frysinger
2009-11-04 20:37 ` John Schmoller
2009-11-04 22:28 ` Wolfgang Denk
2009-11-05 19:57 ` Wolfgang Denk [this message]
2009-11-05 20:25 ` John Schmoller
2009-11-05 22:37 ` Wolfgang Denk
2009-11-05 22:42 ` John Schmoller
2009-11-16 23:15 ` 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=20091105195731.5BA593F6EC@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