From 072a8507619cfd380db830404f49fc374d6a67ff Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 20 Aug 2020 00:00:00 -0500 Subject: [PATCH] top: more useless cosemetic changes (chiefly comments) All of these changes are self-explanatory, so I'll not provide any more comments thus avoiding further shame. [ everything's perfectly justified and right margins ] [ are filled entirely, but of course it must be luck ] Signed-off-by: Jim Warner --- top/top.c | 38 +++++++++++++++++++++++--------------- top/top.h | 2 +- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/top/top.c b/top/top.c index 0d48087d..57ea3743 100644 --- a/top/top.c +++ b/top/top.c @@ -5728,9 +5728,15 @@ static void keys_xtra (int ch) { /*###### Cpu Display Secondary support (summary_show helpers) ##########*/ /* - * Cpu *Helper* function to combine and or show the state - * percentages for 1 cpu or 2 adjacent cpus (one single line). */ -static inline int cpu_prt (const char *str, int nobuf) { + * note how alphabetical order is maintained within carefully chosen | + * function names such as: (s)cpu_see, (t)cpu_tics, and (u)cpu_unify | + * with each name exactly 1 letter more than the preceeding function | + * ( surely, this must make us run much more efficiently. amirite? ) | */ + + /* + * Cpu *Helper* function to show the percentages for one or two cpus | + * as a single line. We return the number of lines actually printed. | */ +static inline int cpu_see (const char *str, int nobuf) { static char row[ROWMINSIZ]; static int tog; char *p; @@ -5748,17 +5754,18 @@ static inline int cpu_prt (const char *str, int nobuf) { row[0] = '\0'; tog = 0; return 1; -} // end: cpu_prt +} // end: cpu_see /* - * State display *Helper* function to calc and display the state - * percentages for a single cpu. In this way, we can support - * the following environments without the usual code bloat. - * 1) single cpu machines - * 2) modest smp boxes with room for each cpu's percentages - * 3) massive smp guys leaving little or no room for process - * display and thus requiring the cpu summary toggle */ + * State display *Helper* function to calculate plus display (maybe) | + * the percentages for a single cpu. In this way, we'll support the | + * following environments without (hopefully) that usual code bloat: | + * 1) single cpu platforms (no matter the paucity of these types) | + * 2) modest smp boxes with ample room for each cpu's percentages | + * 3) massive smp guys leaving little or no room for that process | + * display and thus requiring the '1', '4', or '!' cpu toggles | + * ( we return the number of lines printed, as reported by cpu_see ) | */ static int cpu_tics (CPU_t *cpu, const char *pfx, int nobuf) { /* we'll trim to zero if we get negative time ticks, which has happened with some SMP kernels (pre-2.4?) @@ -5808,10 +5815,10 @@ static int cpu_tics (CPU_t *cpu, const char *pfx, int nobuf) { snprintf(syst, sizeof(syst), gtab[ix].syst, (int)((pct_syst * Graph_adj) + .4), gtab[ix].type); #endif snprintf(dual, sizeof(dual), "%s%s", user, syst); - return cpu_prt(fmtmk("%s ~3%#5.1f~2/%-#5.1f~3 %3.0f[~1%-*s]~1" + return cpu_see(fmtmk("%s ~3%#5.1f~2/%-#5.1f~3 %3.0f[~1%-*s]~1" , pfx, pct_user, pct_syst, pct_user + pct_syst, Graph_len +4, dual), nobuf); } else { - return cpu_prt(fmtmk(Cpu_States_fmts, pfx + return cpu_see(fmtmk(Cpu_States_fmts, pfx , (float)u_frme * scale, (float)s_frme * scale , (float)n_frme * scale, (float)i_frme * scale , (float)w_frme * scale, (float)x_frme * scale @@ -5822,8 +5829,9 @@ static int cpu_tics (CPU_t *cpu, const char *pfx, int nobuf) { /* - * Cpu *Helper* function to combine adjacent cpu stats - * in an effort to reduce total number of processors shown */ + * Cpu *Helper* function to combine additional cpu statistics in our | + * efforts to reduce the total number of processors that'll be shown | + * ( we return the number of lines printed, as reported by cpu_see ) | */ static int cpu_unify (CPU_t *cpu, int nobuf) { static CPU_t accum; static int ix, beg; diff --git a/top/top.h b/top/top.h index 34c085b3..c4d4e859 100644 --- a/top/top.h +++ b/top/top.h @@ -802,7 +802,7 @@ typedef struct WIN_t { //atic void keys_window (int ch); //atic void keys_xtra (int ch); /*------ Cpu Display Secondary Support (summary_show helpers) ----------*/ -//atic inline int cpu_prt (const char *str, int nobuf); +//atic inline int cpu_see (const char *str, int nobuf); //atic int cpu_tics (CPU_t *cpu, const char *pfx, int nobuf); //atic int cpu_unify (CPU_t *cpu, int nobuf); /*------ Main Screen routines ------------------------------------------*/