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 /lib/string.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 'lib/string.c')
-rw-r--r-- | lib/string.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index b63041c5fb..dbb66fe4d2 100644 --- a/lib/string.c +++ b/lib/string.c @@ -899,3 +899,14 @@ int match_string(const char * const *array, size_t n, const char *string) return -EINVAL; } EXPORT_SYMBOL(match_string); + +char *parse_assignment(char *str) +{ + char *value; + + value = strchr(str, '='); + if (value) + *value++ = '\0'; + + return value; +} |