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

Stefan Althoefer
2008-12-07T23:52:20Z

Hi Wolfgang Denk

> Dear Stefan Althoefer,
>
> In message <ghh632$ims$1@ger.gmane.org> you wrote:
>> You argue that the code should have a couple of hard to read else cases?
>
> 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).

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

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".

--- Stefan