1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-22 20:44:19 +00:00

core: correctly parse boolean configuration values.

Also, with style.
This commit is contained in:
Noel Maersk 2014-02-05 22:03:46 +02:00
parent 0e8ec8d060
commit 8dd1c2d4af

View File

@ -1392,18 +1392,20 @@ static char *parse_config(json_t *config, bool fileconf, int parent_iteration)
int n, size = json_array_size(val); int n, size = json_array_size(val);
for (n = 0; n < size && !err; n++) { 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); 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))) else if (json_is_object(json_array_get(val, n)))
{ {
err = parse_config(json_array_get(val, n), false, n); err = parse_config(json_array_get(val, n), false, n);
json_array_index = parent_iteration; 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); err = opt->cb(opt->u.arg);
else } else {
err = "Invalid value"; err = "Invalid value";
}
if (err) { if (err) {
/* Allow invalid values to be in configuration /* Allow invalid values to be in configuration