From f7af38558e5f56ed34ee4855061b4fd0f56d0f82 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 23 Dec 2017 17:04:21 +0100 Subject: [PATCH] A_SERIAL: Don't increment serial line number before saving The line number, as saved in the stats_serial structure, was used to determine if the structure was empty or not: A value of 0 used to mean that the structure was actually empty. As a consequence line #0 was saved with the value 1, line #1 was saved with the value 2, etc. This is no longer useful as structures are now dynamically allocated and we know exactly how many of them we have. So save now the real line number. Signed-off-by: Sebastien GODARD --- json_stats.c | 2 +- pr_stats.c | 2 +- rd_stats.c | 6 ------ rd_stats.h | 4 ---- rndr_stats.c | 12 ++++++------ xml_stats.c | 2 +- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/json_stats.c b/json_stats.c index 0e3723c..0df3780 100644 --- a/json_stats.c +++ b/json_stats.c @@ -683,7 +683,7 @@ __print_funct_t json_print_serial_stats(struct activity *a, int curr, int tab, "\"prtyerr\": %.2f, " "\"brk\": %.2f, " "\"ovrun\": %.2f}", - ssc->line - 1, + ssc->line, S_VALUE(ssp->rx, ssc->rx, itv), S_VALUE(ssp->tx, ssc->tx, itv), S_VALUE(ssp->frame, ssc->frame, itv), diff --git a/pr_stats.c b/pr_stats.c index bf973f8..e419af6 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -984,7 +984,7 @@ __print_funct_t print_serial_stats(struct activity *a, int prev, int curr, continue; printf("%-11s", timestamp[curr]); - cprintf_in(IS_INT, " %3d", "", ssc->line - 1); + cprintf_in(IS_INT, " %3d", "", ssc->line); cprintf_f(NO_UNIT, 6, 9, 2, S_VALUE(ssp->rx, ssc->rx, itv), diff --git a/rd_stats.c b/rd_stats.c index 3314d0c..1189844 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -766,12 +766,6 @@ __nr_t read_tty_driver_serial(struct stats_serial *st_serial, __nr_t nr_alloc) st_serial_i = st_serial + sl_read++; /* Read serial line number */ sscanf(line, "%u", &st_serial_i->line); - /* - * A value of 0 means an unused structure. - * So increment the value we have just read - * to make sure it is not zero. - */ - (st_serial_i->line)++; /* * Read the number of chars transmitted and received by * current serial line. diff --git a/rd_stats.h b/rd_stats.h index e6423bb..a67bfbf 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -221,10 +221,6 @@ struct stats_serial { unsigned int parity; unsigned int brk; unsigned int overrun; - /* - * A value of 0 means that the structure is unused. - * To avoid the confusion, the line number is saved as (line# + 1) - */ unsigned int line; }; diff --git a/rndr_stats.c b/rndr_stats.c index 2666ac8..7816f42 100644 --- a/rndr_stats.c +++ b/rndr_stats.c @@ -1003,42 +1003,42 @@ __print_funct_t render_serial_stats(struct activity *a, int isdb, char *pre, render(isdb, pre, PT_NOFLAG, "ttyS%d\trcvin/s", "%d", - cons(iv, ssc->line - 1, NOVAL), + cons(iv, ssc->line, NOVAL), NOVAL, S_VALUE(ssp->rx, ssc->rx, itv), NULL); render(isdb, pre, PT_NOFLAG, "ttyS%d\txmtin/s", NULL, - cons(iv, ssc->line - 1, NOVAL), + cons(iv, ssc->line, NOVAL), NOVAL, S_VALUE(ssp->tx, ssc->tx, itv), NULL); render(isdb, pre, PT_NOFLAG, "ttyS%d\tframerr/s", NULL, - cons(iv, ssc->line - 1, NOVAL), + cons(iv, ssc->line, NOVAL), NOVAL, S_VALUE(ssp->frame, ssc->frame, itv), NULL); render(isdb, pre, PT_NOFLAG, "ttyS%d\tprtyerr/s", NULL, - cons(iv, ssc->line - 1, NOVAL), + cons(iv, ssc->line, NOVAL), NOVAL, S_VALUE(ssp->parity, ssc->parity, itv), NULL); render(isdb, pre, PT_NOFLAG, "ttyS%d\tbrk/s", NULL, - cons(iv, ssc->line - 1, NOVAL), + cons(iv, ssc->line, NOVAL), NOVAL, S_VALUE(ssp->brk, ssc->brk, itv), NULL); render(isdb, pre, pt_newlin, "ttyS%d\tovrun/s", NULL, - cons(iv, ssc->line - 1, NOVAL), + cons(iv, ssc->line, NOVAL), NOVAL, S_VALUE(ssp->overrun, ssc->overrun, itv), NULL); diff --git a/xml_stats.c b/xml_stats.c index 9f92b86..b2b9c78 100644 --- a/xml_stats.c +++ b/xml_stats.c @@ -670,7 +670,7 @@ __print_funct_t xml_print_serial_stats(struct activity *a, int curr, int tab, "prtyerr=\"%.2f\" " "brk=\"%.2f\" " "ovrun=\"%.2f\"/>", - ssc->line - 1, + ssc->line, S_VALUE(ssp->rx, ssc->rx, itv), S_VALUE(ssp->tx, ssc->tx, itv), S_VALUE(ssp->frame, ssc->frame, itv), -- 2.40.0