From: Lennart Poettering Date: Tue, 6 Nov 2018 11:06:45 +0000 (+0100) Subject: parse-util: allow parse_boolean() to take a NULL argument X-Git-Tag: v240~167^2~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b06f0cc6258b7135182f3b29244a7df0ab203ab6;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index 718357e290f..5b4e94c1348 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;