Use unsigned types for CPU counts and associated variables

This commit is contained in:
Christian Göttsche 2021-02-17 17:38:35 +01:00 committed by Benny Baumann
parent 53bcc5cbff
commit a11d01568c
32 changed files with 88 additions and 89 deletions

View File

@ -30,7 +30,7 @@ in the source distribution for its full text.
Affinity* Affinity_new(ProcessList* pl) {
Affinity* this = xCalloc(1, sizeof(Affinity));
this->size = 8;
this->cpus = xCalloc(this->size, sizeof(int));
this->cpus = xCalloc(this->size, sizeof(unsigned int));
this->pl = pl;
return this;
}
@ -40,10 +40,10 @@ void Affinity_delete(Affinity* this) {
free(this);
}
void Affinity_add(Affinity* this, int id) {
void Affinity_add(Affinity* this, unsigned int id) {
if (this->used == this->size) {
this->size *= 2;
this->cpus = xRealloc(this->cpus, sizeof(int) * this->size);
this->cpus = xRealloc(this->cpus, sizeof(unsigned int) * this->size);
}
this->cpus[this->used] = id;
this->used++;
@ -59,7 +59,7 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
if (ok) {
affinity = Affinity_new(pl);
if (hwloc_bitmap_last(cpuset) == -1) {
for (int i = 0; i < pl->cpuCount; i++) {
for (unsigned int i = 0; i < pl->cpuCount; i++) {
Affinity_add(affinity, i);
}
} else {
@ -76,7 +76,7 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
bool Affinity_set(Process* proc, Arg arg) {
Affinity* this = arg.v;
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
for (int i = 0; i < this->used; i++) {
for (unsigned int i = 0; i < this->used; i++) {
hwloc_bitmap_set(cpuset, this->cpus[i]);
}
bool ok = (hwloc_set_proc_cpubind(this->pl->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
@ -93,7 +93,7 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
return NULL;
Affinity* affinity = Affinity_new(pl);
for (int i = 0; i < pl->cpuCount; i++) {
for (unsigned int i = 0; i < pl->cpuCount; i++) {
if (CPU_ISSET(i, &cpuset)) {
Affinity_add(affinity, i);
}
@ -105,7 +105,7 @@ bool Affinity_set(Process* proc, Arg arg) {
Affinity* this = arg.v;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
for (int i = 0; i < this->used; i++) {
for (unsigned int i = 0; i < this->used; i++) {
CPU_SET(this->cpus[i], &cpuset);
}
bool ok = (sched_setaffinity(proc->pid, sizeof(unsigned long), &cpuset) == 0);

View File

@ -27,16 +27,16 @@ in the source distribution for its full text.
typedef struct Affinity_ {
ProcessList* pl;
int size;
int used;
int* cpus;
unsigned int size;
unsigned int used;
unsigned int* cpus;
} Affinity;
Affinity* Affinity_new(ProcessList* pl);
void Affinity_delete(Affinity* this);
void Affinity_add(Affinity* this, int id);
void Affinity_add(Affinity* this, unsigned int id);
#if defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY)

View File

@ -382,8 +382,8 @@ Panel* AffinityPanel_new(ProcessList* pl, const Affinity* affinity, int* width)
Panel_setHeader(super, "Use CPUs:");
int curCpu = 0;
for (int i = 0; i < pl->cpuCount; i++) {
unsigned int curCpu = 0;
for (unsigned int i = 0; i < pl->cpuCount; i++) {
char number[16];
xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
unsigned cpu_width = 4 + strlen(number);
@ -422,12 +422,12 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
Affinity* affinity = Affinity_new(pl);
#ifdef HAVE_LIBHWLOC
int i;
unsigned int i;
hwloc_bitmap_foreach_begin(i, this->workCpuset)
Affinity_add(affinity, i);
hwloc_bitmap_foreach_end();
#else
for (int i = 0; i < this->pl->cpuCount; i++) {
for (unsigned int i = 0; i < this->pl->cpuCount; i++) {
const MaskItem* item = (const MaskItem*)Vector_get(this->cpuids, i);
if (item->value) {
Affinity_add(affinity, item->cpu);

View File

@ -30,7 +30,7 @@ static void AvailableMetersPanel_delete(Object* object) {
free(this);
}
static inline void AvailableMetersPanel_addMeter(Header* header, Panel* panel, const MeterClass* type, int param, int column) {
static inline void AvailableMetersPanel_addMeter(Header* header, Panel* panel, const MeterClass* type, unsigned int param, int column) {
const Meter* meter = Header_addMeterByClass(header, type, param, column);
Panel_add(panel, (Object*) Meter_toListItem(meter, false));
Panel_setSelected(panel, Panel_size(panel) - 1);
@ -45,7 +45,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
if (!selected)
return IGNORED;
int param = selected->key & 0xff;
unsigned int param = selected->key & 0xff;
int type = selected->key >> 16;
HandlerResult result = IGNORED;
bool update = false;
@ -114,10 +114,10 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* heade
}
// Handle (&CPUMeter_class)
const MeterClass* type = &CPUMeter_class;
int cpus = pl->cpuCount;
unsigned int cpus = pl->cpuCount;
if (cpus > 1) {
Panel_add(super, (Object*) ListItem_new("CPU average", 0));
for (int i = 1; i <= cpus; i++) {
for (unsigned int i = 1; i <= cpus; i++) {
char buffer[50];
xSnprintf(buffer, sizeof(buffer), "%s %d", type->uiName, Settings_cpuId(this->settings, i - 1));
Panel_add(super, (Object*) ListItem_new(buffer, i));

View File

@ -35,23 +35,23 @@ static const int CPUMeter_attributes[] = {
};
typedef struct CPUMeterData_ {
int cpus;
unsigned int cpus;
Meter** meters;
} CPUMeterData;
static void CPUMeter_init(Meter* this) {
int cpu = this->param;
unsigned int cpu = this->param;
if (cpu == 0) {
Meter_setCaption(this, "Avg");
} else if (this->pl->cpuCount > 1) {
char caption[10];
xSnprintf(caption, sizeof(caption), "%3d", Settings_cpuId(this->pl->settings, cpu - 1));
xSnprintf(caption, sizeof(caption), "%3u", Settings_cpuId(this->pl->settings, cpu - 1));
Meter_setCaption(this, caption);
}
}
static void CPUMeter_updateValues(Meter* this) {
int cpu = this->param;
unsigned int cpu = this->param;
if (cpu > this->pl->cpuCount) {
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "absent");
for (uint8_t i = 0; i < this->curItems; i++)
@ -168,7 +168,7 @@ static void CPUMeter_display(const Object* cast, RichString* out) {
static void AllCPUsMeter_getRange(const Meter* this, int* start, int* count) {
const CPUMeterData* data = this->meterData;
int cpus = data->cpus;
unsigned int cpus = data->cpus;
switch(Meter_name(this)[0]) {
default:
case 'A': // All
@ -196,7 +196,7 @@ static void AllCPUsMeter_updateValues(Meter* this) {
}
static void CPUMeterCommonInit(Meter* this, int ncol) {
int cpus = this->pl->cpuCount;
unsigned int cpus = this->pl->cpuCount;
CPUMeterData* data = this->meterData;
if (!data) {
data = this->meterData = xMalloc(sizeof(CPUMeterData));

View File

@ -71,7 +71,7 @@ void Header_writeBackToSettings(const Header* this) {
const Meter* meter = (Meter*) Vector_get(vec, i);
char* name;
if (meter->param) {
xAsprintf(&name, "%s(%d)", As_Meter(meter)->name, meter->param);
xAsprintf(&name, "%s(%u)", As_Meter(meter)->name, meter->param);
} else {
xAsprintf(&name, "%s", As_Meter(meter)->name);
}
@ -85,9 +85,9 @@ MeterModeId Header_addMeterByName(Header* this, const char* name, int column) {
Vector* meters = this->columns[column];
char* paren = strchr(name, '(');
int param = 0;
unsigned int param = 0;
if (paren) {
int ok = sscanf(paren, "(%10d)", &param);
int ok = sscanf(paren, "(%10u)", &param);
if (!ok)
param = 0;
*paren = '\0';
@ -118,7 +118,7 @@ void Header_setMode(Header* this, int i, MeterModeId mode, int column) {
Meter_setMode(meter, mode);
}
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, int param, int column) {
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, unsigned int param, int column) {
Vector* meters = this->columns[column];
Meter* meter = Meter_new(this->pl, param, type);

View File

@ -35,7 +35,7 @@ MeterModeId Header_addMeterByName(Header* this, const char* name, int column);
void Header_setMode(Header* this, int i, MeterModeId mode, int column);
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, int param, int column);
Meter* Header_addMeterByClass(Header* this, const MeterClass* type, unsigned int param, int column);
int Header_size(const Header* this, int column);

View File

@ -32,7 +32,7 @@ const MeterClass Meter_class = {
}
};
Meter* Meter_new(const struct ProcessList_* pl, int param, const MeterClass* type) {
Meter* Meter_new(const struct ProcessList_* pl, unsigned int param, const MeterClass* type) {
Meter* this = xCalloc(1, sizeof(Meter));
Object_setClass(this, type);
this->h = 1;
@ -140,7 +140,7 @@ ListItem* Meter_toListItem(const Meter* this, bool moving) {
}
char number[10];
if (this->param > 0) {
xSnprintf(number, sizeof(number), " %d", this->param);
xSnprintf(number, sizeof(number), " %u", this->param);
} else {
number[0] = '\0';
}

View File

@ -95,7 +95,7 @@ struct Meter_ {
char* caption;
int mode;
int param;
unsigned int param;
GraphData* drawData;
int h;
int columnWidthCount; /*<< only used internally by the Header */
@ -125,7 +125,7 @@ typedef enum {
extern const MeterClass Meter_class;
Meter* Meter_new(const ProcessList* pl, int param, const MeterClass* type);
Meter* Meter_new(const ProcessList* pl, unsigned int param, const MeterClass* type);
int Meter_humanUnit(char* buffer, unsigned long int value, size_t size);

View File

@ -59,10 +59,10 @@ typedef struct ProcessList_ {
bool topologyOk;
#endif
int totalTasks;
int runningTasks;
int userlandThreads;
int kernelThreads;
unsigned int totalTasks;
unsigned int runningTasks;
unsigned int userlandThreads;
unsigned int kernelThreads;
memory_t totalMem;
memory_t usedMem;
@ -75,7 +75,7 @@ typedef struct ProcessList_ {
memory_t usedSwap;
memory_t cachedSwap;
int cpuCount;
unsigned int cpuCount;
time_t scanTs;
} ProcessList;

View File

@ -54,7 +54,7 @@ static void Settings_readMeterModes(Settings* this, const char* line, int column
this->columns[column].modes = modes;
}
static void Settings_defaultMeters(Settings* this, int initialCpuCount) {
static void Settings_defaultMeters(Settings* this, unsigned int initialCpuCount) {
int sizes[] = { 3, 3 };
if (initialCpuCount > 4 && initialCpuCount <= 128) {
sizes[1]++;
@ -125,7 +125,7 @@ static void readFields(ProcessField* fields, uint32_t* flags, const char* line)
String_freeArray(ids);
}
static bool Settings_read(Settings* this, const char* fileName, int initialCpuCount) {
static bool Settings_read(Settings* this, const char* fileName, unsigned int initialCpuCount) {
FILE* fd = fopen(fileName, "r");
if (!fd)
return false;
@ -344,7 +344,7 @@ int Settings_write(const Settings* this) {
return r;
}
Settings* Settings_new(int initialCpuCount) {
Settings* Settings_new(unsigned int initialCpuCount) {
Settings* this = xCalloc(1, sizeof(Settings));
this->sortKey = PERCENT_CPU;

View File

@ -89,7 +89,7 @@ void Settings_delete(Settings* this);
int Settings_write(const Settings* this);
Settings* Settings_new(int initialCpuCount);
Settings* Settings_new(unsigned int initialCpuCount);
void Settings_invertSortOrder(Settings* this);

View File

@ -184,7 +184,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
/* Get the time difference */
dpl->global_diff = 0;
for (int i = 0; i < dpl->super.cpuCount; ++i) {
for (unsigned int i = 0; i < dpl->super.cpuCount; ++i) {
for (size_t j = 0; j < CPU_STATE_MAX; ++j) {
dpl->global_diff += dpl->curr_load[i].cpu_ticks[j] - dpl->prev_load[i].cpu_ticks[j];
}

View File

@ -182,12 +182,12 @@ int Platform_getMaxPid() {
static double Platform_setCPUAverageValues(Meter* mtr) {
const ProcessList* dpl = mtr->pl;
int cpus = dpl->cpuCount;
unsigned int cpus = dpl->cpuCount;
double sumNice = 0.0;
double sumNormal = 0.0;
double sumKernel = 0.0;
double sumPercent = 0.0;
for (int i = 1; i <= cpus; i++) {
for (unsigned int i = 1; i <= cpus; i++) {
sumPercent += Platform_setCPUValues(mtr, i);
sumNice += mtr->values[CPU_METER_NICE];
sumNormal += mtr->values[CPU_METER_NORMAL];
@ -199,7 +199,7 @@ static double Platform_setCPUAverageValues(Meter* mtr) {
return sumPercent / cpus;
}
double Platform_setCPUValues(Meter* mtr, int cpu) {
double Platform_setCPUValues(Meter* mtr, unsigned int cpu) {
if (cpu == 0) {
return Platform_setCPUAverageValues(mtr);

View File

@ -47,7 +47,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
int Platform_getMaxPid(void);
double Platform_setCPUValues(Meter* mtr, int cpu);
double Platform_setCPUValues(Meter* mtr, unsigned int cpu);
void Platform_setMemoryValues(Meter* mtr);

View File

@ -139,8 +139,8 @@ void ProcessList_delete(ProcessList* this) {
static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) {
const DragonFlyBSDProcessList* dfpl = (DragonFlyBSDProcessList*) 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);
@ -167,7 +167,7 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) {
sysctl(MIB_kern_cp_times, 2, dfpl->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 = dfpl->cp_time_n;

View File

@ -157,9 +157,9 @@ int Platform_getMaxPid() {
return maxPid;
}
double Platform_setCPUValues(Meter* this, int cpu) {
double Platform_setCPUValues(Meter* this, unsigned int cpu) {
const DragonFlyBSDProcessList* fpl = (const DragonFlyBSDProcessList*) this->pl;
int cpus = this->pl->cpuCount;
unsigned int cpus = this->pl->cpuCount;
const CPUData* cpuData;
if (cpus == 1) {

View File

@ -41,7 +41,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);

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -166,7 +166,7 @@ static void LinuxProcessList_initNetlinkSocket(LinuxProcessList* this) {
static void LinuxProcessList_updateCPUcount(ProcessList* super, FILE* stream) {
LinuxProcessList* this = (LinuxProcessList*) super;
int cpus = 0;
unsigned int cpus = 0;
char buffer[PROC_LINE_LENGTH + 1];
while (fgets(buffer, sizeof(buffer), stream)) {
if (String_startsWith(buffer, "cpu")) {
@ -1269,7 +1269,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
return false;
}
int cpus = pl->cpuCount;
unsigned int cpus = pl->cpuCount;
bool hideKernelThreads = settings->hideKernelThreads;
bool hideUserlandThreads = settings->hideUserlandThreads;
while ((entry = readdir(dir)) != NULL) {
@ -1765,8 +1765,8 @@ static inline double LinuxProcessList_scanCPUTime(ProcessList* super) {
rewind(file);
int cpus = super->cpuCount;
for (int i = 0; i <= cpus; i++) {
unsigned int cpus = super->cpuCount;
for (unsigned int i = 0; i <= cpus; i++) {
char buffer[PROC_LINE_LENGTH + 1];
unsigned long long int usertime, nicetime, systemtime, idletime;
unsigned long long int ioWait = 0, irq = 0, softIrq = 0, steal = 0, guest = 0, guestnice = 0;
@ -1780,8 +1780,8 @@ static inline double LinuxProcessList_scanCPUTime(ProcessList* super) {
if (i == 0) {
(void) sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
} else {
int cpuid;
(void) sscanf(buffer, "cpu%4d %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
unsigned int cpuid;
(void) sscanf(buffer, "cpu%4u %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
assert(cpuid == i - 1);
}
// Guest time is already accounted in usertime
@ -1841,7 +1841,7 @@ static inline double LinuxProcessList_scanCPUTime(ProcessList* super) {
}
static int scanCPUFreqencyFromSysCPUFreq(LinuxProcessList* this) {
int cpus = this->super.cpuCount;
unsigned int cpus = this->super.cpuCount;
int numCPUsWithFrequency = 0;
unsigned long totalFrequency = 0;
@ -1859,9 +1859,9 @@ static int scanCPUFreqencyFromSysCPUFreq(LinuxProcessList* this) {
return -1;
}
for (int i = 0; i < cpus; ++i) {
for (unsigned int i = 0; i < cpus; ++i) {
char pathBuffer[64];
xSnprintf(pathBuffer, sizeof(pathBuffer), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", i);
xSnprintf(pathBuffer, sizeof(pathBuffer), "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq", i);
struct timespec start;
if (i == 0)
@ -1905,7 +1905,7 @@ static void scanCPUFreqencyFromCPUinfo(LinuxProcessList* this) {
if (file == NULL)
return;
int cpus = this->super.cpuCount;
unsigned int cpus = this->super.cpuCount;
int numCPUsWithFrequency = 0;
double totalFrequency = 0;
int cpuid = -1;
@ -1928,7 +1928,7 @@ static void scanCPUFreqencyFromCPUinfo(LinuxProcessList* this) {
(sscanf(buffer, "clock : %lfMHz", &frequency) == 1) ||
(sscanf(buffer, "clock: %lfMHz", &frequency) == 1)
) {
if (cpuid < 0 || cpuid > (cpus - 1)) {
if (cpuid < 0 || (unsigned int)cpuid > (cpus - 1)) {
continue;
}
@ -1951,10 +1951,9 @@ static void scanCPUFreqencyFromCPUinfo(LinuxProcessList* this) {
}
static void LinuxProcessList_scanCPUFrequency(LinuxProcessList* this) {
int cpus = this->super.cpuCount;
assert(cpus > 0);
unsigned int cpus = this->super.cpuCount;
for (int i = 0; i <= cpus; i++) {
for (unsigned int i = 0; i <= cpus; i++) {
this->cpus[i].frequency = NAN;
}

View File

@ -236,7 +236,7 @@ int Platform_getMaxPid() {
return maxPid;
}
double Platform_setCPUValues(Meter* this, int cpu) {
double Platform_setCPUValues(Meter* this, unsigned int cpu) {
const LinuxProcessList* pl = (const LinuxProcessList*) this->pl;
const CPUData* cpuData = &(pl->cpus[cpu]);
double total = (double) ( cpuData->totalPeriod == 0 ? 1 : cpuData->totalPeriod);

View File

@ -48,7 +48,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);

View File

@ -63,7 +63,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
CRT_fatalError("pagesize sysconf call failed");
pageSizeKB = pageSize / ONE_K;
for (int i = 0; i <= pl->cpuCount; i++) {
for (unsigned int i = 0; i <= pl->cpuCount; i++) {
CPUData* d = opl->cpus + i;
d->totalTime = 1;
d->totalPeriod = 1;
@ -313,7 +313,7 @@ static void OpenBSDProcessList_scanCPUTime(OpenBSDProcessList* this) {
u_int64_t kernelTimes[CPUSTATES] = {0};
u_int64_t avg[CPUSTATES] = {0};
for (int i = 0; i < this->super.cpuCount; i++) {
for (unsigned int i = 0; i < this->super.cpuCount; i++) {
getKernelCPUTimes(i, kernelTimes);
CPUData* cpu = this->cpus + i + 1;
kernelCPUTimesToHtop(kernelTimes, cpu);

View File

@ -166,7 +166,7 @@ int Platform_getMaxPid() {
return 99999;
}
double Platform_setCPUValues(Meter* this, int cpu) {
double Platform_setCPUValues(Meter* this, unsigned int cpu) {
const OpenBSDProcessList* pl = (const OpenBSDProcessList*) this->pl;
const CPUData* cpuData = &(pl->cpus[cpu]);
double total = cpuData->totalPeriod == 0 ? 1 : cpuData->totalPeriod;

View File

@ -44,7 +44,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);

View File

@ -177,9 +177,9 @@ int Platform_getMaxPid() {
return vproc;
}
double Platform_setCPUValues(Meter* this, int cpu) {
double Platform_setCPUValues(Meter* this, unsigned int cpu) {
const SolarisProcessList* spl = (const SolarisProcessList*) this->pl;
int cpus = this->pl->cpuCount;
unsigned int cpus = this->pl->cpuCount;
const CPUData* cpuData = NULL;
if (cpus == 1) {

View File

@ -59,7 +59,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);

View File

@ -69,7 +69,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
const SolarisProcessList* spl = (SolarisProcessList*) pl;
int cpus = pl->cpuCount;
unsigned int cpus = pl->cpuCount;
kstat_t* cpuinfo = NULL;
kstat_named_t* idletime = NULL;
kstat_named_t* intrtime = NULL;
@ -91,7 +91,7 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
}
// Calculate per-CPU statistics first
for (int i = 0; i < cpus; i++) {
for (unsigned int i = 0; i < cpus; i++) {
if (spl->kd != NULL) {
if ((cpuinfo = kstat_lookup(spl->kd, "cpu", i, "sys")) != NULL) {
if (kstat_read(spl->kd, cpuinfo, NULL) != -1) {

View File

@ -93,7 +93,7 @@ int Platform_getMaxPid() {
return 1;
}
double Platform_setCPUValues(Meter* this, int cpu) {
double Platform_setCPUValues(Meter* this, unsigned int cpu) {
(void) cpu;
double* v = this->values;

View File

@ -37,7 +37,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);