diff options
author | Ahmad Fatoum <ahmad@a3f.at> | 2020-11-26 19:31:54 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-27 10:02:36 +0100 |
commit | 8f57bc80c3e6a9f1c5318b52b98e9cc3268d10a8 (patch) | |
tree | 4bdd637c26eeacb9928cf36f2e91ca09a5084c6b /commands/setenv.c | |
parent | 870f45338872b5ac02b2f87b6409036a6292ecf3 (diff) | |
download | barebox-8f57bc80c3e6a9f1c5318b52b98e9cc3268d10a8.tar.gz |
commands: implement and use parse_assignment helper
We have the split by '=' snippet at multiple locations that parse
key=value pairs. Consolidate them to a single location. This makes code
a bit easier to read at the cost of an extra 8 bytes (LZO-compressed
THUMB2 barebox, static inline version is bigger).
No functional change.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/setenv.c')
-rw-r--r-- | commands/setenv.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/commands/setenv.c b/commands/setenv.c index 9aeb8f010b..99604c35c3 100644 --- a/commands/setenv.c +++ b/commands/setenv.c @@ -9,17 +9,15 @@ static int do_setenv(int argc, char *argv[]) { - char *equal; + char *val; int ret; if (argc < 2) return COMMAND_ERROR_USAGE; - equal = strrchr(argv[1], '='); - if (equal) { - equal[0] = '\0'; - argv[2] = &equal[1]; - } + val = parse_assignment(argv[1]); + if (val) + argv[2] = val; if (argv[2]) ret = setenv(argv[1], argv[2]); |