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 | |
parent | 2987225ce6c3800821fe71e1ad5a698785ca54a3 (diff) | |
download | systemd-b06f0cc6258b7135182f3b29244a7df0ab203ab6.tar.gz systemd-b06f0cc6258b7135182f3b29244a7df0ab203ab6.tar.bz2 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')
-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; |