From 5424c63fe146e42cfc9be45b0b9830bcc948b7aa Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Thu, 14 Sep 2017 13:43:58 -0400 Subject: xlator/tier: flood of -Wformat-truncation warnings with gcc-7.1 Starting in Fedora 26 which has gcc-7.1.x, -Wformat-trunction is enabled with -Wformat, resulting in a flood of new warnings. This many warnings is a concern because it makes it hard(er) to see other warnings that should be addressed. An example is at https://kojipkgs.fedoraproject.org//packages/glusterfs/3.12.0/1.fc28/data/logs/x86_64/build.log For more info see https://review.gluster.org/#/c/18267/ Change-Id: Id7ef8e0dedd28ada55f72c03d91facbe1c9888bd BUG: 1492849 Signed-off-by: Kaleb S. KEITHLEY --- xlators/cluster/dht/src/tier.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index db23b9661bb..6223b773cf7 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1687,11 +1687,10 @@ tier_migrate_files_using_qfile (migration_args_t *comp, int ret = -1; tier_brick_list_t *local_brick = NULL; tier_brick_list_t *temp = NULL; - char query_file_path_err[PATH_MAX] = ""; - struct tm tm = {0}; - gfdb_time_t current_time = {0}; - char time_str[256] = {0}; - char time_format[20] = "%Y-%m-%d-%H-%M-%S"; + char query_file_path_err[PATH_MAX+128] = {0,}; + struct tm tm = {0,}; + gfdb_time_t current_time = {0,}; + char time_str[128] = {0,}; ssize_t qfile_array_size = 0; int count = 0; int temp_fd = 0; @@ -1702,7 +1701,7 @@ tier_migrate_files_using_qfile (migration_args_t *comp, /* Time format for error query files */ gettimeofday (¤t_time, NULL); gmtime_r (¤t_time.tv_sec, &tm); - strftime (time_str, 256, time_format, &tm); + strftime (time_str, sizeof (time_str), "%F-%T", &tm); /* Build the qfile list */ list_for_each_entry_safe (local_brick, temp, comp->brick_list, list) { @@ -1760,8 +1759,10 @@ out: list_for_each_entry_safe (local_brick, temp, comp->brick_list, list) { /* rename error qfile*/ - snprintf (query_file_path_err, PATH_MAX, "%s-%s.err", - local_brick->qfile_path, time_str); + snprintf (query_file_path_err, + sizeof (query_file_path_err), + "%s-%s.err", local_brick->qfile_path, + time_str); sys_rename (local_brick->qfile_path, query_file_path_err); } -- cgit