-
Patch request
-
Resolution: Fixed
-
Trivial
-
4.0.0alpha1
-
AIX
-
Sprint 24
-
0.5
- One typecast is enough (no matter which one) because integer operand is casted to double when another operand is double:
/* --- kthr --- */ vmstat->kthr_r = (double)(cpustats.runque - last_runque) / (double)(now - last_clock); vmstat->kthr_b = (double)(cpustats.swpque - last_swpque) / (double)(now - last_clock); /* --- page --- */ vmstat->fi = (double)(memstats.pgins - last_pgins) / (double)(now - last_clock); vmstat->fo = (double)(memstats.pgouts - last_pgouts) / (double)(now - last_clock); vmstat->pi = (double)(memstats.pgspins - last_pgspins) / (double)(now - last_clock); vmstat->po = (double)(memstats.pgspouts - last_pgspouts) / (double)(now - last_clock); vmstat->fr = (double)(memstats.cycles - last_cycles) / (double)(now - last_clock); vmstat->sr = (double)(memstats.scans - last_scans) / (double)(now - last_clock); /* -- faults -- */ vmstat->in = (double)(cpustats.devintrs - last_devintrs) / (double)(now - last_clock); vmstat->sy = (double)(cpustats.syscall - last_syscall) / (double)(now - last_clock); vmstat->cs = (double)(cpustats.pswitch - last_pswitch) / (double)(now - last_clock);
- Typecast is not needed, 100.0 is of type double:
vmstat->ent = (double)lparstats.entitled_proc_capacity / 100.0;
- One typecast is enough:
dpcpu_wa += unused_purr * ((double)dlcpu_wa / (double)(dlcpu_wa + dlcpu_id)); dpcpu_id += unused_purr * ((double)dlcpu_id / (double)(dlcpu_wa + dlcpu_id));
- Typecasts not needed thanks to 100.0 and left-to-right associativity of multiplication and division:
vmstat->cpu_us = (double)dpcpu_us * 100.0 / (double)pcputime; vmstat->cpu_sy = (double)dpcpu_sy * 100.0 / (double)pcputime; vmstat->cpu_id = (double)dpcpu_id * 100.0 / (double)pcputime; vmstat->cpu_wa = (double)dpcpu_wa * 100.0 / (double)pcputime;
- One is enough:
vmstat->cpu_pc = (double)delta_purr / (double)dtimebase;
- Not needed, vmstat->cpu_pc is double:
vmstat->cpu_ec = (double)(vmstat->cpu_pc / vmstat->ent) * 100.0;
- Not needed:
vmstat->cpu_lbusy = (double)(dlcpu_us + dlcpu_sy) * 100.0 / (double)lcputime;
- One is enough:
vmstat->cpu_app = (double)(lparstats.pool_idle_time - last_pool_idle_time) / (XINTFRAC * (double)dtimebase);
- Not needed:
vmstat->cpu_us = (double)dlcpu_us * 100.0 / (double)lcputime; vmstat->cpu_sy = (double)dlcpu_sy * 100.0 / (double)lcputime; vmstat->cpu_id = (double)dlcpu_id * 100.0 / (double)lcputime; vmstat->cpu_wa = (double)dlcpu_wa * 100.0 / (double)lcputime;
- One is enough:
vmstat->disk_tps = (double)(diskstats.xfers - last_xfers) / (double)(now - last_clock);