]> granicus.if.org Git - sysstat/commitdiff
Remove hardcoded size values
authorSebastien GODARD <sysstat@orange.fr.fake>
Fri, 17 Jan 2014 20:46:38 +0000 (21:46 +0100)
committerSebastien GODARD <sysstat@orange.fr.fake>
Fri, 17 Jan 2014 20:46:38 +0000 (21:46 +0100)
Use sizeof() macro instead of hardcoded size values in various parts of
the code.

Signed-off-by: Sebastien GODARD <sysstat@orange.fr.fake>
cifsiostat.c
common.c
count.c
iostat.c
mpstat.c
nfsiostat.c
pidstat.c
rd_stats.c
sadf_misc.c

index 44cd4be5d2fa8e0c6b3fffd8baa888dbca1ff6aa..04b561f006871797ca73eb9aef50731486df19d9 100644 (file)
@@ -113,7 +113,7 @@ int get_cifs_nr(void)
                /* File non-existent */
                return 0;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                
                if (!strncmp(line, "Share (unique mount targets): ", 30)) {
                        sscanf(line + 30, "%d", &cifs);
@@ -330,7 +330,7 @@ void read_cifs_stat(int curr)
        sprintf(aux, "%%*d) %%%ds",
                MAX_NAME_LEN < 200 ? MAX_NAME_LEN - 1 : 200);
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                /* Read CIFS directory name */
                if (isdigit((unsigned char) line[0]) && sscanf(line, aux , name_tmp) == 1) {
index 04a3f647ca878c7b1c053deef501839335aa93df..2f97ce31a058d4b2261dc03857c493ec03afda9d 100644 (file)
--- a/common.c
+++ b/common.c
@@ -297,7 +297,7 @@ unsigned int get_devmap_major(void)
        if ((fp = fopen(DEVICES, "r")) == NULL)
                return dm_major;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (strstr(line, "device-mapper")) {
                        /* Read device-mapper major number */
diff --git a/count.c b/count.c
index 780e7ad2f30f411f27b4732524d891e88fee45b9..856d0fae082c51ed2049ca7cd1bbd7741d56edc1 100644 (file)
--- a/count.c
+++ b/count.c
@@ -119,7 +119,7 @@ int get_proc_cpu_nr(void)
                exit(1);
        }
 
-       while (fgets(line, 16, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (strncmp(line, "cpu ", 4) && !strncmp(line, "cpu", 3)) {
                        sscanf(line + 3, "%d", &num_proc);
@@ -244,7 +244,7 @@ int get_diskstats_dev_nr(int count_part, int only_used_dev)
         * Counting devices and partitions is simply a matter of counting
         * the number of lines...
         */
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                if (!count_part) {
                        i = sscanf(line, "%*d %*d %s %lu %*u %*u %*u %lu",
                                   dev_name, &rd_ios, &wr_ios);
@@ -284,7 +284,7 @@ int get_irq_nr(void)
        if ((fp = fopen(STAT, "r")) == NULL)
                return 0;
 
-       while (fgets(line, 8192, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "intr ", 5)) {
 
@@ -318,7 +318,7 @@ int get_serial_nr(void)
        if ((fp = fopen(SERIAL, "r")) == NULL)
                return 0;       /* No SERIAL file */
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                /*
                 * tx/rx statistics are always present,
                 * except when serial line is unknown.
@@ -351,7 +351,7 @@ int get_iface_nr(void)
        if ((fp = fopen(NET_DEV, "r")) == NULL)
                return 0;       /* No network device file */
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                if (strchr(line, ':')) {
                        iface++;
                }
@@ -407,7 +407,7 @@ int get_freq_nr(void)
        if ((fp = fopen(filename, "r")) == NULL)
                return 0;       /* No time_in_state file for CPU#0 */
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                freq++;
        }
 
@@ -470,7 +470,7 @@ int get_filesystem_nr(void)
                return 0;
 
        /* Get current filesystem */
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                if (line[0] == '/') {
                        
                        /* Read filesystem name and mount point */
index 9f0094ca5d072c8f3dd9fdcdff980ce44687e9a9..bff74cb6bee7fefe95d466d9d43be7da67274cb9 100644 (file)
--- a/iostat.c
+++ b/iostat.c
@@ -693,7 +693,7 @@ void read_diskstats_stat(int curr)
        if ((fp = fopen(DISKSTATS, "r")) == NULL)
                return;
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                /* major minor name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq */
                i = sscanf(line, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %u %u %u %u",
index e20c3a8d63898e1f24aaf55f297699ed0ff4c33e..e1eeefcf339b6a35f34cf629278f99370d2a4509 100644 (file)
--- a/mpstat.c
+++ b/mpstat.c
@@ -614,10 +614,10 @@ void write_stats(int curr, int dis)
        char cur_time[2][16];
 
        /* Get previous timestamp */
-       strftime(cur_time[!curr], 16, "%X", &(mp_tstamp[!curr]));
+       strftime(cur_time[!curr], sizeof(cur_time[!curr]), "%X", &(mp_tstamp[!curr]));
 
        /* Get current timestamp */
-       strftime(cur_time[curr], 16, "%X", &(mp_tstamp[curr]));
+       strftime(cur_time[curr], sizeof(cur_time[curr]), "%X", &(mp_tstamp[curr]));
 
        write_stats_core(!curr, curr, dis, cur_time[!curr], cur_time[curr]);
 }
index e94df902ebe72394006f740fde91b52bc288a6cd..6e62465235718ae3af9455df00cd79b246540624 100644 (file)
@@ -134,7 +134,7 @@ int get_nfs_mount_nr(void)
                /* File non-existent */
                return 0;
 
-       while (fgets(line, 8192, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if ((strstr(line, "mounted")) && (strstr(line, "on")) &&
                    (strstr(line, "with")) && (strstr(line, "fstype"))) {
@@ -357,7 +357,7 @@ void read_nfs_stat(int curr)
        sprintf(aux, "%%%ds",
                MAX_NAME_LEN < 200 ? MAX_NAME_LEN-1 : 200);
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                /* Read NFS directory name */
                if (!strncmp(line, "device", 6)) {
                        sw = 0;
@@ -417,7 +417,7 @@ void read_nfs_stat(int curr)
                if ((sw == 3) && (!strncmp(prefix, "per-op", 6))) {
                        sw = 4;
                        while (sw == 4) {
-                               fgets(line, 256, fp);
+                               fgets(line, sizeof(line), fp);
                                sscanf(line, "%15s %lu", operation, &v1);
                                if (!strncmp(operation, "READ:", 5)) {
                                        snfs.nfs_rops = v1;
index 9cc59b65db01d40dbe52900dcb81582333aac4ef..24bf347a248fad8ca0cb6bc24fc681ce05ee18d1 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -385,7 +385,7 @@ int read_proc_pid_status(unsigned int pid, struct pid_stats *pst,
                /* No such process */
                return 1;
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Uid:", 4)) {
                        sscanf(line + 5, "%d", &pst->uid);
@@ -566,7 +566,7 @@ int read_proc_pid_io(unsigned int pid, struct pid_stats *pst,
                return 0;
        }
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "read_bytes:", 11)) {
                        sscanf(line + 12, "%llu", &pst->read_bytes);
@@ -2150,10 +2150,10 @@ int write_stats(int curr, int dis)
        char cur_time[2][16];
 
        /* Get previous timestamp */
-       strftime(cur_time[!curr], 16, "%X", &ps_tstamp[!curr]);
+       strftime(cur_time[!curr], sizeof(cur_time[!curr]), "%X", &ps_tstamp[!curr]);
 
        /* Get current timestamp */
-       strftime(cur_time[curr], 16, "%X", &ps_tstamp[curr]);
+       strftime(cur_time[curr], sizeof(cur_time[curr]), "%X", &ps_tstamp[curr]);
 
        return (write_stats_core(!curr, curr, dis, FALSE,
                                 cur_time[!curr], cur_time[curr]));
index 5c1c82f7356414cd71d42e683a65ad065c7581cb..d7efbd461ca0b356c693836c9b9c23b576d0b95e 100644 (file)
@@ -70,7 +70,7 @@ void read_stat_cpu(struct stats_cpu *st_cpu, int nbr,
                exit(2);
        }
 
-       while (fgets(line, 8192, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "cpu ", 4)) {
 
@@ -185,7 +185,7 @@ void read_stat_irq(struct stats_irq *st_irq, int nbr)
        if ((fp = fopen(STAT, "r")) == NULL)
                return;
        
-       while (fgets(line, 8192, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "intr ", 5)) {
                        /* Read total number of interrupts received since system boot */
@@ -222,7 +222,7 @@ void read_meminfo(struct stats_memory *st_memory)
        if ((fp = fopen(MEMINFO, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "MemTotal:", 9)) {
                        /* Read the total amount of memory in kB */
@@ -290,7 +290,7 @@ void read_uptime(unsigned long long *uptime)
        if ((fp = fopen(UPTIME, "r")) == NULL)
                return;
 
-       if (fgets(line, 128, fp) == NULL) {
+       if (fgets(line, sizeof(line), fp) == NULL) {
                fclose(fp);
                return;
        }
@@ -362,7 +362,7 @@ void read_stat_pcsw(struct stats_pcsw *st_pcsw)
        if ((fp = fopen(STAT, "r")) == NULL)
                return;
 
-       while (fgets(line, 8192, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "ctxt ", 5)) {
                        /* Read number of context switches */
@@ -421,7 +421,7 @@ void read_loadavg(struct stats_queue *st_queue)
        if ((fp = fopen(STAT, "r")) == NULL)
                return;
 
-       while (fgets(line, 8192, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "procs_blocked ", 14)) {
                        /* Read number of processes blocked */
@@ -452,7 +452,7 @@ void read_vmstat_swap(struct stats_swap *st_swap)
        if ((fp = fopen(VMSTAT, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "pswpin ", 7)) {
                        /* Read number of swap pages brought in */
@@ -490,7 +490,7 @@ void read_vmstat_paging(struct stats_paging *st_paging)
        st_paging->pgsteal = 0;
        st_paging->pgscan_kswapd = st_paging->pgscan_direct = 0;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "pgpgin ", 7)) {
                        /* Read number of pages the system paged in */
@@ -554,7 +554,7 @@ void read_diskstats_io(struct stats_io *st_io)
        if ((fp = fopen(DISKSTATS, "r")) == NULL)
                return;
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (sscanf(line, "%u %u %s %lu %*u %lu %*u %lu %*u %lu",
                           &major, &minor, dev_name,
@@ -604,7 +604,7 @@ void read_diskstats_disk(struct stats_disk *st_disk, int nbr, int read_part)
        if ((fp = fopen(DISKSTATS, "r")) == NULL)
                return;
 
-       while ((fgets(line, 256, fp) != NULL) && (dsk < nbr)) {
+       while ((fgets(line, sizeof(line), fp) != NULL) && (dsk < nbr)) {
 
                if (sscanf(line, "%u %u %s %lu %*u %lu %u %lu %*u %lu"
                           " %u %*u %u %u",
@@ -656,7 +656,7 @@ void read_tty_driver_serial(struct stats_serial *st_serial, int nbr)
        if ((fp = fopen(SERIAL, "r")) == NULL)
                return;
 
-       while ((fgets(line, 256, fp) != NULL) && (sl < nbr)) {
+       while ((fgets(line, sizeof(line), fp) != NULL) && (sl < nbr)) {
 
                if ((p = strstr(line, "tx:")) != NULL) {
                        st_serial_i = st_serial + sl;
@@ -776,7 +776,7 @@ int read_net_dev(struct stats_net_dev *st_net_dev, int nbr)
        if ((fp = fopen(NET_DEV, "r")) == NULL)
                return 0;
        
-       while ((fgets(line, 256, fp) != NULL) && (dev < nbr)) {
+       while ((fgets(line, sizeof(line), fp) != NULL) && (dev < nbr)) {
 
                pos = strcspn(line, ":");
                if (pos < strlen(line)) {
@@ -887,7 +887,7 @@ void read_net_edev(struct stats_net_edev *st_net_edev, int nbr)
        if ((fp = fopen(NET_DEV, "r")) == NULL)
                return;
 
-       while ((fgets(line, 256, fp) != NULL) && (dev < nbr)) {
+       while ((fgets(line, sizeof(line), fp) != NULL) && (dev < nbr)) {
 
                pos = strcspn(line, ":");
                if (pos < strlen(line)) {
@@ -935,7 +935,7 @@ void read_net_nfs(struct stats_net_nfs *st_net_nfs)
 
        memset(st_net_nfs, 0, STATS_NET_NFS_SIZE);
        
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "rpc ", 4)) {
                        sscanf(line + 4, "%u %u",
@@ -987,7 +987,7 @@ void read_net_nfsd(struct stats_net_nfsd *st_net_nfsd)
        
        memset(st_net_nfsd, 0, STATS_NET_NFSD_SIZE);
 
-       while (fgets(line, 256, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "rc ", 3)) {
                        sscanf(line + 3, "%u %u",
@@ -1049,7 +1049,7 @@ void read_net_sock(struct stats_net_sock *st_net_sock)
        if ((fp = fopen(NET_SOCKSTAT, "r")) == NULL)
                return;
        
-       while (fgets(line, 96, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "sockets:", 8)) {
                        /* Sockets */
@@ -1099,7 +1099,7 @@ void read_net_ip(struct stats_net_ip *st_net_ip)
        if ((fp = fopen(NET_SNMP, "r")) == NULL)
                return;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Ip:", 3)) {
                        if (sw) {
@@ -1145,7 +1145,7 @@ void read_net_eip(struct stats_net_eip *st_net_eip)
        if ((fp = fopen(NET_SNMP, "r")) == NULL)
                return;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Ip:", 3)) {
                        if (sw) {
@@ -1191,7 +1191,7 @@ void read_net_icmp(struct stats_net_icmp *st_net_icmp)
        if ((fp = fopen(NET_SNMP, "r")) == NULL)
                return;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Icmp:", 5)) {
                        if (sw) {
@@ -1244,7 +1244,7 @@ void read_net_eicmp(struct stats_net_eicmp *st_net_eicmp)
        if ((fp = fopen(NET_SNMP, "r")) == NULL)
                return;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Icmp:", 5)) {
                        if (sw) {
@@ -1294,7 +1294,7 @@ void read_net_tcp(struct stats_net_tcp *st_net_tcp)
        if ((fp = fopen(NET_SNMP, "r")) == NULL)
                return;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Tcp:", 4)) {
                        if (sw) {
@@ -1336,7 +1336,7 @@ void read_net_etcp(struct stats_net_etcp *st_net_etcp)
        if ((fp = fopen(NET_SNMP, "r")) == NULL)
                return;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Tcp:", 4)) {
                        if (sw) {
@@ -1379,7 +1379,7 @@ void read_net_udp(struct stats_net_udp *st_net_udp)
        if ((fp = fopen(NET_SNMP, "r")) == NULL)
                return;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Udp:", 4)) {
                        if (sw) {
@@ -1419,7 +1419,7 @@ void read_net_sock6(struct stats_net_sock6 *st_net_sock6)
        if ((fp = fopen(NET_SOCKSTAT6, "r")) == NULL)
                return;
        
-       while (fgets(line, 96, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "TCP6:", 5)) {
                        /* TCPv6 sockets */
@@ -1461,7 +1461,7 @@ void read_net_ip6(struct stats_net_ip6 *st_net_ip6)
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Ip6InReceives ", 14)) {
                        sscanf(line + 14, "%llu", &st_net_ip6->InReceives6);
@@ -1517,7 +1517,7 @@ void read_net_eip6(struct stats_net_eip6 *st_net_eip6)
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Ip6InHdrErrors ", 15)) {
                        sscanf(line + 15, "%llu", &st_net_eip6->InHdrErrors6);
@@ -1576,7 +1576,7 @@ void read_net_icmp6(struct stats_net_icmp6 *st_net_icmp6)
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Icmp6InMsgs ", 12)) {
                        sscanf(line + 12, "%lu", &st_net_icmp6->InMsgs6);
@@ -1653,7 +1653,7 @@ void read_net_eicmp6(struct stats_net_eicmp6 *st_net_eicmp6)
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Icmp6InErrors ", 14)) {
                        sscanf(line + 14, "%lu", &st_net_eicmp6->InErrors6);
@@ -1712,7 +1712,7 @@ void read_net_udp6(struct stats_net_udp6 *st_net_udp6)
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "Udp6InDatagrams ", 16)) {
                        sscanf(line + 16, "%lu", &st_net_udp6->InDatagrams6);
@@ -1756,7 +1756,7 @@ void read_cpuinfo(struct stats_pwr_cpufreq *st_pwr_cpufreq, int nbr)
        
        st_pwr_cpufreq->cpufreq = 0;
        
-       while (fgets(line, 1024, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
                
                if (!strncmp(line, "processor\t", 10)) {
                        sscanf(strchr(line, ':') + 1, "%d", &proc_nb);
@@ -1815,7 +1815,7 @@ void read_meminfo_huge(struct stats_huge *st_huge)
        if ((fp = fopen(MEMINFO, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                if (!strncmp(line, "HugePages_Total:", 16)) {
                        /* Read the total number of huge pages */
@@ -1866,7 +1866,7 @@ void read_time_in_state(struct stats_pwr_wghfreq *st_pwr_wghfreq, int cpu_nr, in
        if ((fp = fopen(filename, "r")) == NULL)
                return;
 
-       while (fgets(line, 128, fp) != NULL) {
+       while (fgets(line, sizeof(line), fp) != NULL) {
 
                sscanf(line, "%lu %llu", &freq, &time_in_state);
 
@@ -2020,7 +2020,7 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
        if ((fp = fopen(MTAB, "r")) == NULL)
                return;
 
-       while ((fgets(line, 256, fp) != NULL) && (fs < nbr)) {
+       while ((fgets(line, sizeof(line), fp) != NULL) && (fs < nbr)) {
                if (line[0] == '/') {
                        
                        /* Read current filesystem name and mount point */
index 56ad7b909ef54756b1e0e21db475980e6f4abcdb..21fe7af464076abba132155bb8dff770f8e4301e 100644 (file)
@@ -505,7 +505,7 @@ __printf_funct_t print_xml_header(int *tab, int action, char *dfile,
 
                /* Fill file timestmap structure (rectime) */
                get_file_timestamp_struct(flags, &rectime, file_hdr);
-               strftime(cur_time, 32, "%Y-%m-%d", &rectime);
+               strftime(cur_time, sizeof(cur_time), "%Y-%m-%d", &rectime);
                xprintf(*tab, "<file-date>%s</file-date>", cur_time);
 
                if ((loc_t = gmtime((const time_t *) &file_hdr->sa_ust_time)) != NULL) {
@@ -564,7 +564,7 @@ __printf_funct_t print_json_header(int *tab, int action, char *dfile,
 
                /* Fill file timestmap structure (rectime) */
                get_file_timestamp_struct(flags, &rectime, file_hdr);
-               strftime(cur_time, 32, "%Y-%m-%d", &rectime);
+               strftime(cur_time, sizeof(cur_time), "%Y-%m-%d", &rectime);
                xprintf0(*tab, "\"file-date\": \"%s\"", cur_time);
                
                if ((loc_t = gmtime((const time_t *) &file_hdr->sa_ust_time)) != NULL) {