mirror of https://github.com/xzeldon/htop.git
netbsd: re-initialize freqSize before sysctlbyname()
This commit is contained in:
parent
72cea2881c
commit
a4b650fdec
|
@ -377,7 +377,7 @@ static void NetBSDProcessList_scanCPUFrequency(NetBSDProcessList* this) {
|
||||||
bool match = false;
|
bool match = false;
|
||||||
char name[64];
|
char name[64];
|
||||||
int freq = 0;
|
int freq = 0;
|
||||||
size_t freqSize = sizeof(freq);
|
size_t freqSize;
|
||||||
|
|
||||||
for (unsigned int i = 0; i <= cpus; i++) {
|
for (unsigned int i = 0; i <= cpus; i++) {
|
||||||
this->cpus[i].frequency = NAN;
|
this->cpus[i].frequency = NAN;
|
||||||
|
@ -386,6 +386,7 @@ static void NetBSDProcessList_scanCPUFrequency(NetBSDProcessList* this) {
|
||||||
/* newer hardware supports per-core frequency, for e.g. ARM big.LITTLE */
|
/* newer hardware supports per-core frequency, for e.g. ARM big.LITTLE */
|
||||||
for (unsigned int i = 0; i <= cpus; i++) {
|
for (unsigned int i = 0; i <= cpus; i++) {
|
||||||
snprintf(name, sizeof(name), "machdep.cpufreq.cpu%u.current", i);
|
snprintf(name, sizeof(name), "machdep.cpufreq.cpu%u.current", i);
|
||||||
|
freqSize = sizeof(freq);
|
||||||
if (sysctlbyname(name, &freq, &freqSize, NULL, 0) != -1) {
|
if (sysctlbyname(name, &freq, &freqSize, NULL, 0) != -1) {
|
||||||
this->cpus[i].frequency = freq;
|
this->cpus[i].frequency = freq;
|
||||||
match = true;
|
match = true;
|
||||||
|
@ -401,6 +402,7 @@ static void NetBSDProcessList_scanCPUFrequency(NetBSDProcessList* this) {
|
||||||
* we find a match...
|
* we find a match...
|
||||||
*/
|
*/
|
||||||
for (const char** s = freqSysctls; *s != NULL; ++s) {
|
for (const char** s = freqSysctls; *s != NULL; ++s) {
|
||||||
|
freqSize = sizeof(freq);
|
||||||
if (sysctlbyname(*s, &freq, &freqSize, NULL, 0) != -1) {
|
if (sysctlbyname(*s, &freq, &freqSize, NULL, 0) != -1) {
|
||||||
match = true;
|
match = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue