From 4c0b69f385fb9b796fc53924eec1b88262d3c7c6 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 27 May 2020 00:00:00 -0500 Subject: [PATCH] top: address each of the most recent coverity warnings This patch attempts to supress the following warnings: . MISSING_BREAK, TAINTED_SCALAR plus SIZEOF_MISMATCH . Signed-off-by: Jim Warner --- top/top.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index f5076e40..6e2048ec 100644 --- a/top/top.c +++ b/top/top.c @@ -3472,6 +3472,8 @@ static int config_osel (FILE *fp, char *buf, size_t size) { if (2 != sscanf(buf, Osel_window_fmts, &wno, &tot)) goto end_oops; + if (wno < 0 || wno >= GROUPSMAX) goto end_oops; + if (tot < 0) goto end_oops; for (i = 0; i < tot; i++) { if (!fgets(buf, size, fp)) return 1; @@ -3561,16 +3563,21 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) { case 'a': // 3.2.8 (former procps) if (config_cvt(w)) return p; + // fall through case 'f': // 3.3.0 thru 3.3.3 (ng) SETw(w, Show_JRNUMS); + // fall through case 'g': // from 3.3.4 thru 3.3.8 scat(w->rc.fieldscur, RCF_PLUS_H); + // fall through case 'h': // this is release 3.3.9 w->rc.graph_cpus = w->rc.graph_mems = 0; // these next 2 are really global, but best documented here Rc.summ_mscale = Rc.task_mscale = SK_Kb; + // fall through case 'i': // actual RCF_VERSION_ID scat(w->rc.fieldscur, RCF_PLUS_J); + // fall through case 'j': // and the next version default: if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1) @@ -4597,7 +4604,7 @@ static void other_filters (int ch) { i = 0; osel = w->osel_1st; - pp = alloc_c((w->osel_tot + 1) * sizeof(char **)); + pp = alloc_c((w->osel_tot + 1) * sizeof(char *)); while (osel && i < w->osel_tot) { pp[i++] = osel->raw; osel = osel->nxt;