Message ID | 1479292229-17256-5-git-send-email-bernhard.nortmann@web.de |
---|---|
State | RFC |
Delegated to: | Joe Hershberger |
Headers | show |
Hi Bernhard, On 16 November 2016 at 03:29, Bernhard Nortmann <bernhard.nortmann@web.de> wrote: > "transient" (='t') is like "any", but requests that a variable > should not be exported (ENV_FLAGS_VARACCESS_PREVENT_EXPORT). > > "system" (='S') is meant for 'internal' variables that > aren't supposed to be changed by the user. It corresponds > to "transient" plus "read-only". > > Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de> > > --- > > Changes in v2: > - Fixed outdated "env_flags_varaccess_lock" to the correct > "env_flags_varaccess_system" > > common/env_flags.c | 11 +++++++++-- > include/env_flags.h | 2 ++ > 2 files changed, 11 insertions(+), 2 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org> Please see below. > > diff --git a/common/env_flags.c b/common/env_flags.c > index f39d952..2c30c7f 100644 > --- a/common/env_flags.c > +++ b/common/env_flags.c > @@ -28,7 +28,7 @@ > #endif > > static const char env_flags_vartype_rep[] = "sdxb" ENV_FLAGS_NET_VARTYPE_REPS; > -static const char env_flags_varaccess_rep[] = "aroc"; > +static const char env_flags_varaccess_rep[] = "aroctS"; > static const int env_flags_varaccess_mask[] = { > 0, > ENV_FLAGS_VARACCESS_PREVENT_DELETE | > @@ -37,7 +37,12 @@ static const int env_flags_varaccess_mask[] = { > ENV_FLAGS_VARACCESS_PREVENT_DELETE | > ENV_FLAGS_VARACCESS_PREVENT_OVERWR, > ENV_FLAGS_VARACCESS_PREVENT_DELETE | > - ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR}; > + ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR, > + ENV_FLAGS_VARACCESS_PREVENT_EXPORT, > + ENV_FLAGS_VARACCESS_PREVENT_DELETE | Can these flags be shortened? This is not Java :-) Also it might be helpful to use the [index] = value syntax so you can see which value it corresponds to? > + ENV_FLAGS_VARACCESS_PREVENT_CREATE | > + ENV_FLAGS_VARACCESS_PREVENT_OVERWR | > + ENV_FLAGS_VARACCESS_PREVENT_EXPORT}; > > #ifdef CONFIG_CMD_ENV_FLAGS > static const char * const env_flags_vartype_names[] = { > @@ -55,6 +60,8 @@ static const char * const env_flags_varaccess_names[] = { > "read-only", > "write-once", > "change-default", > + "transient", /* do not export/save */ > + "system", /* = "transient" plus "read-only" */ > }; > > /* > diff --git a/include/env_flags.h b/include/env_flags.h > index 7e2362a..9d66706 100644 > --- a/include/env_flags.h > +++ b/include/env_flags.h > @@ -25,6 +25,8 @@ enum env_flags_varaccess { > env_flags_varaccess_readonly, > env_flags_varaccess_writeonce, > env_flags_varaccess_changedefault, > + env_flags_varaccess_transient, > + env_flags_varaccess_system, > env_flags_varaccess_end > }; > > -- > 2.7.3 > Regards, Simon
On Wed, Nov 16, 2016 at 4:29 AM, Bernhard Nortmann <bernhard.nortmann@web.de> wrote: > "transient" (='t') is like "any", but requests that a variable > should not be exported (ENV_FLAGS_VARACCESS_PREVENT_EXPORT). > > "system" (='S') is meant for 'internal' variables that The flags are positional, so 's' is not in use. It seems it would be cleaner to use a lower-case 's'. > aren't supposed to be changed by the user. It corresponds > to "transient" plus "read-only". > > Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de> > > --- > > Changes in v2: > - Fixed outdated "env_flags_varaccess_lock" to the correct > "env_flags_varaccess_system" > > common/env_flags.c | 11 +++++++++-- > include/env_flags.h | 2 ++ > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/common/env_flags.c b/common/env_flags.c > index f39d952..2c30c7f 100644 > --- a/common/env_flags.c > +++ b/common/env_flags.c > @@ -28,7 +28,7 @@ > #endif > > static const char env_flags_vartype_rep[] = "sdxb" ENV_FLAGS_NET_VARTYPE_REPS; > -static const char env_flags_varaccess_rep[] = "aroc"; > +static const char env_flags_varaccess_rep[] = "aroctS"; > static const int env_flags_varaccess_mask[] = { > 0, > ENV_FLAGS_VARACCESS_PREVENT_DELETE | > @@ -37,7 +37,12 @@ static const int env_flags_varaccess_mask[] = { > ENV_FLAGS_VARACCESS_PREVENT_DELETE | > ENV_FLAGS_VARACCESS_PREVENT_OVERWR, > ENV_FLAGS_VARACCESS_PREVENT_DELETE | > - ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR}; > + ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR, > + ENV_FLAGS_VARACCESS_PREVENT_EXPORT, > + ENV_FLAGS_VARACCESS_PREVENT_DELETE | > + ENV_FLAGS_VARACCESS_PREVENT_CREATE | > + ENV_FLAGS_VARACCESS_PREVENT_OVERWR | > + ENV_FLAGS_VARACCESS_PREVENT_EXPORT}; > > #ifdef CONFIG_CMD_ENV_FLAGS > static const char * const env_flags_vartype_names[] = { > @@ -55,6 +60,8 @@ static const char * const env_flags_varaccess_names[] = { > "read-only", > "write-once", > "change-default", > + "transient", /* do not export/save */ > + "system", /* = "transient" plus "read-only" */ I'm not sure why you are adding "transient" or "volatile" to the varaccess. It is an orthogonal property of a variable. This is obvious from the fact that you need to add yet another to compose varaccess with varlifetime (or something). I worked on something similar years ago, but never posted an RFC. http://lists.denx.de/pipermail/u-boot/2010-June/073027.html > }; > > /* > diff --git a/include/env_flags.h b/include/env_flags.h > index 7e2362a..9d66706 100644 > --- a/include/env_flags.h > +++ b/include/env_flags.h > @@ -25,6 +25,8 @@ enum env_flags_varaccess { > env_flags_varaccess_readonly, > env_flags_varaccess_writeonce, > env_flags_varaccess_changedefault, > + env_flags_varaccess_transient, > + env_flags_varaccess_system, > env_flags_varaccess_end > }; > > -- > 2.7.3 > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot
Hi Joe! Thanks for chiming in, especially seeing that you have previously worked on something very similar. Am 27.11.2016 um 19:53 schrieb Joe Hershberger: > On Wed, Nov 16, 2016 at 4:29 AM, Bernhard Nortmann > <bernhard.nortmann@web.de> wrote: >> "transient" (='t') is like "any", but requests that a variable >> should not be exported (ENV_FLAGS_VARACCESS_PREVENT_EXPORT). >> >> "system" (='S') is meant for 'internal' variables that > The flags are positional, so 's' is not in use. It seems it would be > cleaner to use a lower-case 's'. You're probably right. I think back then I deliberately picked 'S' to avoid potential confusion (e.g. users specifying "s" when they actuall mean/want "ss"), as trying to set flags to just "S" would result in an error message. For precisely that reason I'd actually prefer to find letter(s) that would not conflict with existing type or access flags, but 'v'olatile seemed ambiguous / too broad at that time. >> [...] > I'm not sure why you are adding "transient" or "volatile" to the > varaccess. It is an orthogonal property of a variable. This is obvious > from the fact that you need to add yet another to compose varaccess > with varlifetime (or something). > > I worked on something similar years ago, but never posted an RFC. > > http://lists.denx.de/pipermail/u-boot/2010-June/073027.html That's a very good point. This 'orthogonality' is what actually caused me to come up with that "transient" vs. "system" idea. I think I got misled by the way that U-Boot already combined various "access" bit flags, and it never occured to me to introduce another property with a third flag character. Actually "?av" (any-access, volatile) and "?rv" (read-only, volatile) would represent my intent perfectly well. I also like your "auto-volatile" concept a lot (i.e. resetting the volatile nature on setenv by the user). To stay unambiguous ('a' = "any" access), maybe this could be tagged 't'emporary. We'd also need a default letter for the lifesspan flag, possibly 'n'ormal? The temporary (= auto-volatile) flag would also nicely save use from the need to have users fumble with "setenv .flags", and the quirks involved. Implementing this means some refactoring / a major overhaul of this RFC series, but I think it could be well worth that. I'll definitely give it a try when I find some time. Regards, B. Nortmann
On Wed, Nov 30, 2016 at 4:08 AM, Bernhard Nortmann <bernhard.nortmann@web.de> wrote: > Hi Joe! > > Thanks for chiming in, especially seeing that you have previously worked > on something very similar. Sure! Sorry I didn't review this sooner. > Am 27.11.2016 um 19:53 schrieb Joe Hershberger: >> >> On Wed, Nov 16, 2016 at 4:29 AM, Bernhard Nortmann >> <bernhard.nortmann@web.de> wrote: >>> >>> "transient" (='t') is like "any", but requests that a variable >>> should not be exported (ENV_FLAGS_VARACCESS_PREVENT_EXPORT). >>> >>> "system" (='S') is meant for 'internal' variables that >> >> The flags are positional, so 's' is not in use. It seems it would be >> cleaner to use a lower-case 's'. > > > You're probably right. I think back then I deliberately picked 'S' to avoid > potential confusion (e.g. users specifying "s" when they actuall mean/want > "ss"), as trying to set flags to just "S" would result in an error message. > > For precisely that reason I'd actually prefer to find letter(s) that would > not conflict with existing type or access flags, but 'v'olatile seemed > ambiguous / too broad at that time. Yes, that is a good point and was actually a consideration when I first chose the letters that are used for the current 2 positions. It's not a strict requirement, but it's less error-prone. >>> [...] >> >> I'm not sure why you are adding "transient" or "volatile" to the >> varaccess. It is an orthogonal property of a variable. This is obvious >> from the fact that you need to add yet another to compose varaccess >> with varlifetime (or something). >> >> I worked on something similar years ago, but never posted an RFC. >> >> http://lists.denx.de/pipermail/u-boot/2010-June/073027.html > > > That's a very good point. This 'orthogonality' is what actually caused me > to come up with that "transient" vs. "system" idea. I think I got misled > by the way that U-Boot already combined various "access" bit flags, and it > never occured to me to introduce another property with a third flag > character. > Actually "?av" (any-access, volatile) and "?rv" (read-only, volatile) would > represent my intent perfectly well. Perfect. That's exactly what I was proposing in 2010 (with the addition of auto-volatile). > I also like your "auto-volatile" concept a lot (i.e. resetting the volatile > nature on setenv by the user). To stay unambiguous ('a' = "any" access), > maybe this could be tagged 't'emporary. 't'emporary is ok, but I'm thinking something like o'v'erride(able) is more explicit about the behavior. > We'd also need a default letter for > the lifesspan flag, possibly 'n'ormal? I had suggested 'p'recious, but 'n'ormal is ok too. WD wanted a pointer type too, but I never got around to implementing it. Presumably that would conflict with 'p'recious if we went with that. Again, it's not that important that the letters used be unique across positions, it's just less error prone. At the same time, using the first letter of a meaning more often will be less error-prone also. > The temporary (= auto-volatile) flag would also nicely save use from the > need > to have users fumble with "setenv .flags", and the quirks involved. Exactly. It should be the uncommon case to need to touch the .flags. > Implementing this means some refactoring / a major overhaul of this RFC > series, but I think it could be well worth that. I'll definitely give it > a try when I find some time. Awesome, thanks. -Joe
diff --git a/common/env_flags.c b/common/env_flags.c index f39d952..2c30c7f 100644 --- a/common/env_flags.c +++ b/common/env_flags.c @@ -28,7 +28,7 @@ #endif static const char env_flags_vartype_rep[] = "sdxb" ENV_FLAGS_NET_VARTYPE_REPS; -static const char env_flags_varaccess_rep[] = "aroc"; +static const char env_flags_varaccess_rep[] = "aroctS"; static const int env_flags_varaccess_mask[] = { 0, ENV_FLAGS_VARACCESS_PREVENT_DELETE | @@ -37,7 +37,12 @@ static const int env_flags_varaccess_mask[] = { ENV_FLAGS_VARACCESS_PREVENT_DELETE | ENV_FLAGS_VARACCESS_PREVENT_OVERWR, ENV_FLAGS_VARACCESS_PREVENT_DELETE | - ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR}; + ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR, + ENV_FLAGS_VARACCESS_PREVENT_EXPORT, + ENV_FLAGS_VARACCESS_PREVENT_DELETE | + ENV_FLAGS_VARACCESS_PREVENT_CREATE | + ENV_FLAGS_VARACCESS_PREVENT_OVERWR | + ENV_FLAGS_VARACCESS_PREVENT_EXPORT}; #ifdef CONFIG_CMD_ENV_FLAGS static const char * const env_flags_vartype_names[] = { @@ -55,6 +60,8 @@ static const char * const env_flags_varaccess_names[] = { "read-only", "write-once", "change-default", + "transient", /* do not export/save */ + "system", /* = "transient" plus "read-only" */ }; /* diff --git a/include/env_flags.h b/include/env_flags.h index 7e2362a..9d66706 100644 --- a/include/env_flags.h +++ b/include/env_flags.h @@ -25,6 +25,8 @@ enum env_flags_varaccess { env_flags_varaccess_readonly, env_flags_varaccess_writeonce, env_flags_varaccess_changedefault, + env_flags_varaccess_transient, + env_flags_varaccess_system, env_flags_varaccess_end };
"transient" (='t') is like "any", but requests that a variable should not be exported (ENV_FLAGS_VARACCESS_PREVENT_EXPORT). "system" (='S') is meant for 'internal' variables that aren't supposed to be changed by the user. It corresponds to "transient" plus "read-only". Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de> --- Changes in v2: - Fixed outdated "env_flags_varaccess_lock" to the correct "env_flags_varaccess_system" common/env_flags.c | 11 +++++++++-- include/env_flags.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-)