mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Remove unnecessary include files from PCPDynamicMeter.c
Also resolve a few unintended style guide transgressions in the PCP platform code.
This commit is contained in:
parent
9f667f2c74
commit
e7aaf79166
@ -10,9 +10,6 @@ in the source distribution for its full text.
|
||||
#include "pcp/PCPDynamicMeter.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Object.h"
|
||||
#include "Platform.h"
|
||||
@ -51,8 +48,8 @@ static PCPDynamicMetric* PCPDynamicMeter_lookupMetric(PCPDynamicMeters* meters,
|
||||
return metric;
|
||||
}
|
||||
|
||||
static void PCPDynamicMeter_parseMetric(PCPDynamicMeters* meters, PCPDynamicMeter* meter, const char *path, unsigned int line, char* key, char* value) {
|
||||
PCPDynamicMetric *metric;
|
||||
static void PCPDynamicMeter_parseMetric(PCPDynamicMeters* meters, PCPDynamicMeter* meter, const char* path, unsigned int line, char* key, char* value) {
|
||||
PCPDynamicMetric* metric;
|
||||
char* p;
|
||||
|
||||
if ((p = strchr(key, '.')) == NULL)
|
||||
@ -109,7 +106,7 @@ static void PCPDynamicMeter_parseMetric(PCPDynamicMeters* meters, PCPDynamicMete
|
||||
}
|
||||
|
||||
// Ensure a valid name for use in a PCP metric name and in htoprc
|
||||
static void PCPDynamicMeter_validateMeterName(char* key, const char *path, unsigned int line) {
|
||||
static void PCPDynamicMeter_validateMeterName(char* key, const char* path, unsigned int line) {
|
||||
char* p = key;
|
||||
char* end = strrchr(key, ']');
|
||||
|
||||
@ -219,12 +216,12 @@ static void PCPDynamicMeter_scanDir(PCPDynamicMeters* meters, char* path) {
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
struct dirent *dirent;
|
||||
struct dirent* dirent;
|
||||
while ((dirent = readdir(dir)) != NULL) {
|
||||
if (dirent->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
char *file = String_cat(path, dirent->d_name);
|
||||
char* file = String_cat(path, dirent->d_name);
|
||||
PCPDynamicMeter_parseFile(meters, file);
|
||||
free(file);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
DynamicMeter super;
|
||||
PCPDynamicMetric *metrics;
|
||||
PCPDynamicMetric* metrics;
|
||||
unsigned int totalMetrics;
|
||||
} PCPDynamicMeter;
|
||||
|
||||
|
@ -119,7 +119,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *Platform_metricNames[] = {
|
||||
static const char* Platform_metricNames[] = {
|
||||
[PCP_CONTROL_THREADS] = "proc.control.perclient.threads",
|
||||
|
||||
[PCP_HINV_NCPU] = "hinv.ncpu",
|
||||
@ -251,7 +251,7 @@ const pmDesc* Metric_desc(Metric metric) {
|
||||
return &pcp->descs[metric];
|
||||
}
|
||||
|
||||
pmAtomValue* Metric_values(Metric metric, pmAtomValue *atom, int count, int type) {
|
||||
pmAtomValue* Metric_values(Metric metric, pmAtomValue* atom, int count, int type) {
|
||||
if (pcp->result == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -264,7 +264,7 @@ pmAtomValue* Metric_values(Metric metric, pmAtomValue *atom, int count, int type
|
||||
for (int i = 0; i < vset->numval; i++) {
|
||||
if (i == count)
|
||||
break;
|
||||
const pmValue *value = &vset->vlist[i];
|
||||
const pmValue* value = &vset->vlist[i];
|
||||
int sts = pmExtractValue(vset->valfmt, value, desc->type, &atom[i], type);
|
||||
if (sts < 0) {
|
||||
if (pmDebugOptions.appl0)
|
||||
@ -296,11 +296,11 @@ int Metric_instanceOffset(Metric metric, int inst) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pmAtomValue *Metric_extract(Metric metric, int inst, int offset, pmValueSet *vset, pmAtomValue *atom, int type) {
|
||||
static pmAtomValue* Metric_extract(Metric metric, int inst, int offset, pmValueSet* vset, pmAtomValue* atom, int type) {
|
||||
|
||||
/* extract value (using requested type) of given metric instance */
|
||||
const pmDesc* desc = &pcp->descs[metric];
|
||||
const pmValue *value = &vset->vlist[offset];
|
||||
const pmValue* value = &vset->vlist[offset];
|
||||
int sts = pmExtractValue(vset->valfmt, value, desc->type, atom, type);
|
||||
if (sts < 0) {
|
||||
if (pmDebugOptions.appl0)
|
||||
@ -311,7 +311,7 @@ static pmAtomValue *Metric_extract(Metric metric, int inst, int offset, pmValueS
|
||||
return atom;
|
||||
}
|
||||
|
||||
pmAtomValue *Metric_instance(Metric metric, int inst, int offset, pmAtomValue *atom, int type) {
|
||||
pmAtomValue* Metric_instance(Metric metric, int inst, int offset, pmAtomValue* atom, int type) {
|
||||
|
||||
pmValueSet* vset = pcp->result->vset[metric];
|
||||
if (!vset || vset->numval <= 0)
|
||||
@ -381,7 +381,7 @@ void Metric_enableThreads(void) {
|
||||
pmFreeResult(result);
|
||||
}
|
||||
|
||||
bool Metric_fetch(struct timeval *timestamp) {
|
||||
bool Metric_fetch(struct timeval* timestamp) {
|
||||
if (pcp->result) {
|
||||
pmFreeResult(pcp->result);
|
||||
pcp->result = NULL;
|
||||
@ -398,7 +398,7 @@ bool Metric_fetch(struct timeval *timestamp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int Platform_addMetric(Metric id, const char *name) {
|
||||
int Platform_addMetric(Metric id, const char* name) {
|
||||
unsigned int i = (unsigned int)id;
|
||||
|
||||
if (i >= PCP_METRIC_COUNT && i >= pcp->totalMetrics) {
|
||||
@ -665,7 +665,7 @@ void Platform_setZramValues(Meter* this) {
|
||||
return;
|
||||
}
|
||||
|
||||
pmAtomValue *values = xCalloc(count, sizeof(pmAtomValue));
|
||||
pmAtomValue* values = xCalloc(count, sizeof(pmAtomValue));
|
||||
ZramStats stats = {0};
|
||||
|
||||
if (Metric_values(PCP_ZRAM_CAPACITY, values, count, PM_TYPE_U64)) {
|
||||
@ -847,7 +847,7 @@ void Platform_longOptionsUsage(ATTR_UNUSED const char* name) {
|
||||
|
||||
bool Platform_getLongOption(int opt, ATTR_UNUSED int argc, char** argv) {
|
||||
/* libpcp export without a header definition */
|
||||
extern void __pmAddOptHost(pmOptions *, char *);
|
||||
extern void __pmAddOptHost(pmOptions*, char*);
|
||||
|
||||
switch (opt) {
|
||||
case PLATFORM_LONGOPT_HOST: /* --host=HOSTSPEC */
|
||||
|
@ -77,13 +77,13 @@ char* Platform_getInodeFilename(pid_t pid, ino_t inode);
|
||||
|
||||
FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid);
|
||||
|
||||
void Platform_getPressureStall(const char *file, bool some, double* ten, double* sixty, double* threehundred);
|
||||
void Platform_getPressureStall(const char* file, bool some, double* ten, double* sixty, double* threehundred);
|
||||
|
||||
bool Platform_getDiskIO(DiskIOData* data);
|
||||
|
||||
bool Platform_getNetworkIO(NetworkIOData* data);
|
||||
|
||||
void Platform_getBattery(double *percent, ACPresence *isOnAC);
|
||||
void Platform_getBattery(double* percent, ACPresence* isOnAC);
|
||||
|
||||
void Platform_getHostname(char* buffer, size_t size);
|
||||
|
||||
@ -242,11 +242,11 @@ bool Metric_enabled(Metric metric);
|
||||
|
||||
void Metric_enableThreads(void);
|
||||
|
||||
bool Metric_fetch(struct timeval *timestamp);
|
||||
bool Metric_fetch(struct timeval* timestamp);
|
||||
|
||||
bool Metric_iterate(Metric metric, int* instp, int* offsetp);
|
||||
|
||||
pmAtomValue* Metric_values(Metric metric, pmAtomValue *atom, int count, int type);
|
||||
pmAtomValue* Metric_values(Metric metric, pmAtomValue* atom, int count, int type);
|
||||
|
||||
const pmDesc* Metric_desc(Metric metric);
|
||||
|
||||
@ -254,9 +254,9 @@ int Metric_instanceCount(Metric metric);
|
||||
|
||||
int Metric_instanceOffset(Metric metric, int inst);
|
||||
|
||||
pmAtomValue* Metric_instance(Metric metric, int inst, int offset, pmAtomValue *atom, int type);
|
||||
pmAtomValue* Metric_instance(Metric metric, int inst, int offset, pmAtomValue* atom, int type);
|
||||
|
||||
int Platform_addMetric(Metric id, const char *name);
|
||||
int Platform_addMetric(Metric id, const char* name);
|
||||
|
||||
void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user