Hi tech@, In usr.bin/systat/cpu.c, if allocating memory failed, it seems no need to return value, call "err()" function may be better (refer usr.bin/systat/vmstat.c). Apologize if I'm wrong, thanks!
Index: cpu.c =================================================================== RCS file: /cvs/src/usr.bin/systat/cpu.c,v retrieving revision 1.5 diff -u -p -r1.5 cpu.c --- cpu.c 2 Jan 2016 20:02:40 -0000 1.5 +++ cpu.c 7 May 2018 05:40:07 -0000 @@ -50,6 +50,7 @@ #include <sys/sched.h> #include <sys/sysctl.h> +#include <err.h> #include <stdlib.h> #include <stdint.h> #include <string.h> @@ -200,16 +201,16 @@ initcpu(void) return (-1); if ((cpu_states = calloc(cpu_count, CPUSTATES * sizeof(int64_t))) == NULL) - return (-1); + err(2, NULL); if ((cpu_tm = calloc(cpu_count, sizeof(int64_t *))) == NULL || (cpu_old = calloc(cpu_count, sizeof(int64_t *))) == NULL || (cpu_diff = calloc(cpu_count, sizeof(int64_t *))) == NULL) - return (-1); + err(2, NULL); for (i = 0; i < cpu_count; i++) { if ((cpu_tm[i] = calloc(CPUSTATES, sizeof(int64_t))) == NULL || (cpu_old[i] = calloc(CPUSTATES, sizeof(int64_t))) == NULL || (cpu_diff[i] = calloc(CPUSTATES, sizeof(int64_t))) == NULL) - return (-1); + err(2, NULL); } for (v = views_cpu; v->name != NULL; v++) -- Best Regards Nan Xiao