From: Gerlando Falauto <gerlando.falauto@keymile.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] env: set individual variables to default
Date: Fri, 23 Sep 2011 09:31:50 +0200 [thread overview]
Message-ID: <4E7C35E6.5030808@keymile.com> (raw)
In-Reply-To: <20110922195134.543F21407979@gemini.denx.de>
On 09/22/2011 09:51 PM, Wolfgang Denk wrote:
> > "env default -f" will always keep resetting the whole environment
> > to default.
>
> I don't think this is a good idea.
>
> The "-f" should be used to allow resetting write-protected variables
> like serial# or ethaddr.
I see what you mean, it's the same rationale behind
env set [-f] var
right? Point is, has "-f" ever been implemented in "env set"?
=> env set -f ethaddr
=> printenv
-f=ethaddr
...
> With no variable names given, it will therefore always be needed
> (assuming you have such protected variables in your environment).
OK, so "env default -f" should reset all variables, including protected
ones. Should there also be some way to reset *ALL BUT* protected variables?
Like "env default" or "env default all" as suggested in the wiki page?
Or such operation doesn't make any sense indeed (i.e., all variables
means ALL OF THEM)?
>> +#ifdef CONFIG_CMD_DEFAULTENV_VARS
>> +/*
>> + * import individual variables from an external environment
>> + * (e.g. default environment).
>> + * Most of this code comes straight from himport_r().
>
> Indeed. This is way too much code copied. Please factor this out
> into a separate function to avoid such duplication (which is always a
> maintenance nightmare).
While we're on this subject, do you think it would make any sense to
*import* individual variables?
If yes, what could the syntax be?
env import [flags] addr [size] <vars...>
would make the optional argument "size" ambiguous (unless we take for
granted that variable names cannot start with a digit...).
> ...
>> + /* deal with "name" and "name=" entries (delete var) */
>> + if (*dp == '\0' || *(dp + 1) == '\0' ||
>> + *dp == sep || *(dp + 1) == sep) {
>> + if (*dp == '=')
>> + *dp++ = '\0';
>> + *dp++ = '\0'; /* terminate name */
>
> Here the comment (about the "delete var") is even wrong.
What do you mean? It's what himport_r() does (but please see also my
final comments).
>
>> + /*
>> + * size check needed for text without '\0' termination
>> + * (e.g. default environment)
>> + */
>
> What makes you think the default environment was NOT '\0' terminated?
Sorry, my mistake.
Anyway, the whole thing was based on the assumption that it could make
some sense at some point to import individual variables from a
downloaded file. If that's the case, code should be factored together
with himport_r() as you suggested. If not, most of this code (the part
checking for comments, tabs, '\0'...) can be safely deleted (and I don't
think factoring the rest would be necessary).
Thank you,
Gerlando Falauto
next prev parent reply other threads:[~2011-09-23 7:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 15:06 [U-Boot] [PATCH 0/2] implement set individual variables to default Gerlando Falauto
2011-09-22 15:06 ` [U-Boot] [PATCH 1/2] env: " Gerlando Falauto
2011-09-22 19:51 ` Wolfgang Denk
2011-09-23 7:31 ` Gerlando Falauto [this message]
2011-09-23 9:55 ` Wolfgang Denk
2011-09-28 9:20 ` Gerlando Falauto
2011-09-28 21:08 ` Wolfgang Denk
2011-09-29 6:13 ` Gerlando Falauto
2011-09-22 15:06 ` [U-Boot] [PATCH 2/2] km/common: enable "env default" for all keymile boards Gerlando Falauto
2011-10-21 22:37 ` 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=4E7C35E6.5030808@keymile.com \
--to=gerlando.falauto@keymile.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