[U-Boot] [PATCH] common: nvedit to protect additional ethernet addresses Part 1/1

Wolfgang Denk
2008-12-15T22:55:30Z

Dear Stefan Althoefer,

In message <ghhni0$6dv$1@ger.gmane.org> you wrote:
>
> > That would be one way to avoid unnecessary tests.
> >
> > Probably not the most elegant approach, agreed.
> >
> > There are other options, though.
>
> But your suggested optimizations will only be effective if someone tries to
> write to "serial#". This is not normally done (attempt can be considered
> an error).

Can it? What make you think so?

There are lots of boards that come fresh out of production with a
virgin environment, where setting "serial#" is a perfectly normal
thing, and not an error at all.

> If access to any nonprotected environment variables is requested (and speed
> does matter here) then any of the protected cases must be tested.

Yes, but you can do this in many different ways - more and less
efficient ones.

> Even you code:
>
> --------
> if( "serial#" )
> ...
> else if( "ethaddr" )
> ...
> else if( "eth[0-9]+addr" )
> ...
> ---------
>
> then all the ifs are triggered if you write to "videomode".

Yes, we probably can agree that this is one of the less efficient
implementations [I take it as pseudo code, because otherwise all
cases would execute the "if" branch.]

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
If all you have is a hammer, everything looks like a nail.