mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 10:04:33 +00:00
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.
This commit is contained in:
parent
e4657791bf
commit
b5b20c19f6
@ -567,6 +567,7 @@ char *set_intensity(char *arg)
|
|||||||
else {
|
else {
|
||||||
gpus[device].dynamic = false;
|
gpus[device].dynamic = false;
|
||||||
val = atoi(nextptr);
|
val = atoi(nextptr);
|
||||||
|
if (val == 0) return "disabled";
|
||||||
if (val < MIN_INTENSITY || val > MAX_INTENSITY)
|
if (val < MIN_INTENSITY || val > MAX_INTENSITY)
|
||||||
return "Invalid value passed to set intensity";
|
return "Invalid value passed to set intensity";
|
||||||
tt = &gpus[device].intensity;
|
tt = &gpus[device].intensity;
|
||||||
@ -583,6 +584,7 @@ char *set_intensity(char *arg)
|
|||||||
else {
|
else {
|
||||||
gpus[device].dynamic = false;
|
gpus[device].dynamic = false;
|
||||||
val = atoi(nextptr);
|
val = atoi(nextptr);
|
||||||
|
if (val == 0) return "disabled";
|
||||||
if (val < MIN_INTENSITY || val > MAX_INTENSITY)
|
if (val < MIN_INTENSITY || val > MAX_INTENSITY)
|
||||||
return "Invalid value passed to set intensity";
|
return "Invalid value passed to set intensity";
|
||||||
|
|
||||||
@ -614,6 +616,7 @@ char *set_xintensity(char *arg)
|
|||||||
if (nextptr == NULL)
|
if (nextptr == NULL)
|
||||||
return "Invalid parameters for shader based intensity";
|
return "Invalid parameters for shader based intensity";
|
||||||
val = atoi(nextptr);
|
val = atoi(nextptr);
|
||||||
|
if (val == 0) return "disabled";
|
||||||
if (val < MIN_XINTENSITY || val > MAX_XINTENSITY)
|
if (val < MIN_XINTENSITY || val > MAX_XINTENSITY)
|
||||||
return "Invalid value passed to set shader-based intensity";
|
return "Invalid value passed to set shader-based intensity";
|
||||||
|
|
||||||
@ -625,6 +628,7 @@ char *set_xintensity(char *arg)
|
|||||||
|
|
||||||
while ((nextptr = strtok(NULL, ",")) != NULL) {
|
while ((nextptr = strtok(NULL, ",")) != NULL) {
|
||||||
val = atoi(nextptr);
|
val = atoi(nextptr);
|
||||||
|
if (val == 0) return "disabled";
|
||||||
if (val < MIN_XINTENSITY || val > MAX_XINTENSITY)
|
if (val < MIN_XINTENSITY || val > MAX_XINTENSITY)
|
||||||
return "Invalid value passed to set shader based intensity";
|
return "Invalid value passed to set shader based intensity";
|
||||||
gpus[device].dynamic = false; // Disable dynamic intensity
|
gpus[device].dynamic = false; // Disable dynamic intensity
|
||||||
@ -653,6 +657,7 @@ char *set_rawintensity(char *arg)
|
|||||||
if (nextptr == NULL)
|
if (nextptr == NULL)
|
||||||
return "Invalid parameters for raw intensity";
|
return "Invalid parameters for raw intensity";
|
||||||
val = atoi(nextptr);
|
val = atoi(nextptr);
|
||||||
|
if (val == 0) return "disabled";
|
||||||
if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY)
|
if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY)
|
||||||
return "Invalid value passed to set raw intensity";
|
return "Invalid value passed to set raw intensity";
|
||||||
|
|
||||||
@ -664,6 +669,7 @@ char *set_rawintensity(char *arg)
|
|||||||
|
|
||||||
while ((nextptr = strtok(NULL, ",")) != NULL) {
|
while ((nextptr = strtok(NULL, ",")) != NULL) {
|
||||||
val = atoi(nextptr);
|
val = atoi(nextptr);
|
||||||
|
if (val == 0) return "disabled";
|
||||||
if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY)
|
if (val < MIN_RAWINTENSITY || val > MAX_RAWINTENSITY)
|
||||||
return "Invalid value passed to set raw intensity";
|
return "Invalid value passed to set raw intensity";
|
||||||
gpus[device].dynamic = false; // Disable dynamic intensity
|
gpus[device].dynamic = false; // Disable dynamic intensity
|
||||||
|
@ -1412,10 +1412,10 @@ static char *parse_config(json_t *config, bool fileconf, int parent_iteration)
|
|||||||
* file, just skipping over them provided the
|
* file, just skipping over them provided the
|
||||||
* JSON is still valid after that. */
|
* JSON is still valid after that. */
|
||||||
if (fileconf) {
|
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;
|
fileconf_load = -1;
|
||||||
} else {
|
} 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);
|
p, err);
|
||||||
return err_buf;
|
return err_buf;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user