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.
This commit is contained in:
parent
2987225ce6
commit
b06f0cc625
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue