[PATCH 4/6] parameter: Use strtobool
Sascha Hauer
s.hauer at pengutronix.de
Fri Apr 29 02:52:03 PDT 2016
Use strtobool to convert the input string to a boolean type.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
lib/parameter.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/parameter.c b/lib/parameter.c
index fd05b49..7ceec0c 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,10 @@ 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;
+ return strtobool(val, pi->value);
+
+ *pi->value = simple_strtol(val, NULL, 0);
if (!pi->set)
return 0;
--
2.8.0.rc3
More information about the barebox
mailing list