summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-11-01 01:09:51 +0100
committerBenny Baumann <BenBE@geshi.org>2020-11-02 22:15:01 +0100
commit45869513bfebba80cc2ab42e4218f68b34b1e6ac (patch)
treef064631dbff141bf1c945db8cff40b7bb82fd169 /freebsd
parent61e14d4bb25268593019e6df3eb02264b4ac8e0e (diff)
Embracing branches
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/Battery.c10
-rw-r--r--freebsd/FreeBSDProcess.c5
-rw-r--r--freebsd/FreeBSDProcessList.c36
3 files changed, 33 insertions, 18 deletions
diff --git a/freebsd/Battery.c b/freebsd/Battery.c
index 50691c8b..26b42da9 100644
--- a/freebsd/Battery.c
+++ b/freebsd/Battery.c
@@ -13,15 +13,17 @@ in the source distribution for its full text.
void Battery_getData(double* level, ACPresence* isOnAC) {
int life;
size_t life_len = sizeof(life);
- if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1)
+ if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1) {
*level = NAN;
- else
+ } else {
*level = life;
+ }
int acline;
size_t acline_len = sizeof(acline);
- if (sysctlbyname("hw.acpi.acline", &acline, &acline_len, NULL, 0) == -1)
+ if (sysctlbyname("hw.acpi.acline", &acline, &acline_len, NULL, 0) == -1) {
*isOnAC = AC_ERROR;
- else
+ } else {
*isOnAC = acline == 0 ? AC_ABSENT : AC_PRESENT;
+ }
}
diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c
index a4516d04..baad5d13 100644
--- a/freebsd/FreeBSDProcess.c
+++ b/freebsd/FreeBSDProcess.c
@@ -134,10 +134,11 @@ static long FreeBSDProcess_compare(const void* v1, const void* v2) {
bool Process_isThread(const Process* this) {
const FreeBSDProcess* fp = (const FreeBSDProcess*) this;
- if (fp->kernel == 1 )
+ if (fp->kernel == 1 ) {
return 1;
- else
+ } else {
return Process_isUserlandThread(this);
+ }
}
const ProcessClass FreeBSDProcess_class = {
diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c
index 4594b992..7ce787f8 100644
--- a/freebsd/FreeBSDProcessList.c
+++ b/freebsd/FreeBSDProcessList.c
@@ -98,7 +98,9 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
if (smp) {
int err = sysctlbyname("kern.smp.cpus", &cpus, &len, NULL, 0);
- if (err) cpus = 1;
+ if (err) {
+ cpus = 1;
+ }
} else {
cpus = 1;
}
@@ -152,7 +154,9 @@ void ProcessList_delete(ProcessList* this) {
Hashtable_delete(fpl->ttys);
- if (fpl->kd) kvm_close(fpl->kd);
+ if (fpl->kd) {
+ kvm_close(fpl->kd);
+ }
free(fpl->cp_time_o);
free(fpl->cp_time_n);
@@ -225,7 +229,9 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) {
// totals
total_d = total_n - total_o;
- if (total_d < 1 ) total_d = 1;
+ if (total_d < 1 ) {
+ total_d = 1;
+ }
// save current state as old and calc percentages
for (int s = 0; s < CPUSTATES; ++s) {
@@ -434,13 +440,15 @@ IGNORE_WCASTQUAL_END
jail_errmsg[0] = 0;
jid = jail_get(jiov, 6, 0);
if (jid < 0) {
- if (!jail_errmsg[0])
+ if (!jail_errmsg[0]) {
xSnprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s", strerror(errno));
+ }
return NULL;
} else if (jid == kproc->ki_jid) {
jname = xStrdup(jnamebuf);
- if (jname == NULL)
+ if (jname == NULL) {
strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN);
+ }
return jname;
} else {
return NULL;
@@ -464,11 +472,13 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
FreeBSDProcessList_scanCPUTime(super);
// in pause mode only gather global data for meters (CPU/memory/...)
- if (pauseProcessUpdate)
+ if (pauseProcessUpdate) {
return;
+ }
- if (settings->flags & PROCESS_FLAG_FREEBSD_TTY)
+ if (settings->flags & PROCESS_FLAG_FREEBSD_TTY) {
FreeBSDProcessList_scanTTYs(super);
+ }
int count = 0;
struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count);
@@ -485,10 +495,11 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
if (!preExisting) {
fp->jid = kproc->ki_jid;
proc->pid = kproc->ki_pid;
- if ( ! ((kproc->ki_pid == 0) || (kproc->ki_pid == 1) ) && kproc->ki_flag & P_SYSTEM)
- fp->kernel = 1;
- else
- fp->kernel = 0;
+ if ( ! ((kproc->ki_pid == 0) || (kproc->ki_pid == 1) ) && kproc->ki_flag & P_SYSTEM) {
+ fp->kernel = 1;
+ } else {
+ fp->kernel = 0;
+ }
proc->ppid = kproc->ki_ppid;
proc->tpgid = kproc->ki_tpgid;
proc->tgid = kproc->ki_pid;
@@ -565,8 +576,9 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
default: proc->state = '?';
}
- if (settings->flags & PROCESS_FLAG_FREEBSD_TTY)
+ if (settings->flags & PROCESS_FLAG_FREEBSD_TTY) {
fp->ttyPath = (kproc->ki_tdev == NODEV) ? nodevStr : Hashtable_get(fpl->ttys, kproc->ki_tdev);
+ }
if (Process_isKernelThread(proc))
super->kernelThreads++;

© 2014-2024 Faster IT GmbH | imprint | privacy policy