diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-04-29 11:10:31 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-05-04 11:58:46 +0200 |
commit | a9b18674c0ffefd08064dff898b1f621f8c258d5 (patch) | |
tree | 25cf0bcaf263bdaff72eb242e7da5267e03c8c12 /lib | |
parent | a66b7f8afd9a58d918f4a5748722f0e64754db7f (diff) | |
download | barebox-a9b18674c0ffefd08064dff898b1f621f8c258d5.tar.gz barebox-a9b18674c0ffefd08064dff898b1f621f8c258d5.tar.xz |
parameter: Use strtobool
Use strtobool to convert the input string to a boolean type.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parameter.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/parameter.c b/lib/parameter.c index fd05b49adf..cf34817dc2 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -27,6 +27,7 @@ #include <net.h> #include <malloc.h> #include <driver.h> +#include <string.h> #include <linux/err.h> struct param_d *get_param_by_name(struct device_d *dev, const char *name) @@ -314,10 +315,13 @@ static int param_int_set(struct device_d *dev, struct param_d *p, const char *va if (!val) return -EINVAL; - *pi->value = simple_strtol(val, NULL, 0); - - if (pi->flags & PARAM_INT_FLAG_BOOL) - *pi->value = !!*pi->value; + if (pi->flags & PARAM_INT_FLAG_BOOL) { + ret = strtobool(val, pi->value); + if (ret) + return ret; + } else { + *pi->value = simple_strtol(val, NULL, 0); + } if (!pi->set) return 0; |