summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2023-05-08 10:08:20 +1000
committerNathan Scott <nathans@redhat.com>2023-05-08 13:07:50 +1000
commit290ddba35e7a1463c1a9fc5ff6bd723cd1670ba2 (patch)
treea31bbb5623459e4f4038f7876ab6b14e31004e14
parent72235d8e098d9d79029dca65122605741e1aafad (diff)
Minor whitespace and small logic flow improvements on review
Quality improvements from BenBE as part of review for #1234.
-rw-r--r--darwin/DarwinMachine.c16
-rw-r--r--linux/LinuxMachine.c2
-rw-r--r--netbsd/NetBSDMachine.c1
-rw-r--r--openbsd/Platform.c2
-rw-r--r--solaris/Platform.c4
-rw-r--r--solaris/SolarisMachine.c69
6 files changed, 52 insertions, 42 deletions
diff --git a/darwin/DarwinMachine.c b/darwin/DarwinMachine.c
index 6bf52b76..1290e959 100644
--- a/darwin/DarwinMachine.c
+++ b/darwin/DarwinMachine.c
@@ -1,6 +1,7 @@
/*
htop - DarwinMachine.c
(C) 2014 Hisham H. Muhammad
+(C) 2023 htop dev team
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@@ -33,12 +34,17 @@ static void DarwinMachine_getHostInfo(host_basic_info_data_t* p) {
}
static void DarwinMachine_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");
- }
- *p = NULL;
+ if (!p)
+ return;
+
+ if (!*p)
+ return;
+
+ if (0 != munmap(*p, vm_page_size)) {
+ CRT_fatalError("Unable to free old CPU load information");
}
+
+ *p = NULL;
}
static unsigned DarwinMachine_allocateCPULoadInfo(processor_cpu_load_info_t* p) {
diff --git a/linux/LinuxMachine.c b/linux/LinuxMachine.c
index 48d0e80e..7b6abfa0 100644
--- a/linux/LinuxMachine.c
+++ b/linux/LinuxMachine.c
@@ -440,7 +440,7 @@ static void LinuxMachine_scanCPUTime(LinuxMachine* this) {
// The rest will remain at zero.
unsigned int adjCpuId;
if (i == 0) {
- (void) sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
+ (void) sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
adjCpuId = 0;
} else {
unsigned int cpuid;
diff --git a/netbsd/NetBSDMachine.c b/netbsd/NetBSDMachine.c
index 1e2a0a13..9f3b32de 100644
--- a/netbsd/NetBSDMachine.c
+++ b/netbsd/NetBSDMachine.c
@@ -276,6 +276,7 @@ void Machine_scan(Machine* super) {
bool Machine_isCPUonline(const Machine* host, unsigned int id) {
assert(id < host->existingCPUs);
+ (void)host; (void)id;
// TODO: Support detecting online / offline CPUs.
return true;
diff --git a/openbsd/Platform.c b/openbsd/Platform.c
index 94e71928..06594089 100644
--- a/openbsd/Platform.c
+++ b/openbsd/Platform.c
@@ -182,7 +182,7 @@ int Platform_getMaxPid(void) {
double Platform_setCPUValues(Meter* this, unsigned int cpu) {
const Machine* host = this->host;
const OpenBSDMachine* ohost = (const OpenBSDMachine*) host;
- const CPUData* cpuData = &(ohost->cpuData[cpu]);
+ const CPUData* cpuData = &ohost->cpuData[cpu];
double total;
double totalPercent;
double* v = this->values;
diff --git a/solaris/Platform.c b/solaris/Platform.c
index ad899492..95c50b4d 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -258,13 +258,13 @@ void Platform_setSwapValues(Meter* this) {
void Platform_setZfsArcValues(Meter* this) {
const SolarisMachine* shost = (SolarisMachine*) this->host;
- ZfsArcMeter_readStats(this, &(shost->zfs));
+ ZfsArcMeter_readStats(this, &shost->zfs);
}
void Platform_setZfsCompressedArcValues(Meter* this) {
const SolarisMachine* shost = (SolarisMachine*) this->host;
- ZfsCompressedArcMeter_readStats(this, &(shost->zfs));
+ ZfsCompressedArcMeter_readStats(this, &shost->zfs);
}
static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr_t addr, const char* str) {
diff --git a/solaris/SolarisMachine.c b/solaris/SolarisMachine.c
index 9ce4ced2..b94fc742 100644
--- a/solaris/SolarisMachine.c
+++ b/solaris/SolarisMachine.c
@@ -241,48 +241,51 @@ static void SolarisMachine_scanMemoryInfo(SolarisMachine* this) {
}
static void SolarisMachine_scanZfsArcstats(SolarisMachine* this) {
- kstat_named_t *cur_kstat = NULL;
- kstat_t *arcstats = NULL;
- int ksrphyserr = -1;
+ kstat_named_t *cur_kstat;
+ kstat_t *arcstats;
+ int ksrphyserr;
- if (this->kd != NULL) {
- arcstats = kstat_lookup_wrapper(this->kd, "zfs", 0, "arcstats");
- }
- if (arcstats != NULL) {
- ksrphyserr = kstat_read(this->kd, arcstats, NULL);
- }
- if (ksrphyserr != -1) {
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "size" );
- this->zfs.size = cur_kstat->value.ui64 / 1024;
- this->zfs.enabled = this->zfs.size > 0 ? 1 : 0;
+ if (this->kd == NULL)
+ return;
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "c_max" );
- this->zfs.max = cur_kstat->value.ui64 / 1024;
+ arcstats = kstat_lookup_wrapper(this->kd, "zfs", 0, "arcstats");
+ if (arcstats == NULL)
+ return;
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "mfu_size" );
- this->zfs.MFU = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
+ ksrphyserr = kstat_read(this->kd, arcstats, NULL);
+ if (ksrphyserr == -1)
+ return;
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "mru_size" );
- this->zfs.MRU = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "size" );
+ this->zfs.size = cur_kstat->value.ui64 / 1024;
+ this->zfs.enabled = this->zfs.size > 0 ? 1 : 0;
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "anon_size" );
- this->zfs.anon = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "c_max" );
+ this->zfs.max = cur_kstat->value.ui64 / 1024;
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "hdr_size" );
- this->zfs.header = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "mfu_size" );
+ this->zfs.MFU = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "other_size" );
- this->zfs.other = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "mru_size" );
+ this->zfs.MRU = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
- if ((cur_kstat = kstat_data_lookup_wrapper( arcstats, "compressed_size" )) != NULL) {
- this->zfs.compressed = cur_kstat->value.ui64 / 1024;
- this->zfs.isCompressed = 1;
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "anon_size" );
+ this->zfs.anon = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
- cur_kstat = kstat_data_lookup_wrapper( arcstats, "uncompressed_size" );
- this->zfs.uncompressed = cur_kstat->value.ui64 / 1024;
- } else {
- this->zfs.isCompressed = 0;
- }
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "hdr_size" );
+ this->zfs.header = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
+
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "other_size" );
+ this->zfs.other = cur_kstat != NULL ? cur_kstat->value.ui64 / 1024 : 0;
+
+ if ((cur_kstat = kstat_data_lookup_wrapper( arcstats, "compressed_size" )) != NULL) {
+ this->zfs.compressed = cur_kstat->value.ui64 / 1024;
+ this->zfs.isCompressed = 1;
+
+ cur_kstat = kstat_data_lookup_wrapper( arcstats, "uncompressed_size" );
+ this->zfs.uncompressed = cur_kstat->value.ui64 / 1024;
+ } else {
+ this->zfs.isCompressed = 0;
}
}

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