]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
parse-util: allow parse_boolean() to take a NULL argument
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Nov 2018 11:06:45 +0000 (12:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 30 Nov 2018 15:46:09 +0000 (16:46 +0100)
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.

src/basic/parse-util.c

index 718357e290f6d98c31696113075d2da13fb0a5aa..5b4e94c13488fef0f70cca5d1c4b6446b4cd7965 100644 (file)
@@ -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;