From b5b20c19f6c70391d357c5b477120d2e7cab2d26 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Fri, 7 Feb 2014 00:30:58 +0200 Subject: [PATCH] core: make errors on reading experimental options from config less scary. The config file is written poorly: first off, not all available options are written (they have to be written manually, since there's no struct enumeration); then, default values are not commented out. --- driver-opencl.c | 6 ++++++ sgminer.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/driver-opencl.c b/driver-opencl.c index d3275a1c..54f3e0de 100644 --- a/driver-opencl.c +++ b/driver-opencl.c @@ -567,6 +567,7 @@ char *set_intensity(char *arg) else { gpus[device].dynamic = false; val = atoi(nextptr); + if (val == 0) return "disabled"; if (val < MIN_INTENSITY || val > MAX_INTENSITY) return "Invalid value passed to set intensity"; tt = &gpus[device].intensity; @@ -583,6 +584,7 @@ char *set_intensity(char *arg) else { gpus[device].dynamic = false; val = atoi(nextptr); + if (val == 0) return "disabled"; if (val < MIN_INTENSITY || val > MAX_INTENSITY) return "Invalid value passed to set intensity"; @@ -614,6 +616,7 @@ char *set_xintensity(char *arg) if (nextptr == NULL) return "Invalid parameters for shader based intensity"; val = atoi(nextptr); + if (val == 0) return "disabled"; if (val < MIN_XINTENSITY || val > MAX_XINTENSITY) return "Invalid value passed to set shader-based intensity"; @@ -625,6 +628,7 @@ char *set_xintensity(char *arg) while ((nextptr = strtok(NULL, ",")) != NULL) { val = atoi(nextptr); + if (val == 0) return "disabled"; if (val < MIN_XINTENSITY || val > MAX_XINTENSITY) return "Invalid value passed to set shader based intensity"; gpus[device].dynamic = false; // Disable dynamic intensity @@ -653,6 +657,7 @@ char *set_rawintensity(char *arg) if (nextptr == NULL) return "Invalid parameters for raw intensity"; val = atoi(nextptr); + if (val == 0) return "disabled"; if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY) return "Invalid value passed to set raw intensity"; @@ -664,6 +669,7 @@ char *set_rawintensity(char *arg) while ((nextptr = strtok(NULL, ",")) != NULL) { val = atoi(nextptr); + if (val == 0) return "disabled"; if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY) return "Invalid value passed to set raw intensity"; gpus[device].dynamic = false; // Disable dynamic intensity diff --git a/sgminer.c b/sgminer.c index 424ecb25..37486f13 100644 --- a/sgminer.c +++ b/sgminer.c @@ -1412,10 +1412,10 @@ static char *parse_config(json_t *config, bool fileconf, int parent_iteration) * file, just skipping over them provided the * JSON is still valid after that. */ if (fileconf) { - applog(LOG_ERR, "Invalid config option %s: %s", p, err); + applog(LOG_WARNING, "Skipping config option %s: %s", p, err); fileconf_load = -1; } else { - snprintf(err_buf, sizeof(err_buf), "Parsing JSON option %s: %s", + snprintf(err_buf, sizeof(err_buf), "Error parsing JSON option %s: %s", p, err); return err_buf; }