Skip to content

Commit

Permalink
Use TIMESTAMP_LEN constant for timestamp buffers
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sysstat committed Oct 3, 2016
1 parent 6d74e12 commit 3664a8e
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cifsiostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion iostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion mpstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion pidstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
1 change: 0 additions & 1 deletion sa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*
Expand Down
4 changes: 2 additions & 2 deletions sa_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions sadf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions sadf_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions svg_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tapestat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3664a8e

Please sign in to comment.