Browse Source

core: correctly parse boolean configuration values.

Also, with style.
nfactor-troky
Noel Maersk 11 years ago
parent
commit
8dd1c2d4af
  1. 8
      sgminer.c

8
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); 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

Loading…
Cancel
Save