From 636109108bfdb4ab97658d6c861cd7bbac8ad969 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 30 Mar 2019 08:55:04 +0100 Subject: [PATCH] sadf: PCP: Simplify code used to take into account timezone value flags variable is already a global one. Don't need to pass it explicitly. Signed-off-by: Sebastien GODARD --- sa.h | 6 ------ sadf.c | 36 ++++++++++++++++-------------------- sadf_misc.c | 9 ++++----- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/sa.h b/sa.h index 7a756e6..193ecaf 100644 --- a/sa.h +++ b/sa.h @@ -315,12 +315,6 @@ /* 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 267cf49..fbdb8b1 100644 --- 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); } } diff --git a/sadf_misc.c b/sadf_misc.c index 36b820c..713b674 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -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("\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]); } -- 2.40.0