From 290ddba35e7a1463c1a9fc5ff6bd723cd1670ba2 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 8 May 2023 10:08:20 +1000 Subject: Minor whitespace and small logic flow improvements on review Quality improvements from BenBE as part of review for #1234. --- solaris/Platform.c | 4 +-- solaris/SolarisMachine.c | 69 +++++++++++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 35 deletions(-) (limited to 'solaris') 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; } } -- cgit v1.2.3