From 3664a8eedf5968b47e2829765d9f789674ea1211 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Mon, 3 Oct 2016 17:10:31 +0200 Subject: [PATCH] Use TIMESTAMP_LEN constant for timestamp buffers Several buffers were used to hold timestamps, with different sizes (sometimes 16, 32 or 64 characters). Now define and use a single size for all of them (TIMESTAMP_LEN). Signed-off-by: Sebastien GODARD --- cifsiostat.c | 2 +- common.c | 2 +- common.h | 3 +++ iostat.c | 2 +- mpstat.c | 2 +- pidstat.c | 2 +- sa.h | 1 - sa_common.c | 4 ++-- sadf.c | 4 ++-- sadf_misc.c | 6 +++--- svg_stats.c | 4 ++-- tapestat.c | 2 +- 12 files changed, 18 insertions(+), 16 deletions(-) diff --git a/cifsiostat.c b/cifsiostat.c index acdd7e5..704e9df 100644 --- a/cifsiostat.c +++ b/cifsiostat.c @@ -53,7 +53,7 @@ int cpu_nr = 0; /* Nb of processors on the machine */ int flags = 0; /* Flag for common options and system state */ long interval = 0; -char timestamp[64]; +char timestamp[TIMESTAMP_LEN]; struct sigaction alrm_act; diff --git a/common.c b/common.c index 1bd4b2f..603b62d 100644 --- a/common.c +++ b/common.c @@ -432,7 +432,7 @@ void xprintf(int nr_tab, const char *fmtf, ...) int print_gal_header(struct tm *rectime, char *sysname, char *release, char *nodename, char *machine, int cpu_nr, int format) { - char cur_date[64]; + char cur_date[TIMESTAMP_LEN]; int rc = 0; if (rectime == NULL) { diff --git a/common.h b/common.h index 68176b9..6b58aa5 100644 --- a/common.h +++ b/common.h @@ -33,6 +33,9 @@ #define DISP_HDR 1 +/* Timestamp buffer length */ +#define TIMESTAMP_LEN 64 + /* Number of seconds per day */ #define SEC_PER_DAY 3600 * 24 diff --git a/iostat.c b/iostat.c index c1a0997..1827ec0 100644 --- a/iostat.c +++ b/iostat.c @@ -69,7 +69,7 @@ int flags = 0; /* Flag for common options and system state */ unsigned int dm_major; /* Device-mapper major number */ long interval = 0; -char timestamp[64]; +char timestamp[TIMESTAMP_LEN]; struct sigaction alrm_act; diff --git a/mpstat.c b/mpstat.c index ff7babe..8fa3fc1 100644 --- a/mpstat.c +++ b/mpstat.c @@ -1223,7 +1223,7 @@ void write_stats_avg(int curr, int dis) */ void write_stats(int curr, int dis) { - char cur_time[2][16]; + char cur_time[2][TIMESTAMP_LEN]; /* Get previous timestamp */ if (is_iso_time_fmt()) { diff --git a/pidstat.c b/pidstat.c index 19a2532..35c780e 100644 --- a/pidstat.c +++ b/pidstat.c @@ -2320,7 +2320,7 @@ void write_stats_avg(int curr, int dis) */ int write_stats(int curr, int dis) { - char cur_time[2][16]; + char cur_time[2][TIMESTAMP_LEN]; /* Get previous timestamp */ if (is_iso_time_fmt()) { diff --git a/sa.h b/sa.h index f76ff66..2cfb4b5 100644 --- a/sa.h +++ b/sa.h @@ -224,7 +224,6 @@ #define BITMAP_SIZE(m) ((((m) + 1) / 8) + 1) #define UTSNAME_LEN 65 -#define TIMESTAMP_LEN 64 #define HEADER_LINE_LEN 512 /* diff --git a/sa_common.c b/sa_common.c index f014f9e..d8bc089 100644 --- a/sa_common.c +++ b/sa_common.c @@ -2290,7 +2290,7 @@ int print_special_record(struct record_header *record_hdr, unsigned int l_flags, struct file_magic *file_magic, struct file_header *file_hdr, struct activity *act[], struct report_format *ofmt) { - char cur_date[32], cur_time[32]; + char cur_date[TIMESTAMP_LEN], cur_time[TIMESTAMP_LEN]; int dp = 1; unsigned int new_cpu_nr; @@ -2312,7 +2312,7 @@ int print_special_record(struct record_header *record_hdr, unsigned int l_flags, else { /* Set date and time strings to be displayed for current record */ set_record_timestamp_string(l_flags, record_hdr, - cur_date, cur_time, 32, rectime); + cur_date, cur_time, TIMESTAMP_LEN, rectime); } if (rtype == R_RESTART) { diff --git a/sadf.c b/sadf.c index 85e7498..fc7a975 100644 --- a/sadf.c +++ b/sadf.c @@ -578,7 +578,7 @@ int generic_write_stats(int curr, int use_tm_start, int use_tm_end, int reset, { int i; unsigned long long dt, itv, g_itv; - char cur_date[32], cur_time[32], *pre = NULL; + char cur_date[TIMESTAMP_LEN], cur_time[TIMESTAMP_LEN], *pre = NULL; static int cross_day = FALSE; if (reset_cd) { @@ -642,7 +642,7 @@ int generic_write_stats(int curr, int use_tm_start, int use_tm_end, int reset, /* Set date and time strings for current record */ set_record_timestamp_string(flags, &record_hdr[curr], - cur_date, cur_time, 32, rectime); + cur_date, cur_time, TIMESTAMP_LEN, rectime); if (*fmt[f_position]->f_timestamp) { pre = (char *) (*fmt[f_position]->f_timestamp)(parm, F_BEGIN, cur_date, cur_time, diff --git a/sadf_misc.c b/sadf_misc.c index 97f3424..714d40d 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -617,7 +617,7 @@ __printf_funct_t print_xml_header(void *parm, int action, char *dfile, struct activity *act[], unsigned int id_seq[]) { struct tm rectime, *loc_t; - char cur_time[32]; + char cur_time[TIMESTAMP_LEN]; int *tab = (int *) parm; if (action & F_BEGIN) { @@ -684,7 +684,7 @@ __printf_funct_t print_json_header(void *parm, int action, char *dfile, struct activity *act[], unsigned int id_seq[]) { struct tm rectime, *loc_t; - char cur_time[32]; + char cur_time[TIMESTAMP_LEN]; int *tab = (int *) parm; if (action & F_BEGIN) { @@ -742,7 +742,7 @@ __printf_funct_t print_hdr_header(void *parm, int action, char *dfile, { int i, p; struct tm rectime, *loc_t; - char cur_time[32]; + char cur_time[TIMESTAMP_LEN]; /* Actions F_MAIN and F_END ignored */ if (action & F_BEGIN) { diff --git a/svg_stats.c b/svg_stats.c index 0e99559..bcbd83c 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -617,7 +617,7 @@ void display_vgrid(long int xpos, double xfactor, int v_gridnr, struct svg_parm { struct record_header stamp; struct tm rectime; - char cur_time[32]; + char cur_time[TIMESTAMP_LEN]; int j; stamp.ust_time = svg_p->ust_time_ref; /* Only ust_time field needs to be set. TRUE_TIME not allowed */ @@ -626,7 +626,7 @@ void display_vgrid(long int xpos, double xfactor, int v_gridnr, struct svg_parm /* Display vertical lines */ sa_get_record_timestamp_struct(flags, &stamp, &rectime, NULL); - set_record_timestamp_string(flags, &stamp, NULL, cur_time, 32, &rectime); + set_record_timestamp_string(flags, &stamp, NULL, cur_time, TIMESTAMP_LEN, &rectime); printf("\n", xpos * j, xpos * j, -SVG_G_YSIZE, xfactor); diff --git a/tapestat.c b/tapestat.c index 20b6701..b06d1d5 100644 --- a/tapestat.c +++ b/tapestat.c @@ -59,7 +59,7 @@ int cpu_nr = 0; /* Nb of processors on the machine */ int flags = 0; /* Flag for common options and system state */ long interval = 0; -char timestamp[64]; +char timestamp[TIMESTAMP_LEN]; struct sigaction alrm_act; -- 2.40.0