svn commit: samba r13677 - branches/SAMBA_3_0/examples/perfcounter trunk/examples/perfcounter

jerry at samba.org jerry at samba.org
Fri Feb 24 17:53:25 GMT 2006


Author: jerry
Date: 2006-02-24 17:53:25 +0000 (Fri, 24 Feb 2006)
New Revision: 13677

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13677

Log:
patch from Max N. Boyarov <m.boyarov at sam-solutions.net>
Prevent div/0 when sysconf(_SC_NPROCESSORS_ONLN) fails.


Modified:
   branches/SAMBA_3_0/examples/perfcounter/perf_writer.c
   trunk/examples/perfcounter/perf_writer.c


Changeset:
Modified: branches/SAMBA_3_0/examples/perfcounter/perf_writer.c
===================================================================
--- branches/SAMBA_3_0/examples/perfcounter/perf_writer.c	2006-02-24 16:06:18 UTC (rev 13676)
+++ branches/SAMBA_3_0/examples/perfcounter/perf_writer.c	2006-02-24 17:53:25 UTC (rev 13677)
@@ -26,7 +26,7 @@
 /* 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);

Modified: trunk/examples/perfcounter/perf_writer.c
===================================================================
--- trunk/examples/perfcounter/perf_writer.c	2006-02-24 16:06:18 UTC (rev 13676)
+++ trunk/examples/perfcounter/perf_writer.c	2006-02-24 17:53:25 UTC (rev 13677)
@@ -26,7 +26,7 @@
 /* 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);



More information about the samba-cvs mailing list