diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-06 12:06:45 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-11-30 16:46:09 +0100 |
commit | b06f0cc6258b7135182f3b29244a7df0ab203ab6 (patch) | |
tree | b8d90b7bf6b9e41a2f85778adc2f34858dee322a /src/basic/parse-util.c | |
parent | analyze: use strv_skip() where appropriate (diff) | |
download | systemd-b06f0cc6258b7135182f3b29244a7df0ab203ab6.tar.xz systemd-b06f0cc6258b7135182f3b29244a7df0ab203ab6.zip |
parse-util: allow parse_boolean() to take a NULL argument
It's pretty useful to allow parse_boolean() to take a NULL argument and
return an error in that case, rather than abort. i.e. making this a
runtime rather than programming error allows us to shorten code
elsewhere.
Diffstat (limited to 'src/basic/parse-util.c')
-rw-r--r-- | src/basic/parse-util.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index 718357e290..5b4e94c134 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -20,7 +20,8 @@ #include "string-util.h" int parse_boolean(const char *v) { - assert(v); + if (!v) + return -EINVAL; if (streq(v, "1") || strcaseeq(v, "yes") || strcaseeq(v, "y") || strcaseeq(v, "true") || strcaseeq(v, "t") || strcaseeq(v, "on")) return 1; |