From: Carlo M. A. B. <ca...@sa...> - 2008-04-23 10:15:22
|
the following proposed patch for stable (3.0 and 3.1) removes a floating cast and the use of an uninitialized buffer which could result in high cpu_speed values when the size of the buffer used by the call to sysctlbyname on "machdep.tsc.freq" was smaller than the one proposed (8 bytes). attached original fix committed as r1293 Carlo --- Index: metrics.c =================================================================== --- metrics.c (revision 1292) +++ metrics.c (revision 1293) @@ -204,9 +204,10 @@ * machdep.tsc_freq exists on some i386/amd64 machines and gives the * CPU speed in Hz. If it exists it's a decent value. */ + tscfreq = 0; len = sizeof(tscfreq); if (sysctlbyname("machdep.tsc_freq", &tscfreq, &len, NULL, 0) != -1) { - freq = (double)tscfreq / 1e6; + freq = tscfreq / 1e6; goto done; } |