From 475826671a4bce7dada95e04cd9466d431e444e5 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Mon, 9 Jul 2018 13:32:26 +0300 Subject: tier: Move time string formatting There is no need to format the time, unless ret is true. I don't think there's a reason to allocate memory for those struct and char array unless we are formatting either (But I'm not sure what the code convention is - are we ok with 'local' variable declarations?) Only compile-tested. Change-Id: I9feb09871943764bd76bdfc9ac6ca506f329aac1 updates: bz#1193929 Signed-off-by: Yaniv Kaul --- xlators/cluster/dht/src/tier.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index e4294f4fda9..45a19d96243 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1690,22 +1690,16 @@ 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] = {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; gf_tier_conf_t *tier_conf = NULL; - int32_t len = 0; tier_conf = &(query_cbk_args->defrag->tier_conf); - /* Time format for error query files */ + /* Time for error query files */ gettimeofday (¤t_time, NULL); - gmtime_r (¤t_time.tv_sec, &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,6 +1754,15 @@ out: /* If there is an error rename all the query files to .err files * with a timestamp for better debugging */ if (ret) { + struct tm tm = {0,}; + char time_str[128] = {0,}; + char query_file_path_err[PATH_MAX] = {0,}; + int32_t len = 0; + + /* Time format for error query files */ + gmtime_r (¤t_time.tv_sec, &tm); + strftime (time_str, sizeof (time_str), "%F-%T", &tm); + list_for_each_entry_safe (local_brick, temp, comp->brick_list, list) { /* rename error qfile*/ -- cgit