From 8dd1c2d4aff5e40e4a87f59fa09f8de3f2232fc1 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Wed, 5 Feb 2014 22:03:46 +0200 Subject: [PATCH] core: correctly parse boolean configuration values. Also, with style. --- sgminer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sgminer.c b/sgminer.c index 9f793b1d..424ecb25 100644 --- a/sgminer.c +++ b/sgminer.c @@ -1392,18 +1392,20 @@ static char *parse_config(json_t *config, bool fileconf, int parent_iteration) int n, size = json_array_size(val); for (n = 0; n < size && !err; n++) { - if (json_is_string(json_array_get(val, n))) + if (json_is_string(json_array_get(val, n))) { err = opt->cb_arg(json_string_value(json_array_get(val, n)), opt->u.arg); + } else if (json_is_object(json_array_get(val, n))) { err = parse_config(json_array_get(val, n), false, n); json_array_index = parent_iteration; } } - } else if ((opt->type & OPT_NOARG) && json_is_true(val)) + } else if ((opt->type & OPT_NOARG) && json_is_boolean(val)) { err = opt->cb(opt->u.arg); - else + } else { err = "Invalid value"; + } if (err) { /* Allow invalid values to be in configuration