From b84c86f7c99ee8671d134f792b1dbbfe89ca368f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 24 Feb 2006 17:53:25 +0000 Subject: r13677: patch from Max N. Boyarov Prevent div/0 when sysconf(_SC_NPROCESSORS_ONLN) fails. (This used to be commit 9a335255529d0e93dabbb6b0910f10fa162f9d4a) --- examples/perfcounter/perf_writer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/perfcounter/perf_writer.c b/examples/perfcounter/perf_writer.c index 04127f5621..00e47bdaba 100644 --- a/examples/perfcounter/perf_writer.c +++ b/examples/perfcounter/perf_writer.c @@ -26,7 +26,7 @@ sig_atomic_t keep_running = TRUE; /* allocates memory and gets numCPUs, total memory, and PerfFreq, number of disks... */ void get_constants(PERF_DATA_BLOCK *data) { - data->cpuInfo.numCPUs = sysconf(_SC_NPROCESSORS_ONLN); + data->cpuInfo.numCPUs = sysconf(_SC_NPROCESSORS_ONLN) > 0 ? sysconf(_SC_NPROCESSORS_ONLN) : 1; data->PerfFreq = sysconf(_SC_CLK_TCK); init_mem_data(data); init_cpu_data(data); -- cgit