]> granicus.if.org Git - sysstat/commitdiff
sadf: PCP: Simplify code used to take into account timezone value
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 30 Mar 2019 07:55:04 +0000 (08:55 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 30 Mar 2019 07:55:04 +0000 (08:55 +0100)
flags variable is already a global one. Don't need to pass it
explicitly.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sa.h
sadf.c
sadf_misc.c

diff --git a/sa.h b/sa.h
index 7a756e6eaf790473a7f71a71c600abc1abb30541..193ecaff58a87b8b80b02e762d182ba4f8099034 100644 (file)
--- a/sa.h
+++ b/sa.h
 /* Type for all functions displaying statistics */
 #define __print_funct_t void
 
-/* Structure containing specific parameters for logic#1 output (XML/JSON/PCP...) */
-struct log1_parm {
-       unsigned int flags;     /* Common flags */
-       int tab;                /* Number of tabulations */
-};
-
 /* Structure for SVG specific parameters */
 struct svg_parm {
        unsigned long long dt;                  /* Interval of time for current sample */
diff --git a/sadf.c b/sadf.c
index 267cf490117cadfc181f9283f19bcfc1138e3d45..fbdb8b1c57d0b75a321dad12b8d6c049358e2382 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -1012,8 +1012,7 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
                         char *pcparchive, struct file_magic *file_magic,
                         struct tm *rectime, struct tm *loctime)
 {
-       struct log1_parm parm;
-       int curr, rtype;
+       int curr, rtype, tab = 0;
        int eosaf, next, reset = FALSE;
        long cnt = 1;
 
@@ -1030,18 +1029,15 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
        /* Save current file position */
        seek_file_position(ifd, DO_SAVE);
 
-       parm.tab = 0;
-       parm.flags = flags;
-
        /* Print header (eg. XML file header) */
        if (*fmt[f_position]->f_header) {
-               (*fmt[f_position]->f_header)(&parm, F_BEGIN, pcparchive, file_magic,
+               (*fmt[f_position]->f_header)(&tab, F_BEGIN, pcparchive, file_magic,
                                             &file_hdr, act, id_seq, file_actlst);
        }
 
        /* Process activities */
        if (*fmt[f_position]->f_statistics) {
-               (*fmt[f_position]->f_statistics)(&(parm.tab), F_BEGIN, act, id_seq);
+               (*fmt[f_position]->f_statistics)(&tab, F_BEGIN, act, id_seq);
        }
 
        do {
@@ -1051,7 +1047,7 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
                 */
                do {
                        eosaf = read_next_sample(ifd, IGNORE_COMMENT | IGNORE_RESTART, 0,
-                                                file, &rtype, parm.tab, file_magic, file_actlst,
+                                                file, &rtype, tab, file_magic, file_actlst,
                                                 rectime, loctime, UEOF_STOP);
                }
                while (!eosaf && ((rtype == R_RESTART) || (rtype == R_COMMENT) ||
@@ -1068,17 +1064,17 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
                if (!eosaf) {
                        do {
                                eosaf = read_next_sample(ifd, IGNORE_COMMENT | IGNORE_RESTART, curr,
-                                                        file, &rtype, parm.tab, file_magic, file_actlst,
+                                                        file, &rtype, tab, file_magic, file_actlst,
                                                         rectime, loctime, UEOF_CONT);
 
                                if (!eosaf && (rtype != R_COMMENT) && (rtype != R_RESTART)) {
                                        if (*fmt[f_position]->f_statistics) {
-                                               (*fmt[f_position]->f_statistics)(&(parm.tab), F_MAIN, act, id_seq);
+                                               (*fmt[f_position]->f_statistics)(&tab, F_MAIN, act, id_seq);
                                        }
 
                                        /* next is set to 1 when we were close enough to desired interval */
                                        next = generic_write_stats(curr, tm_start.use, tm_end.use, reset,
-                                                                 &cnt, &(parm.tab), rectime, loctime,
+                                                                 &cnt, &tab, rectime, loctime,
                                                                  FALSE, ALL_ACTIVITIES);
 
                                        if (next) {
@@ -1096,7 +1092,7 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
                                /* Go to next Linux restart, if possible */
                                do {
                                        eosaf = read_next_sample(ifd, IGNORE_COMMENT | IGNORE_RESTART, curr,
-                                                                file, &rtype, parm.tab, file_magic, file_actlst,
+                                                                file, &rtype, tab, file_magic, file_actlst,
                                                                 rectime, loctime, UEOF_CONT);
                                }
                                while (!eosaf && (rtype != R_RESTART));
@@ -1107,7 +1103,7 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
        while (!eosaf);
 
        if (*fmt[f_position]->f_statistics) {
-               (*fmt[f_position]->f_statistics)(&(parm.tab), F_END, act, id_seq);
+               (*fmt[f_position]->f_statistics)(&tab, F_END, act, id_seq);
        }
 
        /* Rewind file */
@@ -1115,19 +1111,19 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
 
        /* Process now RESTART entries to display restart messages */
        if (*fmt[f_position]->f_restart) {
-               (*fmt[f_position]->f_restart)(&(parm.tab), F_BEGIN, NULL, NULL, FALSE,
+               (*fmt[f_position]->f_restart)(&tab, F_BEGIN, NULL, NULL, FALSE,
                                              &file_hdr);
        }
 
        do {
                eosaf = read_next_sample(ifd, IGNORE_COMMENT, 0,
-                                        file, &rtype, parm.tab, file_magic, file_actlst,
+                                        file, &rtype, tab, file_magic, file_actlst,
                                         rectime, loctime, UEOF_CONT);
        }
        while (!eosaf);
 
        if (*fmt[f_position]->f_restart) {
-               (*fmt[f_position]->f_restart)(&(parm.tab), F_END, NULL, NULL, FALSE, &file_hdr);
+               (*fmt[f_position]->f_restart)(&tab, F_END, NULL, NULL, FALSE, &file_hdr);
        }
 
        /* Rewind file */
@@ -1136,25 +1132,25 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
        /* Last, process COMMENT entries to display comments */
        if (DISPLAY_COMMENT(flags)) {
                if (*fmt[f_position]->f_comment) {
-                       (*fmt[f_position]->f_comment)(&(parm.tab), F_BEGIN, NULL, NULL, 0, NULL,
+                       (*fmt[f_position]->f_comment)(&tab, F_BEGIN, NULL, NULL, 0, NULL,
                                                      &file_hdr);
                }
                do {
                        eosaf = read_next_sample(ifd, IGNORE_RESTART, 0,
-                                                file, &rtype, parm.tab, file_magic, file_actlst,
+                                                file, &rtype, tab, file_magic, file_actlst,
                                                 rectime, loctime, UEOF_CONT);
                }
                while (!eosaf);
 
                if (*fmt[f_position]->f_comment) {
-                       (*fmt[f_position]->f_comment)(&(parm.tab), F_END, NULL, NULL, 0, NULL,
+                       (*fmt[f_position]->f_comment)(&tab, F_END, NULL, NULL, 0, NULL,
                                                      &file_hdr);
                }
        }
 
        /* Print header trailer */
        if (*fmt[f_position]->f_header) {
-               (*fmt[f_position]->f_header)(&parm, F_END, pcparchive, file_magic,
+               (*fmt[f_position]->f_header)(&tab, F_END, pcparchive, file_magic,
                                             &file_hdr, act, id_seq, file_actlst);
        }
 }
index 36b820c937f41c073ab5c1c8517fc49e39e79797..713b6744f95ce9977e900e43ee8dc7e759cba456 100644 (file)
@@ -863,7 +863,7 @@ __printf_funct_t print_xml_header(void *parm, int action, char *dfile,
 {
        struct tm rectime, loc_t;
        char cur_time[TIMESTAMP_LEN];
-       int *tab = &(((struct log1_parm *) parm)->tab);
+       int *tab = (int *) tab;
 
        if (action & F_BEGIN) {
                printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
@@ -931,7 +931,7 @@ __printf_funct_t print_json_header(void *parm, int action, char *dfile,
 {
        struct tm rectime, loc_t;
        char cur_time[TIMESTAMP_LEN];
-       int *tab = &(((struct log1_parm *) parm)->tab);
+       int *tab = (int *) parm;
 
        if (action & F_BEGIN) {
                xprintf(*tab, "{\"sysstat\": {");
@@ -1175,7 +1175,7 @@ __printf_funct_t print_svg_header(void *parm, int action, char *dfile,
  * PCP header function.
  *
  * IN:
- * @parm       Specific parameter.
+ * @parm       Specific parameter (unused here).
  * @action     Action expected from current function.
  * @dfile      Name of PCP archive file.
  * @file_magic System activity file magic header (unused here).
@@ -1192,14 +1192,13 @@ __printf_funct_t print_pcp_header(void *parm, int action, char *dfile,
                                  struct file_activity *file_actlst)
 {
 #ifdef HAVE_PCP
-       unsigned int lflags = ((struct log1_parm *) parm)->flags;
        char buf[64];
 
        if (action & F_BEGIN) {
                /* Create new PCP context */
                pmiStart(dfile, FALSE);
 
-               if (PRINT_LOCAL_TIME(lflags)) {
+               if (PRINT_LOCAL_TIME(flags)) {
                        tzset();        /* Set timezone value in tzname */
                        pmiSetTimezone(tzname[0]);
                }