fw_setenv: avoid writing environment when nothing has changed
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Thu, 27 Sep 2018 20:45:26 +0000 (22:45 +0200)
committerJoe Hershberger <joe.hershberger@ni.com>
Fri, 20 Dec 2019 16:02:24 +0000 (10:02 -0600)
commitc62e6142b95045621fc229d34f40bd8d0e41160a
treeee87cb01d104057c94b32ae95c012c69d415b362
parent1785d8c3a5f396f7f81f029d8828908229bff87e
fw_setenv: avoid writing environment when nothing has changed

In the case where one deletes an already-non-existing variable, or sets
a variable to the value it already has, there is no point in writing the
environment back, thus reducing wear on the underlying storage
device.

In the case of redundant environments, if the two environments
differ (e.g. because one is corrupt), make sure that any call of
fw_setenv causes the two to become synchronized, even if the fw_setenv
call does not change anything in the good copy.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
tools/env/fw_env.c