]> granicus.if.org Git - sysstat/commitdiff
Use TIMESTAMP_LEN constant for timestamp buffers
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 3 Oct 2016 15:10:31 +0000 (17:10 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 3 Oct 2016 15:10:31 +0000 (17:10 +0200)
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 <sysstat@users.noreply.github.com>
12 files changed:
cifsiostat.c
common.c
common.h
iostat.c
mpstat.c
pidstat.c
sa.h
sa_common.c
sadf.c
sadf_misc.c
svg_stats.c
tapestat.c

index acdd7e57bf7ca7ae87eac113a4f3af5bde74a1be..704e9df02b1cafca24e92bc75b4db8ed03707007 100644 (file)
@@ -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;
 
index 1bd4b2f0fd4e44e69bcf220f03799ceba32652bb..603b62d253494c536427bdc8805c1c6d4b4356a0 100644 (file)
--- 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) {
index 68176b9f20954388b17214b71c2cadf87c12ea87..6b58aa5887e71d03c66258e63ecd9d474859a300 100644 (file)
--- 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
 
index c1a099719ded6f5f7f371ada27697c2ed7a33ca6..1827ec03d9f8ab2427041e8420d77a91281cf5d9 100644 (file)
--- 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;
 
index ff7babe7cb3ae7260805d0712dbca469cdf0c41e..8fa3fc151343e3b60f9c6a5e067dd5683f599c99 100644 (file)
--- 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()) {
index 19a2532552cfa3ccb40397701daff58279f610df..35c780e36024af238ceb836af4a6848b45b64a70 100644 (file)
--- 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 f76ff66aec81ed9f99204342330e5063112c4874..2cfb4b58e862f68603133051e049eb3939ad958a 100644 (file)
--- a/sa.h
+++ b/sa.h
 #define BITMAP_SIZE(m) ((((m) + 1) / 8) + 1)
 
 #define UTSNAME_LEN    65
-#define TIMESTAMP_LEN  64
 #define HEADER_LINE_LEN        512
 
 /*
index f014f9ef14a65e918b248acca8bd4919f352a0e8..d8bc089068a76cb6fb94c7dfeb42b9c43b941ab6 100644 (file)
@@ -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 85e749872c51bd104bab21bf3babd9ef25c0b9d8..fc7a9756bbe0b08700c6e9b9d5d9cf70795d80d6 100644 (file)
--- 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,
index 97f34246cce10d2f2b2353e7b60d69bcedc4f665..714d40d0ae597f8373030d488de5ee3638ed3125 100644 (file)
@@ -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) {
index 0e995598fe586c185b55c8fc3450e9d4eb480dd9..bcbd83c64b7b53c1f6ba2d88ea1bf81990648ddf 100644 (file)
@@ -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("<polyline points=\"%ld,0 %ld,%d\" style=\"vector-effect: non-scaling-stroke; "
                       "stroke: #202020\" transform=\"scale(%f,1)\"/>\n",
                       xpos * j, xpos * j, -SVG_G_YSIZE, xfactor);
index 20b6701eec4d0dad30532968629db6c42345beb6..b06d1d571062a1df3c33a7786d368fde02ae3741 100644 (file)
@@ -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;