mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-24 15:15:44 +00:00
PCP: ensure unsigned types used throughout CPU count detection
This cannot be negative in these code locations, but for the purposes of static checking like Coverity scan make it clear and used the same unsigned type as ProcessList.h for the CPU count variable (matching PL activeCPUs and existingCPUs).
This commit is contained in:
parent
c401ac3a98
commit
c7f634ec21
@ -35,7 +35,7 @@ static void PCPProcessList_updateCPUcount(PCPProcessList* this) {
|
||||
unsigned int cpus = Platform_getMaxCPU();
|
||||
if (cpus == pl->existingCPUs)
|
||||
return;
|
||||
if (cpus <= 0)
|
||||
if (cpus == 0)
|
||||
cpus = pl->activeCPUs;
|
||||
if (cpus <= 1)
|
||||
cpus = pl->activeCPUs = 1;
|
||||
|
@ -396,15 +396,15 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
|
||||
}
|
||||
}
|
||||
|
||||
int Platform_getMaxCPU(void) {
|
||||
unsigned int Platform_getMaxCPU(void) {
|
||||
if (pcp->ncpu)
|
||||
return pcp->ncpu;
|
||||
|
||||
pmAtomValue value;
|
||||
if (PCPMetric_values(PCP_HINV_NCPU, &value, 1, PM_TYPE_32) != NULL)
|
||||
pcp->ncpu = value.l;
|
||||
if (PCPMetric_values(PCP_HINV_NCPU, &value, 1, PM_TYPE_U32) != NULL)
|
||||
pcp->ncpu = value.ul;
|
||||
else
|
||||
pcp->ncpu = -1;
|
||||
pcp->ncpu = 1;
|
||||
return pcp->ncpu;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef struct Platform_ {
|
||||
long long btime; /* boottime in seconds since the epoch */
|
||||
char* release; /* uname and distro from this context */
|
||||
int pidmax; /* maximum platform process identifier */
|
||||
int ncpu; /* maximum processor count configured */
|
||||
unsigned int ncpu; /* maximum processor count configured */
|
||||
} Platform;
|
||||
|
||||
extern ProcessField Platform_defaultFields[];
|
||||
@ -79,7 +79,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
|
||||
|
||||
long long Platform_getBootTime(void);
|
||||
|
||||
int Platform_getMaxCPU(void);
|
||||
unsigned int Platform_getMaxCPU(void);
|
||||
|
||||
int Platform_getMaxPid(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user