Spacing around operators

This commit is contained in:
Benny Baumann
2020-10-31 23:28:02 +01:00
parent b23f8235e2
commit 61e14d4bb2
74 changed files with 784 additions and 765 deletions

View File

@ -52,7 +52,7 @@ bool Process_isThread(const Process* this) {
return false;
}
char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset) {
char* DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset) {
/* This function is from the old Mac version of htop. Originally from ps? */
int mib[3], argmax, nargs, c = 0;
size_t size;
@ -68,7 +68,7 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset) {
}
/* Allocate space for the arguments. */
procargs = ( char * ) xMalloc( argmax );
procargs = (char*)xMalloc(argmax);
if ( procargs == NULL ) {
goto ERROR_A;
}
@ -195,8 +195,8 @@ ERROR_A:
return retval;
}
void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool exists) {
struct extern_proc *ep = &ps->kp_proc;
void DarwinProcess_setFromKInfoProc(Process* proc, struct kinfo_proc* ps, bool exists) {
struct extern_proc* ep = &ps->kp_proc;
/* UNSET HERE :
*
@ -241,7 +241,7 @@ void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool e
proc->updated = true;
}
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList *dpl) {
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessList* dpl) {
struct proc_taskinfo pti;
if (sizeof(pti) == proc_pidinfo(proc->super.pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti))) {
@ -280,7 +280,7 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
* Based on: http://stackoverflow.com/questions/6788274/ios-mac-cpu-usage-for-thread
* and https://github.com/max-horvath/htop-osx/blob/e86692e869e30b0bc7264b3675d2a4014866ef46/ProcessList.c
*/
void DarwinProcess_scanThreads(DarwinProcess *dp) {
void DarwinProcess_scanThreads(DarwinProcess* dp) {
Process* proc = (Process*) dp;
kern_return_t ret;

View File

@ -28,17 +28,17 @@ void Process_delete(Object* cast);
bool Process_isThread(const Process* this);
char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset);
char* DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset);
void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool exists);
void DarwinProcess_setFromKInfoProc(Process* proc, struct kinfo_proc* ps, bool exists);
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList *dpl);
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessList* dpl);
/*
* Scan threads for process state information.
* Based on: http://stackoverflow.com/questions/6788274/ios-mac-cpu-usage-for-thread
* and https://github.com/max-horvath/htop-osx/blob/e86692e869e30b0bc7264b3675d2a4014866ef46/ProcessList.c
*/
void DarwinProcess_scanThreads(DarwinProcess *dp);
void DarwinProcess_scanThreads(DarwinProcess* dp);
#endif

View File

@ -27,7 +27,7 @@ struct kern {
short int version[3];
};
void GetKernelVersion(struct kern *k) {
void GetKernelVersion(struct kern* k) {
static short int version_[3] = {0};
if (!version_[0]) {
// just in case it fails someday
@ -64,7 +64,7 @@ int CompareKernelVersion(short int major, short int minor, short int component)
return 0;
}
void ProcessList_getHostInfo(host_basic_info_data_t *p) {
void ProcessList_getHostInfo(host_basic_info_data_t* p) {
mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT;
if (0 != host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)p, &info_size)) {
@ -72,7 +72,7 @@ void ProcessList_getHostInfo(host_basic_info_data_t *p) {
}
}
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p) {
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t* p) {
if (NULL != p && NULL != *p) {
if (0 != munmap(*p, vm_page_size)) {
CRT_fatalError("Unable to free old CPU load information\n");
@ -81,7 +81,7 @@ void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p) {
}
}
unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t *p) {
unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t* p) {
mach_msg_type_number_t info_size = sizeof(processor_cpu_load_info_t);
unsigned cpu_count;
@ -101,9 +101,9 @@ void ProcessList_getVMStats(vm_statistics_t p) {
}
}
struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) {
struct kinfo_proc* ProcessList_getKInfoProcs(size_t* count) {
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
struct kinfo_proc *processes = NULL;
struct kinfo_proc* processes = NULL;
/* Note the two calls to sysctl(). One to get length and one to get the
* data. This -does- mean that the second call could end up with a missing

View File

@ -9,7 +9,7 @@ in the source distribution for its full text.
struct kern;
void GetKernelVersion(struct kern *k);
void GetKernelVersion(struct kern* k);
/* compare the given os version with the one installed returns:
0 if equals the installed version
@ -37,15 +37,15 @@ typedef struct DarwinProcessList_ {
ZfsArcStats zfs;
} DarwinProcessList;
void ProcessList_getHostInfo(host_basic_info_data_t *p);
void ProcessList_getHostInfo(host_basic_info_data_t* p);
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p);
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t* p);
unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t *p);
unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t* p);
void ProcessList_getVMStats(vm_statistics_t p);
struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count);
struct kinfo_proc* ProcessList_getKInfoProcs(size_t* count);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);

View File

@ -176,7 +176,7 @@ ProcessPidColumn Process_pidColumns[] = {
};
static double Platform_setCPUAverageValues(Meter* mtr) {
const ProcessList *dpl = mtr->pl;
const ProcessList* dpl = mtr->pl;
int cpus = dpl->cpuCount;
double sumNice = 0.0;
double sumNormal = 0.0;
@ -200,9 +200,9 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
return Platform_setCPUAverageValues(mtr);
}
const DarwinProcessList *dpl = (const DarwinProcessList *)mtr->pl;
const processor_cpu_load_info_t prev = &dpl->prev_load[cpu-1];
const processor_cpu_load_info_t curr = &dpl->curr_load[cpu-1];
const DarwinProcessList* dpl = (const DarwinProcessList*)mtr->pl;
const processor_cpu_load_info_t prev = &dpl->prev_load[cpu - 1];
const processor_cpu_load_info_t curr = &dpl->curr_load[cpu - 1];
double total = 0;
/* Take the sums */
@ -228,7 +228,7 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
}
void Platform_setMemoryValues(Meter* mtr) {
const DarwinProcessList *dpl = (const DarwinProcessList *)mtr->pl;
const DarwinProcessList* dpl = (const DarwinProcessList*)mtr->pl;
const struct vm_statistics* vm = &dpl->vm_stats;
double page_K = (double)vm_page_size / (double)1024;
@ -283,14 +283,14 @@ char* Platform_getProcessEnv(pid_t pid) {
p += sizeof(int);
// skip exe
p = strchr(p, 0)+1;
p = strchr(p, 0) + 1;
// skip padding
while (!*p && p < endp)
++p;
// skip argv
for (; argc-- && p < endp; p = strrchr(p, 0)+1)
for (; argc-- && p < endp; p = strrchr(p, 0) + 1)
;
// skip padding
@ -298,10 +298,10 @@ char* Platform_getProcessEnv(pid_t pid) {
++p;
size_t size = endp - p;
env = xMalloc(size+2);
env = xMalloc(size + 2);
memcpy(env, p, size);
env[size] = 0;
env[size+1] = 0;
env[size + 1] = 0;
}
}
free(buf);
@ -317,10 +317,10 @@ bool Platform_getDiskIO(DiskIOData* data) {
return false;
}
bool Platform_getNetworkIO(unsigned long int *bytesReceived,
unsigned long int *packetsReceived,
unsigned long int *bytesTransmitted,
unsigned long int *packetsTransmitted) {
bool Platform_getNetworkIO(unsigned long int* bytesReceived,
unsigned long int* packetsReceived,
unsigned long int* bytesTransmitted,
unsigned long int* packetsTransmitted) {
// TODO
*bytesReceived = 0;
*packetsReceived = 0;

View File

@ -51,9 +51,9 @@ char* Platform_getProcessEnv(pid_t pid);
bool Platform_getDiskIO(DiskIOData* data);
bool Platform_getNetworkIO(unsigned long int *bytesReceived,
unsigned long int *packetsReceived,
unsigned long int *bytesTransmitted,
unsigned long int *packetsTransmitted);
bool Platform_getNetworkIO(unsigned long int* bytesReceived,
unsigned long int* packetsReceived,
unsigned long int* bytesTransmitted,
unsigned long int* packetsTransmitted);
#endif