Browse Source

core: don't use magic numbers to set xintensity.

nfactor-troky
Noel Maersk 11 years ago
parent
commit
99fa25c27f
  1. 10
      driver-opencl.c
  2. 4
      miner.h

10
driver-opencl.c

@ -603,7 +603,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 < 1 || val > 9999) if (val < MIN_XINTENSITY || val > MAX_XINTENSITY)
return "Invalid value passed to set shader intensity"; return "Invalid value passed to set shader intensity";
gpus[device].dynamic = false; // Disable dynamic intensity gpus[device].dynamic = false; // Disable dynamic intensity
@ -613,7 +613,7 @@ char *set_xintensity(char *arg)
while ((nextptr = strtok(NULL, ",")) != NULL) { while ((nextptr = strtok(NULL, ",")) != NULL) {
val = atoi(nextptr); val = atoi(nextptr);
if (val < 1 || val > 9999) 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
gpus[device].intensity = 0; // Disable regular intensity gpus[device].intensity = 0; // Disable regular intensity
@ -678,7 +678,7 @@ void manage_gpu(void)
opt_loginput = true; opt_loginput = true;
immedok(logwin, true); immedok(logwin, true);
clear_logwin(); clear_logwin();
retry: retry: // TODO: refactor
for (gpu = 0; gpu < nDevs; gpu++) { for (gpu = 0; gpu < nDevs; gpu++) {
struct cgpu_info *cgpu = &gpus[gpu]; struct cgpu_info *cgpu = &gpus[gpu];
@ -865,14 +865,14 @@ retry:
goto retry; goto retry;
} }
intvar = curses_input("Set experimental GPU scan intensity (1 -> 999)"); // FIXME: no magic numbers intvar = curses_input("Set experimental GPU scan intensity (" MIN_XINTENSITY_STR " -> " MAX_XINTENSITY_STR ")");
if (!intvar) { if (!intvar) {
wlogprint("Invalid input\n"); wlogprint("Invalid input\n");
goto retry; goto retry;
} }
xintensity = atoi(intvar); xintensity = atoi(intvar);
free(intvar); free(intvar);
if (xintensity < 1 || xintensity > 999) { // FIXME: no magic numbers if (xintensity < MIN_XINTENSITY || xintensity > MAX_XINTENSITY) {
wlogprint("Invalid selection\n"); wlogprint("Invalid selection\n");
goto retry; goto retry;
} }

4
miner.h

@ -1050,6 +1050,10 @@ extern bool add_pool_details(struct pool *pool, bool live, char *url, char *user
#define MIN_INTENSITY_STR "8" #define MIN_INTENSITY_STR "8"
#define MAX_INTENSITY 31 #define MAX_INTENSITY 31
#define MAX_INTENSITY_STR "31" #define MAX_INTENSITY_STR "31"
#define MIN_XINTENSITY 1
#define MIN_XINTENSITY_STR "1"
#define MAX_XINTENSITY 999
#define MAX_XINTENSITY_STR "999"
extern bool hotplug_mode; extern bool hotplug_mode;
extern int hotplug_time; extern int hotplug_time;

Loading…
Cancel
Save