From a11d01568c5e7bc5570fd48fa0703d837c4bcd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 17 Feb 2021 17:38:35 +0100 Subject: Use unsigned types for CPU counts and associated variables --- freebsd/FreeBSDProcessList.c | 10 +++++----- freebsd/Platform.c | 4 ++-- freebsd/Platform.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'freebsd') diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 87f2e4d5..628956d1 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -175,8 +175,8 @@ void ProcessList_delete(ProcessList* this) { static inline void FreeBSDProcessList_scanCPU(ProcessList* pl) { const FreeBSDProcessList* fpl = (FreeBSDProcessList*) pl; - int cpus = pl->cpuCount; // actual CPU count - int maxcpu = cpus; // max iteration (in case we have average + smp) + unsigned int cpus = pl->cpuCount; // actual CPU count + unsigned int maxcpu = cpus; // max iteration (in case we have average + smp) int cp_times_offset; assert(cpus > 0); @@ -203,7 +203,7 @@ static inline void FreeBSDProcessList_scanCPU(ProcessList* pl) { sysctl(MIB_kern_cp_times, 2, fpl->cp_times_n, &sizeof_cp_time_array, NULL, 0); } - for (int i = 0; i < maxcpu; i++) { + for (unsigned int i = 0; i < maxcpu; i++) { if (cpus == 1) { // single CPU box cp_time_n = fpl->cp_time_n; @@ -287,7 +287,7 @@ static inline void FreeBSDProcessList_scanCPU(ProcessList* pl) { if (cpus > 1) { if (pl->settings->showCPUTemperature) { double maxTemp = NAN; - for (int i = 1; i < maxcpu; i++) { + for (unsigned int i = 1; i < maxcpu; i++) { const double coreTemp = fpl->cpus[i].temperature; if (isnan(coreTemp)) continue; @@ -302,7 +302,7 @@ static inline void FreeBSDProcessList_scanCPU(ProcessList* pl) { const double coreZeroFreq = fpl->cpus[1].frequency; double freqSum = coreZeroFreq; if (!isnan(coreZeroFreq)) { - for (int i = 2; i < maxcpu; i++) { + for (unsigned int i = 2; i < maxcpu; i++) { if (isnan(fpl->cpus[i].frequency)) fpl->cpus[i].frequency = coreZeroFreq; diff --git a/freebsd/Platform.c b/freebsd/Platform.c index 453703c3..1ca080d0 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -179,9 +179,9 @@ int Platform_getMaxPid() { return maxPid; } -double Platform_setCPUValues(Meter* this, int cpu) { +double Platform_setCPUValues(Meter* this, unsigned int cpu) { const FreeBSDProcessList* fpl = (const FreeBSDProcessList*) this->pl; - int cpus = this->pl->cpuCount; + unsigned int cpus = this->pl->cpuCount; const CPUData* cpuData; if (cpus == 1) { diff --git a/freebsd/Platform.h b/freebsd/Platform.h index ab5c63cf..850fb75b 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -42,7 +42,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen); int Platform_getMaxPid(void); -double Platform_setCPUValues(Meter* this, int cpu); +double Platform_setCPUValues(Meter* this, unsigned int cpu); void Platform_setMemoryValues(Meter* this); -- cgit v1.2.3