]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
setenv(): Delete 0-length environment variables
authorPeter Tyser <ptyser@xes-inc.com>
Sun, 25 Oct 2009 20:12:55 +0000 (15:12 -0500)
committerWolfgang Denk <wd@denx.de>
Tue, 27 Oct 2009 19:58:25 +0000 (20:58 +0100)
Previously setenv() would only delete an environment variable if it
was passed a NULL string pointer as a value.  It should also delete an
environment variable when it encounters a valid string pointer of
0-length.

This change/fix is generally useful and is necessary for the upcoming
"editenv" command.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
common/cmd_nvedit.c

index 9f8d5319596d2a171f55035683c1eca61af21d11..725e573ddf85ce8b6e09b836d9469d198407409a 100644 (file)
@@ -400,7 +400,7 @@ int _do_setenv (int flag, int argc, char *argv[])
 int setenv (char *varname, char *varvalue)
 {
        char *argv[4] = { "setenv", varname, varvalue, NULL };
-       if (varvalue == NULL)
+       if ((varvalue == NULL) || (varvalue[0] == '\0'))
                return _do_setenv (0, 2, argv);
        else
                return _do_setenv (0, 3, argv);