mirror of https://github.com/xzeldon/htop.git
Merge pull request #747 from natoscott/coverity
Coverity scan updates (minor)
This commit is contained in:
commit
3f727d4720
3
Action.c
3
Action.c
|
@ -174,7 +174,8 @@ static Htop_Reaction actionSetSortColumn(State* st) {
|
||||||
char* name = NULL;
|
char* name = NULL;
|
||||||
if (fields[i] >= LAST_PROCESSFIELD) {
|
if (fields[i] >= LAST_PROCESSFIELD) {
|
||||||
DynamicColumn* column = Hashtable_get(dynamicColumns, fields[i]);
|
DynamicColumn* column = Hashtable_get(dynamicColumns, fields[i]);
|
||||||
if (column)
|
if (!column)
|
||||||
|
continue;
|
||||||
name = xStrdup(column->caption ? column->caption : column->name);
|
name = xStrdup(column->caption ? column->caption : column->name);
|
||||||
} else {
|
} else {
|
||||||
name = String_trim(Process_fields[fields[i]].name);
|
name = String_trim(Process_fields[fields[i]].name);
|
||||||
|
|
|
@ -287,6 +287,9 @@ void PCPDynamicColumn_writeField(PCPDynamicColumn* this, const Process* proc, Ri
|
||||||
int PCPDynamicColumn_compareByKey(const PCPProcess* p1, const PCPProcess* p2, ProcessField key) {
|
int PCPDynamicColumn_compareByKey(const PCPProcess* p1, const PCPProcess* p2, ProcessField key) {
|
||||||
const PCPDynamicColumn* column = Hashtable_get(p1->super.processList->dynamicColumns, key);
|
const PCPDynamicColumn* column = Hashtable_get(p1->super.processList->dynamicColumns, key);
|
||||||
|
|
||||||
|
if (!column)
|
||||||
|
return -1;
|
||||||
|
|
||||||
size_t metric = column->id;
|
size_t metric = column->id;
|
||||||
unsigned int type = PCPMetric_type(metric);
|
unsigned int type = PCPMetric_type(metric);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ static void PCPProcessList_updateCPUcount(PCPProcessList* this) {
|
||||||
unsigned int cpus = Platform_getMaxCPU();
|
unsigned int cpus = Platform_getMaxCPU();
|
||||||
if (cpus == pl->existingCPUs)
|
if (cpus == pl->existingCPUs)
|
||||||
return;
|
return;
|
||||||
if (cpus <= 0)
|
if (cpus == 0)
|
||||||
cpus = pl->activeCPUs;
|
cpus = pl->activeCPUs;
|
||||||
if (cpus <= 1)
|
if (cpus <= 1)
|
||||||
cpus = pl->activeCPUs = 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)
|
if (pcp->ncpu)
|
||||||
return pcp->ncpu;
|
return pcp->ncpu;
|
||||||
|
|
||||||
pmAtomValue value;
|
pmAtomValue value;
|
||||||
if (PCPMetric_values(PCP_HINV_NCPU, &value, 1, PM_TYPE_32) != NULL)
|
if (PCPMetric_values(PCP_HINV_NCPU, &value, 1, PM_TYPE_U32) != NULL)
|
||||||
pcp->ncpu = value.l;
|
pcp->ncpu = value.ul;
|
||||||
else
|
else
|
||||||
pcp->ncpu = -1;
|
pcp->ncpu = 1;
|
||||||
return pcp->ncpu;
|
return pcp->ncpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ typedef struct Platform_ {
|
||||||
long long btime; /* boottime in seconds since the epoch */
|
long long btime; /* boottime in seconds since the epoch */
|
||||||
char* release; /* uname and distro from this context */
|
char* release; /* uname and distro from this context */
|
||||||
int pidmax; /* maximum platform process identifier */
|
int pidmax; /* maximum platform process identifier */
|
||||||
int ncpu; /* maximum processor count configured */
|
unsigned int ncpu; /* maximum processor count configured */
|
||||||
} Platform;
|
} Platform;
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ProcessField Platform_defaultFields[];
|
||||||
|
@ -79,7 +79,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
|
||||||
|
|
||||||
long long Platform_getBootTime(void);
|
long long Platform_getBootTime(void);
|
||||||
|
|
||||||
int Platform_getMaxCPU(void);
|
unsigned int Platform_getMaxCPU(void);
|
||||||
|
|
||||||
int Platform_getMaxPid(void);
|
int Platform_getMaxPid(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue