Revert "Provide simple macros for the repeated use of checking the first value of the input char with strncasecmp." This reverts commit 87708a6a0e151401aee6cebf624940467993707b. Broken.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
diff --git a/adl.c b/adl.c
index b68fa5d..b2c00fc 100644
--- a/adl.c
+++ b/adl.c
@@ -1198,34 +1198,34 @@ void change_autosettings(int gpu)
wlogprint("Toggle [F]an auto [G]PU auto\nChange [T]arget [O]verheat [C]utoff\n");
wlogprint("Or press any other key to continue\n");
input = getch();
- if (INPUTEQ(f)) {
+ if (!strncasecmp(&input, "f", 1)) {
ga->autofan ^= true;
wlogprint("Fan autotune is now %s\n", ga->autofan ? "enabled" : "disabled");
if (!ga->autofan) {
wlogprint("Resetting fan to startup settings\n");
set_defaultfan(gpu);
}
- } else if (INPUTEQ(g)) {
+ } else if (!strncasecmp(&input, "g", 1)) {
ga->autoengine ^= true;
wlogprint("GPU engine clock autotune is now %s\n", ga->autoengine ? "enabled" : "disabled");
if (!ga->autoengine) {
wlogprint("Resetting GPU engine clock to startup settings\n");
set_defaultengine(gpu);
}
- } else if (INPUTEQ(t)) {
+ } else if (!strncasecmp(&input, "t", 1)) {
val = curses_int("Enter target temperature for this GPU in C (0-200)");
if (val < 0 || val > 200)
wlogprint("Invalid temperature");
else
ga->targettemp = val;
- } else if (INPUTEQ(o)) {
+ } else if (!strncasecmp(&input, "o", 1)) {
wlogprint("Enter overheat temperature for this GPU in C (%d+)", ga->targettemp);
val = curses_int("");
if (val <= ga->targettemp || val > 200)
wlogprint("Invalid temperature");
else
ga->overtemp = val;
- } else if (INPUTEQ(c)) {
+ } else if (!strncasecmp(&input, "c", 1)) {
wlogprint("Enter cutoff temperature for this GPU in C (%d+)", ga->overtemp);
val = curses_int("");
if (val <= ga->overtemp || val > 200)
@@ -1265,70 +1265,70 @@ updated:
wlogprint("Or press any other key to continue\n");
input = getch();
- if (INPUTEQ(a)) {
+ if (!strncasecmp(&input, "a", 1)) {
change_autosettings(gpu);
- } else if (INPUTEQ(e)) {
+ } else if (!strncasecmp(&input, "e", 1)) {
get_enginerange(gpu, &imin, &imax);
wlogprint("Enter GPU engine clock speed (%d - %d Mhz)", imin, imax);
val = curses_int("");
if (val < imin || val > imax) {
wlogprint("Value is outside safe range, are you sure?\n");
input = getch();
- if (INPUTNEQ(y))
+ if (strncasecmp(&input, "y", 1))
return;
}
if (!set_engineclock(gpu, val))
wlogprint("Driver reports success but check values below\n");
else
wlogprint("Failed to modify engine clock speed\n");
- } else if (INPUTEQ(f)) {
+ } else if (!strncasecmp(&input, "f", 1)) {
get_fanrange(gpu, &imin, &imax);
wlogprint("Enter fan percentage (%d - %d %)", imin, imax);
val = curses_int("");
if (val < imin || val > imax) {
wlogprint("Value is outside safe range, are you sure?\n");
input = getch();
- if (INPUTNEQ(y))
+ if (strncasecmp(&input, "y", 1))
return;
}
if (!set_fanspeed(gpu, val))
wlogprint("Driver reports success but check values below\n");
else
wlogprint("Failed to modify fan speed\n");
- } else if (INPUTEQ(m)) {
+ } else if (!strncasecmp(&input, "m", 1)) {
get_memoryrange(gpu, &imin, &imax);
wlogprint("Enter GPU memory clock speed (%d - %d Mhz)", imin, imax);
val = curses_int("");
if (val < imin || val > imax) {
wlogprint("Value is outside safe range, are you sure?\n");
input = getch();
- if (INPUTNEQ(y))
+ if (strncasecmp(&input, "y", 1))
return;
}
if (!set_memoryclock(gpu, val))
wlogprint("Driver reports success but check values below\n");
else
wlogprint("Failed to modify memory clock speed\n");
- } else if (INPUTEQ(v)) {
+ } else if (!strncasecmp(&input, "v", 1)) {
get_vddcrange(gpu, &fmin, &fmax);
wlogprint("Enter GPU voltage (%.3f - %.3f V)", fmin, fmax);
fval = curses_float("");
if (fval < fmin || fval > fmax) {
wlogprint("Value is outside safe range, are you sure?\n");
input = getch();
- if (INPUTNEQ(y))
+ if (strncasecmp(&input, "y", 1))
return;
}
if (!set_vddc(gpu, fval))
wlogprint("Driver reports success but check values below\n");
else
wlogprint("Failed to modify voltage\n");
- } else if (INPUTEQ(p)) {
+ } else if (!strncasecmp(&input, "p", 1)) {
val = curses_int("Enter powertune value (-20 - 20)");
if (val < -20 || val > 20) {
wlogprint("Value is outside safe range, are you sure?\n");
input = getch();
- if (INPUTNEQ(y))
+ if (strncasecmp(&input, "y", 1))
return;
}
if (!set_powertune(gpu, val))
diff --git a/cgminer.c b/cgminer.c
index d38cd1d..873be64 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2814,10 +2814,10 @@ retry:
wlogprint("Or press any other key to continue\n");
input = getch();
- if (INPUTEQ(a)) {
+ if (!strncasecmp(&input, "a", 1)) {
input_pool(true);
goto updated;
- } else if (INPUTEQ(r)) {
+ } else if (!strncasecmp(&input, "r", 1)) {
if (total_pools <= 1) {
wlogprint("Cannot remove last pool");
goto retry;
@@ -2837,7 +2837,7 @@ retry:
pool->enabled = POOL_DISABLED;
remove_pool(pool);
goto updated;
- } else if (INPUTEQ(s)) {
+ } else if (!strncasecmp(&input, "s", 1)) {
selected = curses_int("Select pool number");
if (selected < 0 || selected >= total_pools) {
wlogprint("Invalid selection\n");
@@ -2847,7 +2847,7 @@ retry:
pool->enabled = POOL_ENABLED;
switch_pools(pool);
goto updated;
- } else if (INPUTEQ(d)) {
+ } else if (!strncasecmp(&input, "d", 1)) {
if (active_pools() <= 1) {
wlogprint("Cannot disable last pool");
goto retry;
@@ -2862,7 +2862,7 @@ retry:
if (pool == current_pool())
switch_pools(NULL);
goto updated;
- } else if (INPUTEQ(e)) {
+ } else if (!strncasecmp(&input, "e", 1)) {
selected = curses_int("Select pool number");
if (selected < 0 || selected >= total_pools) {
wlogprint("Invalid selection\n");
@@ -2873,7 +2873,7 @@ retry:
if (pool->prio < current_pool()->prio)
switch_pools(pool);
goto updated;
- } else if (INPUTEQ(c)) {
+ } else if (!strncasecmp(&input, "c", 1)) {
for (i = 0; i <= TOP_STRATEGY; i++)
wlogprint("%d: %s\n", i, strategies[i]);
selected = curses_int("Select strategy number type");
@@ -2893,7 +2893,7 @@ retry:
pool_strategy = selected;
switch_pools(NULL);
goto updated;
- } else if (INPUTEQ(i)) {
+ } else if (!strncasecmp(&input, "i", 1)) {
selected = curses_int("Select pool number");
if (selected < 0 || selected >= total_pools) {
wlogprint("Invalid selection\n");
@@ -2928,17 +2928,17 @@ retry:
opt_log_interval);
wlogprint("Select an option or any other key to return\n");
input = getch();
- if (INPUTEQ(q)) {
+ if (!strncasecmp(&input, "q", 1)) {
opt_quiet ^= true;
wlogprint("Quiet mode %s\n", opt_quiet ? "enabled" : "disabled");
goto retry;
- } else if (INPUTEQ(v)) {
+ } else if (!strncasecmp(&input, "v", 1)) {
opt_log_output ^= true;
if (opt_log_output)
opt_quiet = false;
wlogprint("Verbose mode %s\n", opt_log_output ? "enabled" : "disabled");
goto retry;
- } else if (INPUTEQ(n)) {
+ } else if (!strncasecmp(&input, "n", 1)) {
opt_log_output = false;
opt_debug = false;
opt_quiet = false;
@@ -2946,27 +2946,27 @@ retry:
want_per_device_stats = false;
wlogprint("Output mode reset to normal\n");
goto retry;
- } else if (INPUTEQ(d)) {
+ } else if (!strncasecmp(&input, "d", 1)) {
opt_debug ^= true;
opt_log_output = opt_debug;
if (opt_debug)
opt_quiet = false;
wlogprint("Debug mode %s\n", opt_debug ? "enabled" : "disabled");
goto retry;
- } else if (INPUTEQ(p)) {
+ } else if (!strncasecmp(&input, "p", 1)) {
want_per_device_stats ^= true;
opt_log_output = want_per_device_stats;
wlogprint("Per-device stats %s\n", want_per_device_stats ? "enabled" : "disabled");
goto retry;
- } else if (INPUTEQ(r)) {
+ } else if (!strncasecmp(&input, "r", 1)) {
opt_protocol ^= true;
if (opt_protocol)
opt_quiet = false;
wlogprint("RPC protocol debugging %s\n", opt_protocol ? "enabled" : "disabled");
goto retry;
- } else if (INPUTEQ(c))
+ } else if (!strncasecmp(&input, "c", 1))
clear_logwin();
- else if (INPUTEQ(l)) {
+ else if (!strncasecmp(&input, "l", 1)) {
selected = curses_int("Interval in seconds");
if (selected < 0 || selected > 9999) {
wlogprint("Invalid selection\n");
@@ -2975,7 +2975,7 @@ retry:
opt_log_interval = selected;
wlogprint("Log interval set to %d seconds\n", opt_log_interval);
goto retry;
- } else if (INPUTEQ(s)) {
+ } else if (!strncasecmp(&input, "s", 1)) {
opt_realquiet = true;
} else
clear_logwin();
@@ -3001,7 +3001,7 @@ retry:
wlogprint("Select an option or any other key to return\n");
input = getch();
- if (INPUTEQ(q)) {
+ if (!strncasecmp(&input, "q", 1)) {
selected = curses_int("Extra work items to queue");
if (selected < 0 || selected > 9999) {
wlogprint("Invalid selection\n");
@@ -3009,7 +3009,7 @@ retry:
}
opt_queue = selected;
goto retry;
- } else if (INPUTEQ(s)) {
+ } else if (!strncasecmp(&input, "s", 1)) {
selected = curses_int("Set scantime in seconds");
if (selected < 0 || selected > 9999) {
wlogprint("Invalid selection\n");
@@ -3017,7 +3017,7 @@ retry:
}
opt_scantime = selected;
goto retry;
- } else if (INPUTEQ(e)) {
+ } else if (!strncasecmp(&input, "e", 1)) {
selected = curses_int("Set expiry time in seconds");
if (selected < 0 || selected > 9999) {
wlogprint("Invalid selection\n");
@@ -3025,7 +3025,7 @@ retry:
}
opt_expiry = selected;
goto retry;
- } else if (INPUTEQ(r)) {
+ } else if (!strncasecmp(&input, "r", 1)) {
selected = curses_int("Retries before failing (-1 infinite)");
if (selected < -1 || selected > 9999) {
wlogprint("Invalid selection\n");
@@ -3033,7 +3033,7 @@ retry:
}
opt_retries = selected;
goto retry;
- } else if (INPUTEQ(p)) {
+ } else if (!strncasecmp(&input, "p", 1)) {
selected = curses_int("Seconds to pause before network retries");
if (selected < 1 || selected > 9999) {
wlogprint("Invalid selection\n");
@@ -3041,7 +3041,7 @@ retry:
}
opt_fail_pause = selected;
goto retry;
- } else if (INPUTEQ(w)) {
+ } else if (!strncasecmp(&input, "w", 1)) {
FILE *fcfg;
char *str, filename[PATH_MAX], prompt[PATH_MAX + 50];
@@ -3067,7 +3067,7 @@ retry:
if (!stat(filename, &statbuf)) {
wlogprint("File exists, overwrite?\n");
input = getch();
- if (INPUTNEQ(y))
+ if (strncasecmp(&input, "y", 1))
goto retry;
}
}
@@ -3080,10 +3080,10 @@ retry:
fclose(fcfg);
goto retry;
- } else if (INPUTEQ(c)) {
+ } else if (!strncasecmp(&input, "c", 1)) {
wlogprint("Are you sure?\n");
input = getch();
- if (INPUTEQ(y))
+ if (!strncasecmp(&input, "y", 1))
app_restart();
else
clear_logwin();
@@ -3105,16 +3105,16 @@ static void *input_thread(void __maybe_unused *userdata)
char input;
input = getch();
- if (INPUTEQ(q)) {
+ if (!strncasecmp(&input, "q", 1)) {
kill_work();
return NULL;
- } else if (INPUTEQ(d))
+ } else if (!strncasecmp(&input, "d", 1))
display_options();
- else if (INPUTEQ(p))
+ else if (!strncasecmp(&input, "p", 1))
display_pools();
- else if (INPUTEQ(s))
+ else if (!strncasecmp(&input, "s", 1))
set_options();
- else if (have_opencl && INPUTEQ(g))
+ else if (have_opencl && !strncasecmp(&input, "g", 1))
manage_gpu();
if (opt_realquiet) {
disable_curses();
diff --git a/driver-opencl.c b/driver-opencl.c
index 71462f6..dd15687 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -663,7 +663,7 @@ retry:
selected = 0;
else
selected = -1;
- if (INPUTEQ(e)) {
+ if (!strncasecmp(&input, "e", 1)) {
struct cgpu_info *cgpu;
if (selected)
@@ -693,7 +693,7 @@ retry:
tq_push(thr->q, &ping);
}
goto retry;
- } if (INPUTEQ(d)) {
+ } if (!strncasecmp(&input, "d", 1)) {
if (selected)
selected = curses_int("Select GPU to disable");
if (selected < 0 || selected >= nDevs) {
@@ -706,7 +706,7 @@ retry:
}
gpus[selected].deven = DEV_DISABLED;
goto retry;
- } else if (INPUTEQ(i)) {
+ } else if (!strncasecmp(&input, "i", 1)) {
int intensity;
char *intvar;
@@ -739,7 +739,7 @@ retry:
wlogprint("Intensity on gpu %d set to %d\n", selected, intensity);
pause_dynamic_threads(selected);
goto retry;
- } else if (INPUTEQ(r)) {
+ } else if (!strncasecmp(&input, "r", 1)) {
if (selected)
selected = curses_int("Select GPU to attempt to restart");
if (selected < 0 || selected >= nDevs) {
@@ -749,7 +749,7 @@ retry:
wlogprint("Attempting to restart threads of GPU %d\n", selected);
reinit_device(&gpus[selected]);
goto retry;
- } else if (adl_active && (INPUTEQ(c))) {
+ } else if (adl_active && (!strncasecmp(&input, "c", 1))) {
if (selected)
selected = curses_int("Select GPU to change settings on");
if (selected < 0 || selected >= nDevs) {
diff --git a/miner.h b/miner.h
index 2974313..cf78951 100644
--- a/miner.h
+++ b/miner.h
@@ -132,9 +132,6 @@ void *alloca (size_t);
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
-#define INPUTEQ(X) (!strncasecmp(&input, ("X"), 1))
-#define INPUTNEQ(X) (strncasecmp(&input, ("X"), 1))
-
enum alive {
LIFE_WELL,
LIFE_SICK,