Spacing after keywords (if)

This commit is contained in:
Benny Baumann 2020-10-31 20:52:20 +01:00
parent 0a51eae11f
commit 374edb9ed5
16 changed files with 52 additions and 52 deletions

4
CRT.c
View File

@ -770,7 +770,7 @@ void CRT_handleSIGSEGV(int signal) {
);
const char* signal_str = strsignal(signal);
if(!signal_str) {
if (!signal_str) {
signal_str = "unknown reason";
}
fprintf(stderr,
@ -821,7 +821,7 @@ void CRT_handleSIGSEGV(int signal) {
);
/* Call old sigsegv handler; may be default exit or third party one (e.g. ASAN) */
if(sigaction (signal, &old_sig_handler[signal], NULL) < 0) {
if (sigaction (signal, &old_sig_handler[signal], NULL) < 0) {
/* This avoids an infinite loop in case the handler could not be reset. */
fprintf(stderr,
"!!! Chained handler could not be restored. Forcing exit.\n"

View File

@ -325,7 +325,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
case PID: xSnprintf(buffer, n, Process_pidFormat, this->pid); break;
case PPID: xSnprintf(buffer, n, Process_pidFormat, this->ppid); break;
case PRIORITY: {
if(this->priority <= -100)
if (this->priority <= -100)
xSnprintf(buffer, n, " RT ");
else
xSnprintf(buffer, n, "%3ld ", this->priority);

View File

@ -81,10 +81,10 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
if (pipe(fdpair) == -1)
return false;
if(fcntl(fdpair[0], F_SETFL, O_NONBLOCK) < 0)
if (fcntl(fdpair[0], F_SETFL, O_NONBLOCK) < 0)
goto err;
if(fcntl(fdpair[1], F_SETFL, O_NONBLOCK) < 0)
if (fcntl(fdpair[1], F_SETFL, O_NONBLOCK) < 0)
goto err;
pid_t child = fork();

View File

@ -201,7 +201,7 @@ void Vector_insert(Vector* this, int idx, void* data_) {
Vector_checkArraySize(this);
//assert(this->array[this->items] == NULL);
if(idx < this->items) {
if (idx < this->items) {
memmove(&this->array[idx + 1], &this->array[idx], (this->items - idx) * sizeof(this->array[0]));
}
this->array[idx] = data;
@ -215,7 +215,7 @@ Object* Vector_take(Vector* this, int idx) {
Object* removed = this->array[idx];
assert(removed);
this->items--;
if(idx < this->items) {
if (idx < this->items) {
memmove(&this->array[idx], &this->array[idx + 1], (this->items - idx) * sizeof(this->array[0]));
}
//this->array[this->items] = NULL;

View File

@ -13,7 +13,7 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
*level = NAN;
*isOnAC = AC_ERROR;
if(NULL == power_sources) {
if (NULL == power_sources) {
return;
}
@ -21,7 +21,7 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
CFDictionaryRef battery = NULL;
int len;
if(NULL == list) {
if (NULL == list) {
CFRelease(power_sources);
return;
@ -35,18 +35,18 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
CFArrayGetValueAtIndex(list, i)); /* GET rule */
CFStringRef type;
if(NULL != candidate) {
if (NULL != candidate) {
type = (CFStringRef) CFDictionaryGetValue(candidate,
CFSTR(kIOPSTransportTypeKey)); /* GET rule */
if(kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) {
if (kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) {
CFRetain(candidate);
battery = candidate;
}
}
}
if(NULL != battery) {
if (NULL != battery) {
/* Determine the AC state */
CFStringRef power_state = CFDictionaryGetValue(battery, CFSTR(kIOPSPowerSourceStateKey));

View File

@ -212,7 +212,7 @@ void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool e
*/
/* First, the "immutable" parts */
if(!exists) {
if (!exists) {
/* Set the PID/PGID/etc. */
proc->pid = ep->p_pid;
proc->ppid = ps->kp_eproc.e_ppid;
@ -244,8 +244,8 @@ void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool e
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))) {
if(0 != proc->utime || 0 != proc->stime) {
if (sizeof(pti) == proc_pidinfo(proc->super.pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti))) {
if (0 != proc->utime || 0 != proc->stime) {
uint64_t diff = (pti.pti_total_system - proc->stime)
+ (pti.pti_total_user - proc->utime);

View File

@ -57,14 +57,14 @@ int CompareKernelVersion(short int major, short int minor, short int component)
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)) {
if (0 != host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)p, &info_size)) {
CRT_fatalError("Unable to retrieve host info\n");
}
}
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p) {
if(NULL != p && NULL != *p) {
if(0 != munmap(*p, vm_page_size)) {
if (NULL != p && NULL != *p) {
if (0 != munmap(*p, vm_page_size)) {
CRT_fatalError("Unable to free old CPU load information\n");
}
*p = NULL;
@ -76,7 +76,7 @@ unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t *p) {
unsigned cpu_count;
// TODO Improving the accuracy of the load counts woule help a lot.
if(0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t *)p, &info_size)) {
if (0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t *)p, &info_size)) {
CRT_fatalError("Unable to retrieve CPU info\n");
}
@ -200,7 +200,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
super->totalTasks += 1;
if(!preExisting) {
if (!preExisting) {
proc->super.user = UsersTable_getRef(super->usersTable, proc->super.st_uid);
ProcessList_add(super, &proc->super);

View File

@ -149,7 +149,7 @@ int Platform_getUptime() {
void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
double results[3];
if(3 == getloadavg(results, 3)) {
if (3 == getloadavg(results, 3)) {
*one = results[0];
*five = results[1];
*fifteen = results[2];

View File

@ -417,7 +417,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
dfp->jname = DragonFlyBSDProcessList_readJailName(dfpl, kproc->kp_jailid);
} else {
proc->processor = kproc->kp_lwp.kl_cpuid;
if(dfp->jid != kproc->kp_jailid) { // process can enter jail anytime
if (dfp->jid != kproc->kp_jailid) { // process can enter jail anytime
dfp->jid = kproc->kp_jailid;
free(dfp->jname);
dfp->jname = DragonFlyBSDProcessList_readJailName(dfpl, kproc->kp_jailid);
@ -425,7 +425,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
if (proc->ppid != kproc->kp_ppid) { // if there are reapers in the system, process can get reparented anytime
proc->ppid = kproc->kp_ppid;
}
if(proc->st_uid != kproc->kp_uid) { // some processes change users (eg. to lower privs)
if (proc->st_uid != kproc->kp_uid) { // some processes change users (eg. to lower privs)
proc->st_uid = kproc->kp_uid;
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);
}

View File

@ -502,7 +502,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc->comm = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset);
fp->jname = FreeBSDProcessList_readJailName(kproc);
} else {
if(fp->jid != kproc->ki_jid) {
if (fp->jid != kproc->ki_jid) {
// process can enter jail anytime
fp->jid = kproc->ki_jid;
free(fp->jname);
@ -512,7 +512,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
// if there are reapers in the system, process can get reparented anytime
proc->ppid = kproc->ki_ppid;
}
if(proc->st_uid != kproc->ki_uid) {
if (proc->st_uid != kproc->ki_uid) {
// some processes change users (eg. to lower privs)
proc->st_uid = kproc->ki_uid;
proc->user = UsersTable_getRef(super->usersTable, proc->st_uid);

6
htop.c
View File

@ -186,7 +186,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
char* saveptr;
char* pid = strtok_r(argCopy, ",", &saveptr);
if(!flags.pidMatchList) {
if (!flags.pidMatchList) {
flags.pidMatchList = Hashtable_new(8, false);
}
@ -243,7 +243,7 @@ static void setCommFilter(State* state, char** commFilter) {
int main(int argc, char** argv) {
char *lc_ctype = getenv("LC_CTYPE");
if(lc_ctype != NULL)
if (lc_ctype != NULL)
setlocale(LC_CTYPE, lc_ctype);
else if ((lc_ctype = getenv("LC_ALL")))
setlocale(LC_CTYPE, lc_ctype);
@ -334,7 +334,7 @@ int main(int argc, char** argv) {
UsersTable_delete(ut);
Settings_delete(settings);
if(flags.pidMatchList) {
if (flags.pidMatchList) {
Hashtable_delete(flags.pidMatchList);
}
return 0;

View File

@ -244,11 +244,11 @@ void LinuxProcess_writeField(const Process* this, RichString* str, ProcessField
case IO_WRITE_RATE: Process_outputRate(str, buffer, n, lp->io_rate_write_bps, coloring); return;
case IO_RATE: {
double totalRate = NAN;
if(!isnan(lp->io_rate_read_bps) && !isnan(lp->io_rate_write_bps))
if (!isnan(lp->io_rate_read_bps) && !isnan(lp->io_rate_write_bps))
totalRate = lp->io_rate_read_bps + lp->io_rate_write_bps;
else if(!isnan(lp->io_rate_read_bps))
else if (!isnan(lp->io_rate_read_bps))
totalRate = lp->io_rate_read_bps;
else if(!isnan(lp->io_rate_write_bps))
else if (!isnan(lp->io_rate_write_bps))
totalRate = lp->io_rate_write_bps;
else
totalRate = NAN;

View File

@ -208,7 +208,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
// Check for /proc/*/smaps_rollup availability (improves smaps parsing speed, Linux 4.14+)
FILE* file = fopen(PROCDIR "/self/smaps_rollup", "r");
if(file != NULL) {
if (file != NULL) {
this->haveSmapsRollup = true;
fclose(file);
} else {
@ -271,10 +271,10 @@ void ProcessList_delete(ProcessList* pl) {
static inline unsigned long long LinuxProcess_adjustTime(unsigned long long t) {
static double jiffy = NAN;
if(isnan(jiffy)) {
if (isnan(jiffy)) {
errno = 0;
long sc_jiffy = sysconf(_SC_CLK_TCK);
if(errno || -1 == sc_jiffy) {
if (errno || -1 == sc_jiffy) {
jiffy = NAN;
return t; // Assume 100Hz clock
}
@ -481,7 +481,7 @@ static bool LinuxProcessList_readSmapsFile(LinuxProcess* process, const char* di
char buffer[256];
if(haveSmapsRollup) {// only available in Linux 4.14+
if (haveSmapsRollup) {// only available in Linux 4.14+
xSnprintf(buffer, sizeof(buffer), "%s/%s/smaps_rollup", dirname, name);
} else {
xSnprintf(buffer, sizeof(buffer), "%s/%s/smaps", dirname, name);
@ -496,10 +496,10 @@ static bool LinuxProcessList_readSmapsFile(LinuxProcess* process, const char* di
process->m_psswp = 0;
while (fgets(buffer, sizeof(buffer), f)) {
if(!strchr(buffer, '\n')) {
if (!strchr(buffer, '\n')) {
// Partial line, skip to end of this line
while (fgets(buffer, sizeof(buffer), f)) {
if(strchr(buffer, '\n')) {
if (strchr(buffer, '\n')) {
break;
}
}
@ -543,10 +543,10 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
bool foundVPid = false;
char linebuf[256];
while (fgets(linebuf, sizeof(linebuf), file) != NULL) {
if(strchr(linebuf, '\n') == NULL) {
if (strchr(linebuf, '\n') == NULL) {
// Partial line, skip to end of this line
while (fgets(linebuf, sizeof(linebuf), file) != NULL) {
if(strchr(linebuf, '\n') != NULL) {
if (strchr(linebuf, '\n') != NULL) {
break;
}
}
@ -554,14 +554,14 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
}
char* name_value_sep = strchr(linebuf, ':');
if(name_value_sep == NULL) {
if (name_value_sep == NULL) {
continue;
}
int field;
if(0 == strncasecmp(linebuf, "envID", name_value_sep - linebuf)) {
if (0 == strncasecmp(linebuf, "envID", name_value_sep - linebuf)) {
field = 1;
} else if(0 == strncasecmp(linebuf, "VPid", name_value_sep - linebuf)) {
} else if (0 == strncasecmp(linebuf, "VPid", name_value_sep - linebuf)) {
field = 2;
} else {
continue;
@ -577,7 +577,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
value_end++;
}
if(name_value_sep == value_end) {
if (name_value_sep == value_end) {
continue;
}
@ -586,7 +586,7 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
switch(field) {
case 1:
foundEnvID = true;
if(!String_eq(name_value_sep, process->ctid ? process->ctid : "")) {
if (!String_eq(name_value_sep, process->ctid ? process->ctid : "")) {
free(process->ctid);
process->ctid = xStrdup(name_value_sep);
}
@ -603,12 +603,12 @@ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* d
fclose(file);
if(!foundEnvID) {
if (!foundEnvID) {
free(process->ctid);
process->ctid = NULL;
}
if(!foundVPid) {
if (!foundVPid) {
process->vpid = process->super.pid;
}
}
@ -1010,7 +1010,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
if (isnan(proc->percent_cpu)) proc->percent_cpu = 0.0;
proc->percent_mem = (proc->m_resident * CRT_pageSizeKB) / (double)(pl->totalMem) * 100.0;
if(!preExisting) {
if (!preExisting) {
if (! LinuxProcessList_statProcessDir(proc, dirname, name))
goto errorReadingProcess;

View File

@ -272,7 +272,7 @@ char* Platform_getProcessEnv(pid_t pid) {
char procname[128];
xSnprintf(procname, sizeof(procname), PROCDIR "/%d/environ", pid);
FILE* fd = fopen(procname, "r");
if(!fd)
if (!fd)
return NULL;
char *env = NULL;

View File

@ -19,18 +19,18 @@ static void ZramMeter_updateValues(Meter* this, char* buffer, int size) {
written = Meter_humanUnit(buffer, this->values[0], size);
buffer += written;
size -= written;
if(size <= 0) {
if (size <= 0) {
return;
}
*buffer++ = '(';
size--;
if(size <= 0) {
if (size <= 0) {
return;
}
written = Meter_humanUnit(buffer, this->values[1], size);
buffer += written;
size -= written;
if(size <= 0) {
if (size <= 0) {
return;
}
*buffer++ = ')';

View File

@ -322,7 +322,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
// See note above (in common section) about this BINARY FRACTION
proc->percent_cpu = ((uint16_t)_psinfo->pr_pctcpu/(double)32768)*(double)100.0;
proc->time = _psinfo->pr_time.tv_sec;
if(!preExisting) { // Tasks done only for NEW processes
if (!preExisting) { // Tasks done only for NEW processes
sproc->is_lwp = false;
proc->starttime_ctime = _psinfo->pr_start.tv_sec;
}