summaryrefslogtreecommitdiff
path: root/cmd/nvedit.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-03-31 10:04:23 -0400
committerTom Rini <trini@konsulko.com>2023-03-31 10:04:23 -0400
commitb8deed53fe6a55ef76b4f9038bb419a9c853a9fa (patch)
tree2f0cdb8f35d7c51611417bab680583a65bf21306 /cmd/nvedit.c
parentf1617e99b933d2c3ecb381954148284d37bf922e (diff)
parentf98b112f9e0516fc9333611d1228d0b634aa353e (diff)
Merge branch '2023-03-30-assorted-general-upates' into next
- RTC cleanups / improvements, run_commandf() cleanups, fs bugfixes, socrates config fix, PCI MPS support, GPIO improvements, other code cleanups
Diffstat (limited to 'cmd/nvedit.c')
-rw-r--r--cmd/nvedit.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 7cbc3fd573a..12eae0627bb 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -1025,6 +1025,7 @@ static int do_env_indirect(struct cmd_tbl *cmdtp, int flag,
char *from = argv[2];
char *default_value = NULL;
int ret = 0;
+ char *val;
if (argc < 3 || argc > 4) {
return CMD_RET_USAGE;
@@ -1034,18 +1035,14 @@ static int do_env_indirect(struct cmd_tbl *cmdtp, int flag,
default_value = argv[3];
}
- if (env_get(from) == NULL && default_value == NULL) {
+ val = env_get(from) ?: default_value;
+ if (!val) {
printf("## env indirect: Environment variable for <from> (%s) does not exist.\n", from);
return CMD_RET_FAILURE;
}
- if (env_get(from) == NULL) {
- ret = env_set(to, default_value);
- }
- else {
- ret = env_set(to, env_get(from));
- }
+ ret = env_set(to, val);
if (ret == 0) {
return CMD_RET_SUCCESS;