From 4d6c78fb892cc190bd86e3430650af3f946973e9 Mon Sep 17 00:00:00 2001 From: Paul Bone Date: Tue, 2 Mar 2021 20:31:23 +1100 Subject: [PATCH] Only set numPhysicalCores if ratio is valid --- programs/util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/programs/util.c b/programs/util.c index be048332b..9b0405043 100644 --- a/programs/util.c +++ b/programs/util.c @@ -1212,11 +1212,13 @@ int UTIL_countPhysicalCores(void) /* fall back on the sysconf value */ goto failed; } } - if (siblings && cpu_cores) { + if (siblings && cpu_cores && siblings > cpu_cores) { ratio = siblings / cpu_cores; } - numPhysicalCores = numPhysicalCores / ratio; + if (ratio && numPhysicalCores > ratio) { + numPhysicalCores = numPhysicalCores / ratio; + } failed: fclose(cpuinfo);