From 374edb9ed5e9d5fa24cfe358258d82f69d9d430d Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 31 Oct 2020 20:52:20 +0100 Subject: Spacing after keywords (if) --- solaris/SolarisProcessList.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'solaris') diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index 2af82aab..e219d1ee 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -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; } -- cgit v1.2.3 From b23f8235e28472c410dcb00893e0e3d403892673 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 31 Oct 2020 22:14:27 +0100 Subject: Whitespace and indentation issues --- solaris/Platform.c | 6 ++--- solaris/SolarisProcessList.c | 54 ++++++++++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 23 deletions(-) (limited to 'solaris') diff --git a/solaris/Platform.c b/solaris/Platform.c index 87247969..be2d25ed 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -172,10 +172,10 @@ double Platform_setCPUValues(Meter* this, int cpu) { const CPUData* cpuData = NULL; if (cpus == 1) { - // single CPU box has everything in spl->cpus[0] - cpuData = &(spl->cpus[0]); + // single CPU box has everything in spl->cpus[0] + cpuData = &(spl->cpus[0]); } else { - cpuData = &(spl->cpus[cpu]); + cpuData = &(spl->cpus[cpu]); } double percent; diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index e219d1ee..cbef6c8f 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -29,16 +29,18 @@ in the source distribution for its full text. #define MAXCMDLINE 255 char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc) { - char* zname; - if ( sproc->zoneid == 0 ) { - zname = xStrdup(GZONE); - } else if ( kd == NULL ) { - zname = xStrdup(UZONE); - } else { - kstat_t* ks = kstat_lookup( kd, "zones", sproc->zoneid, NULL ); - zname = xStrdup(ks == NULL ? UZONE : ks->ks_name); - } - return zname; + char* zname; + + if ( sproc->zoneid == 0 ) { + zname = xStrdup(GZONE); + } else if ( kd == NULL ) { + zname = xStrdup(UZONE); + } else { + kstat_t* ks = kstat_lookup( kd, "zones", sproc->zoneid, NULL ); + zname = xStrdup(ks == NULL ? UZONE : ks->ks_name); + } + + return zname; } ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { @@ -78,15 +80,19 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) { assert(cpus > 0); if (cpus > 1) { - // Store values for the stats loop one extra element up in the array - // to leave room for the average to be calculated afterwards - arrskip++; + // Store values for the stats loop one extra element up in the array + // to leave room for the average to be calculated afterwards + arrskip++; } // Calculate per-CPU statistics first for (int i = 0; i < cpus; i++) { - if (spl->kd != NULL) { cpuinfo = kstat_lookup(spl->kd,"cpu",i,"sys"); } - if (cpuinfo != NULL) { kchain = kstat_read(spl->kd,cpuinfo,NULL); } + if (spl->kd != NULL) { + cpuinfo = kstat_lookup(spl->kd, "cpu", i, "sys"); + } + if (cpuinfo != NULL) { + kchain = kstat_read(spl->kd, cpuinfo, NULL); + } if (kchain != -1 ) { idletime = kstat_data_lookup(cpuinfo,"cpu_nsec_idle"); intrtime = kstat_data_lookup(cpuinfo,"cpu_nsec_intr"); @@ -170,7 +176,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { // Not really "buffers" but the best Solaris analogue that I can find to // "memory in use but not by programs or the kernel itself" pl->buffersMem = (totalmem_pgs->value.ui64 - pages->value.ui64) * CRT_pageSizeKB; - } else { + } else { // Fall back to basic sysconf if kstat isn't working pl->totalMem = sysconf(_SC_PHYS_PAGES) * CRT_pageSize; pl->buffersMem = 0; @@ -180,8 +186,12 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { // Part 2 - swap nswap = swapctl(SC_GETNSWP, NULL); - if (nswap > 0) { sl = xMalloc((nswap * sizeof(swapent_t)) + sizeof(int)); } - if (sl != NULL) { spathbase = xMalloc( nswap * MAXPATHLEN ); } + if (nswap > 0) { + sl = xMalloc((nswap * sizeof(swapent_t)) + sizeof(int)); + } + if (sl != NULL) { + spathbase = xMalloc( nswap * MAXPATHLEN ); + } if (spathbase != NULL) { spath = spathbase; swapdev = sl->swt_ent; @@ -211,8 +221,12 @@ static inline void SolarisProcessList_scanZfsArcstats(ProcessList* pl) { int ksrphyserr = -1; kstat_named_t *cur_kstat = NULL; - if (spl->kd != NULL) { arcstats = kstat_lookup(spl->kd, "zfs", 0, "arcstats"); } - if (arcstats != NULL) { ksrphyserr = kstat_read(spl->kd, arcstats, NULL); } + if (spl->kd != NULL) { + arcstats = kstat_lookup(spl->kd, "zfs", 0, "arcstats"); + } + if (arcstats != NULL) { + ksrphyserr = kstat_read(spl->kd, arcstats, NULL); + } if (ksrphyserr != -1) { cur_kstat = kstat_data_lookup( arcstats, "size" ); spl->zfs.size = cur_kstat->value.ui64 / 1024; -- cgit v1.2.3 From 61e14d4bb25268593019e6df3eb02264b4ac8e0e Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 31 Oct 2020 23:28:02 +0100 Subject: Spacing around operators --- solaris/Platform.c | 32 +++++++++++------------ solaris/Platform.h | 10 +++---- solaris/SolarisProcessList.c | 62 ++++++++++++++++++++++++-------------------- solaris/SolarisProcessList.h | 2 +- 4 files changed, 56 insertions(+), 50 deletions(-) (limited to 'solaris') diff --git a/solaris/Platform.c b/solaris/Platform.c index be2d25ed..69777726 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -130,7 +130,7 @@ extern char Process_pidFormat[20]; int Platform_getUptime() { int boot_time = 0; int curr_time = time(NULL); - struct utmpx * ent; + struct utmpx* ent; while (( ent = getutxent() )) { if ( !strcmp("system boot", ent->ut_line )) { @@ -140,7 +140,7 @@ int Platform_getUptime() { endutxent(); - return (curr_time-boot_time); + return (curr_time - boot_time); } void Platform_getLoadAverage(double* one, double* five, double* fifteen) { @@ -151,9 +151,9 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) { } int Platform_getMaxPid() { - kstat_ctl_t *kc = NULL; - kstat_t *kshandle = NULL; - kvar_t *ksvar = NULL; + kstat_ctl_t* kc = NULL; + kstat_t* kshandle = NULL; + kvar_t* ksvar = NULL; int vproc = 32778; // Reasonable Solaris default kc = kstat_open(); if (kc != NULL) { kshandle = kstat_lookup(kc,"unix",0,"var"); } @@ -187,11 +187,11 @@ double Platform_setCPUValues(Meter* this, int cpu) { v[CPU_METER_KERNEL] = cpuData->systemPercent; v[CPU_METER_IRQ] = cpuData->irqPercent; this->curItems = 4; - percent = v[0]+v[1]+v[2]+v[3]; + percent = v[0] + v[1] + v[2] + v[3]; } else { v[2] = cpuData->systemAllPercent; this->curItems = 3; - percent = v[0]+v[1]+v[2]; + percent = v[0] + v[1] + v[2]; } percent = CLAMP(percent, 0.0, 100.0); @@ -228,8 +228,8 @@ void Platform_setZfsCompressedArcValues(Meter* this) { ZfsCompressedArcMeter_readStats(this, &(spl->zfs)); } -static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr_t addr, const char *str) { - envAccum *accump = accum; +static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr_t addr, const char* str) { + envAccum* accump = accum; (void) Phandle; (void) addr; size_t thissz = strlen(str); @@ -247,16 +247,16 @@ char* Platform_getProcessEnv(pid_t pid) { envAccum envBuilder; pid_t realpid = pid / 1024; int graberr; - struct ps_prochandle *Phandle; + struct ps_prochandle* Phandle; - if ((Phandle = Pgrab(realpid,PGRAB_RDONLY,&graberr)) == NULL) + if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) return "Unable to read process environment."; envBuilder.capacity = 4096; envBuilder.size = 0; envBuilder.env = xMalloc(envBuilder.capacity); - (void) Penv_iter(Phandle,Platform_buildenv,&envBuilder); + (void) Penv_iter(Phandle, Platform_buildenv, &envBuilder); Prelease(Phandle, 0); @@ -270,10 +270,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; diff --git a/solaris/Platform.h b/solaris/Platform.h index 8718dbfe..701bc77d 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -27,7 +27,7 @@ typedef struct envAccum_ { size_t capacity; size_t size; size_t bytes; - char *env; + char* env; } envAccum; extern double plat_loadavg[3]; @@ -66,9 +66,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 diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index cbef6c8f..31507506 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -64,12 +64,12 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) { const SolarisProcessList* spl = (SolarisProcessList*) pl; int cpus = pl->cpuCount; - kstat_t *cpuinfo = NULL; + kstat_t* cpuinfo = NULL; int kchain = 0; - kstat_named_t *idletime = NULL; - kstat_named_t *intrtime = NULL; - kstat_named_t *krnltime = NULL; - kstat_named_t *usertime = NULL; + kstat_named_t* idletime = NULL; + kstat_named_t* intrtime = NULL; + kstat_named_t* krnltime = NULL; + kstat_named_t* usertime = NULL; double idlebuf = 0; double intrbuf = 0; double krnlbuf = 0; @@ -94,16 +94,16 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) { kchain = kstat_read(spl->kd, cpuinfo, NULL); } if (kchain != -1 ) { - idletime = kstat_data_lookup(cpuinfo,"cpu_nsec_idle"); - intrtime = kstat_data_lookup(cpuinfo,"cpu_nsec_intr"); - krnltime = kstat_data_lookup(cpuinfo,"cpu_nsec_kernel"); - usertime = kstat_data_lookup(cpuinfo,"cpu_nsec_user"); + idletime = kstat_data_lookup(cpuinfo, "cpu_nsec_idle"); + intrtime = kstat_data_lookup(cpuinfo, "cpu_nsec_intr"); + krnltime = kstat_data_lookup(cpuinfo, "cpu_nsec_kernel"); + usertime = kstat_data_lookup(cpuinfo, "cpu_nsec_user"); } assert( (idletime != NULL) && (intrtime != NULL) && (krnltime != NULL) && (usertime != NULL) ); - CPUData* cpuData = &(spl->cpus[i+arrskip]); + CPUData* cpuData = &(spl->cpus[i + arrskip]); totaltime = (idletime->value.ui64 - cpuData->lidle) + (intrtime->value.ui64 - cpuData->lintr) + (krnltime->value.ui64 - cpuData->lkrnl) @@ -158,9 +158,11 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { // Part 1 - physical memory if (spl->kd != NULL && meminfo == NULL) { // Look up the kstat chain just one, it never changes - meminfo = kstat_lookup(spl->kd,"unix",0,"system_pages"); + meminfo = kstat_lookup(spl->kd, "unix", 0, "system_pages"); + } + if (meminfo != NULL) { + ksrphyserr = kstat_read(spl->kd, meminfo, NULL); } - if (meminfo != NULL) { ksrphyserr = kstat_read(spl->kd,meminfo,NULL); } if (ksrphyserr != -1) { totalmem_pgs = kstat_data_lookup(meminfo, "physmem"); freemem_pgs = kstat_data_lookup(meminfo, "freemem"); @@ -276,13 +278,13 @@ void ProcessList_delete(ProcessList* pl) { * system for more info. */ -int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr) { +int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, void* listptr) { bool preExisting; pid_t getpid; // Setup process list - ProcessList *pl = (ProcessList*) listptr; - SolarisProcessList *spl = (SolarisProcessList*) listptr; + ProcessList* pl = (ProcessList*) listptr; + SolarisProcessList* spl = (SolarisProcessList*) listptr; id_t lwpid_real = _lwpsinfo->pr_lwpid; if (lwpid_real > 1023) return 0; @@ -293,8 +295,8 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * } else { getpid = lwpid; } - Process *proc = ProcessList_getProcess(pl, getpid, &preExisting, SolarisProcess_new); - SolarisProcess *sproc = (SolarisProcess*) proc; + Process* proc = ProcessList_getProcess(pl, getpid, &preExisting, SolarisProcess_new); + SolarisProcess* sproc = (SolarisProcess*) proc; // Common code pass 1 proc->show = false; @@ -309,22 +311,22 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * // NOTE: This 'percentage' is a 16-bit BINARY FRACTIONS where 1.0 = 0x8000 // Source: https://docs.oracle.com/cd/E19253-01/816-5174/proc-4/index.html // (accessed on 18 November 2017) - proc->percent_mem = ((uint16_t)_psinfo->pr_pctmem/(double)32768)*(double)100.0; + proc->percent_mem = ((uint16_t)_psinfo->pr_pctmem / (double)32768) * (double)100.0; proc->st_uid = _psinfo->pr_euid; proc->pgrp = _psinfo->pr_pgid; proc->nlwp = _psinfo->pr_nlwp; proc->tty_nr = _psinfo->pr_ttydev; - proc->m_resident = _psinfo->pr_rssize/CRT_pageSizeKB; - proc->m_size = _psinfo->pr_size/CRT_pageSizeKB; + proc->m_resident = _psinfo->pr_rssize / CRT_pageSizeKB; + proc->m_size = _psinfo->pr_size / CRT_pageSizeKB; if (!preExisting) { sproc->realpid = _psinfo->pr_pid; sproc->lwpid = lwpid_real; sproc->zoneid = _psinfo->pr_zoneid; - sproc->zname = SolarisProcessList_readZoneName(spl->kd,sproc); + sproc->zname = SolarisProcessList_readZoneName(spl->kd, sproc); proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid); proc->comm = xStrdup(_psinfo->pr_fname); - proc->commLen = strnlen(_psinfo->pr_fname,PRFNSZ); + proc->commLen = strnlen(_psinfo->pr_fname, PRFNSZ); } // End common code pass 1 @@ -334,7 +336,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * proc->tgid = (_psinfo->pr_ppid * 1024); sproc->realppid = _psinfo->pr_ppid; // See note above (in common section) about this BINARY FRACTION - proc->percent_cpu = ((uint16_t)_psinfo->pr_pctcpu/(double)32768)*(double)100.0; + 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 sproc->is_lwp = false; @@ -344,7 +346,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * // Update proc and thread counts based on settings if (sproc->kernel && !pl->settings->hideKernelThreads) { pl->kernelThreads += proc->nlwp; - pl->totalTasks += proc->nlwp+1; + pl->totalTasks += proc->nlwp + 1; if (proc->state == 'O') pl->runningTasks++; } else if (!sproc->kernel) { if (proc->state == 'O') pl->runningTasks++; @@ -352,12 +354,12 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * pl->totalTasks++; } else { pl->userlandThreads += proc->nlwp; - pl->totalTasks += proc->nlwp+1; + pl->totalTasks += proc->nlwp + 1; } } proc->show = !(pl->settings->hideKernelThreads && sproc->kernel); } else { // We are not in the master LWP, so jump to the LWP handling code - proc->percent_cpu = ((uint16_t)_lwpsinfo->pr_pctcpu/(double)32768)*(double)100.0; + proc->percent_cpu = ((uint16_t)_lwpsinfo->pr_pctcpu / (double)32768) * (double)100.0; proc->time = _lwpsinfo->pr_time.tv_sec; if (!preExisting) { // Tasks done only for NEW LWPs sproc->is_lwp = true; @@ -369,8 +371,12 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * } // Top-level process only gets this for the representative LWP - if (sproc->kernel && !pl->settings->hideKernelThreads) proc->show = true; - if (!sproc->kernel && !pl->settings->hideUserlandThreads) proc->show = true; + if (sproc->kernel && !pl->settings->hideKernelThreads) { + proc->show = true; + } + if (!sproc->kernel && !pl->settings->hideUserlandThreads) { + proc->show = true; + } } // Top-level LWP or subordinate LWP // Common code pass 2 diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h index 3a653eed..f800d9da 100644 --- a/solaris/SolarisProcessList.h +++ b/solaris/SolarisProcessList.h @@ -58,7 +58,7 @@ void ProcessList_delete(ProcessList* pl); * system for more info. */ -int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr); +int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, void* listptr); void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate); -- cgit v1.2.3 From 45869513bfebba80cc2ab42e4218f68b34b1e6ac Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sun, 1 Nov 2020 01:09:51 +0100 Subject: Embracing branches --- solaris/Platform.c | 25 ++++++++++++++++++------- solaris/SolarisProcessList.c | 27 +++++++++++++++++++-------- 2 files changed, 37 insertions(+), 15 deletions(-) (limited to 'solaris') diff --git a/solaris/Platform.c b/solaris/Platform.c index 69777726..6159c357 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -156,13 +156,19 @@ int Platform_getMaxPid() { kvar_t* ksvar = NULL; int vproc = 32778; // Reasonable Solaris default kc = kstat_open(); - if (kc != NULL) { kshandle = kstat_lookup(kc,"unix",0,"var"); } - if (kshandle != NULL) { kstat_read(kc,kshandle,NULL); } + if (kc != NULL) { + kshandle = kstat_lookup(kc, "unix", 0, "var"); + } + if (kshandle != NULL) { + kstat_read(kc, kshandle, NULL); + } ksvar = kshandle->ks_data; if (ksvar->v_proc > 0 ) { vproc = ksvar->v_proc; } - if (kc != NULL) { kstat_close(kc); } + if (kc != NULL) { + kstat_close(kc); + } return vproc; } @@ -195,7 +201,9 @@ double Platform_setCPUValues(Meter* this, int cpu) { } percent = CLAMP(percent, 0.0, 100.0); - if (isnan(percent)) percent = 0.0; + if (isnan(percent)) { + percent = 0.0; + } v[CPU_METER_FREQUENCY] = NAN; @@ -233,10 +241,12 @@ static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr (void) Phandle; (void) addr; size_t thissz = strlen(str); - if ((thissz + 2) > (accump->capacity - accump->size)) + if ((thissz + 2) > (accump->capacity - accump->size)) { accump->env = xRealloc(accump->env, accump->capacity *= 2); - if ((thissz + 2) > (accump->capacity - accump->size)) + } + if ((thissz + 2) > (accump->capacity - accump->size)) { return 1; + } strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size)); strncpy( accump->env + accump->size + thissz + 1, "\n", 1); accump->size = accump->size + thissz + 1; @@ -249,8 +259,9 @@ char* Platform_getProcessEnv(pid_t pid) { int graberr; struct ps_prochandle* Phandle; - if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) + if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) { return "Unable to read process environment."; + } envBuilder.capacity = 4096; envBuilder.size = 0; diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index 31507506..49aeb24c 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -169,10 +169,11 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { pages = kstat_data_lookup(meminfo, "pagestotal"); pl->totalMem = totalmem_pgs->value.ui64 * CRT_pageSizeKB; - if (pl->totalMem > freemem_pgs->value.ui64 * CRT_pageSizeKB) + if (pl->totalMem > freemem_pgs->value.ui64 * CRT_pageSizeKB) { pl->usedMem = pl->totalMem - freemem_pgs->value.ui64 * CRT_pageSizeKB; - else - pl->usedMem = 0; // This can happen in non-global zone (in theory) + } else { + pl->usedMem = 0; // This can happen in non-global zone (in theory) + } // Not sure how to implement this on Solaris - suggestions welcome! pl->cachedMem = 0; // Not really "buffers" but the best Solaris analogue that I can find to @@ -268,7 +269,9 @@ void ProcessList_delete(ProcessList* pl) { SolarisProcessList* spl = (SolarisProcessList*) pl; ProcessList_done(pl); free(spl->cpus); - if (spl->kd) kstat_close(spl->kd); + if (spl->kd) { + kstat_close(spl->kd); + } free(spl); } @@ -287,7 +290,10 @@ int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, void* SolarisProcessList* spl = (SolarisProcessList*) listptr; id_t lwpid_real = _lwpsinfo->pr_lwpid; - if (lwpid_real > 1023) return 0; + if (lwpid_real > 1023) { + return 0; + } + pid_t lwpid = (_psinfo->pr_pid * 1024) + lwpid_real; bool onMasterLWP = (_lwpsinfo->pr_lwpid == _psinfo->pr_lwp.pr_lwpid); if (onMasterLWP) { @@ -347,9 +353,13 @@ int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo, void* if (sproc->kernel && !pl->settings->hideKernelThreads) { pl->kernelThreads += proc->nlwp; pl->totalTasks += proc->nlwp + 1; - if (proc->state == 'O') pl->runningTasks++; + if (proc->state == 'O') { + pl->runningTasks++; + } } else if (!sproc->kernel) { - if (proc->state == 'O') pl->runningTasks++; + if (proc->state == 'O') { + pl->runningTasks++; + } if (pl->settings->hideUserlandThreads) { pl->totalTasks++; } else { @@ -403,8 +413,9 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { SolarisProcessList_scanZfsArcstats(super); // in pause mode only gather global data for meters (CPU/memory/...) - if (pauseProcessUpdate) + if (pauseProcessUpdate) { return; + } super->kernelThreads = 1; proc_walk(&SolarisProcessList_walkproc, super, PR_WALK_LWP); -- cgit v1.2.3 From 0e922d4085f0285cf353323fd5a96edae604d5da Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Mon, 2 Nov 2020 21:36:20 +0100 Subject: Integrate NAN check into assignment The check for NAN is kept to avoid relying on implementation details of the CLAMP macro/function --- solaris/Platform.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'solaris') diff --git a/solaris/Platform.c b/solaris/Platform.c index 6159c357..e7a70c2c 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -200,10 +200,7 @@ double Platform_setCPUValues(Meter* this, int cpu) { percent = v[0] + v[1] + v[2]; } - percent = CLAMP(percent, 0.0, 100.0); - if (isnan(percent)) { - percent = 0.0; - } + percent = isnan(percent) ? 0.0 : CLAMP(percent, 0.0, 100.0); v[CPU_METER_FREQUENCY] = NAN; -- cgit v1.2.3