Limit configurable CPU count to the number of detected CPU cores.

This commit is contained in:
Roman D committed 2023-08-21 22:24:13 +02:00
1 parent dfabad37d9
commit 908b8ca0b3
3 files changed
+10 -4

No files matched your search

+3 -2
View File
@@ -1004,8 +1004,9 @@ int main(int argc, char *argv[]) {
return 1;
}
long int ncpus = strtol(argv[i + 1], NULL, 10);
if (ncpus < 0 || ncpus >= INT_MAX) {
PrintAndLogEx(ERR, _RED_("ERROR:") " invalid number of CPU cores: --ncpu " _YELLOW_("%s") "\n", argv[i + 1]);
const int detected_cpus = detect_num_CPUs();
if (ncpus < 0 || ncpus >= detected_cpus) {
PrintAndLogEx(ERR, _RED_("ERROR:") " invalid number of CPU cores: --ncpu " _YELLOW_("%s") " (available: %d)\n", argv[i + 1], detected_cpus);
return 1;
}
g_numCPUs = ncpus;