summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2018-07-06 20:23:35 +0200
committerXavi Hernandez <xhernandez@redhat.com>2018-07-10 16:28:24 +0200
commit6dc5dfef819cad69d6d4b4c1c305efa74236ad84 (patch)
tree6b325caf478689d8113279191ca1916e5f5b32ea /xlators/cluster/dht
parent03f1f5bdc46076178f1afdf8e2a76c5b973fe11f (diff)
Fix compile warnings
This patch fixes compile warnings that appear with newer compilers. The solution applied is only to remove the warnings, but it doesn't always solve the problem in the best way. It assumes that the problem will never happen, as the previous code assumed. Change-Id: I6e8470d6c2e2dbd3bd7d324b5fd2f92ffdc3d6ec updates: bz#1193929 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'xlators/cluster/dht')
-rw-r--r--xlators/cluster/dht/src/tier.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c
index 5fa50a26d80..e4294f4fda9 100644
--- a/xlators/cluster/dht/src/tier.c
+++ b/xlators/cluster/dht/src/tier.c
@@ -1690,7 +1690,7 @@ 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+128] = {0,};
+ char query_file_path_err[PATH_MAX] = {0,};
struct tm tm = {0,};
gfdb_time_t current_time = {0,};
char time_str[128] = {0,};
@@ -1698,6 +1698,7 @@ tier_migrate_files_using_qfile (migration_args_t *comp,
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);
@@ -1762,14 +1763,17 @@ out:
list_for_each_entry_safe (local_brick, temp, comp->brick_list,
list) {
/* rename error qfile*/
- snprintf (query_file_path_err,
- sizeof (query_file_path_err),
- "%s-%s.err", local_brick->qfile_path,
- time_str);
- if (sys_rename (local_brick->qfile_path,
- query_file_path_err) == -1)
- gf_msg_debug ("tier", 0, "rename "
- "failed");
+ len = snprintf (query_file_path_err,
+ sizeof (query_file_path_err),
+ "%s-%s.err", local_brick->qfile_path,
+ time_str);
+ if ((len >= 0) &&
+ (len < sizeof(query_file_path_err))) {
+ if (sys_rename (local_brick->qfile_path,
+ query_file_path_err) == -1)
+ gf_msg_debug ("tier", 0, "rename "
+ "failed");
+ }
}
}
@@ -2118,6 +2122,7 @@ tier_get_bricklist (xlator_t *xl, struct list_head *local_bricklist_head)
char db_name[PATH_MAX] = "";
int ret = 0;
tier_brick_list_t *local_brick = NULL;
+ int32_t len = 0;
GF_VALIDATE_OR_GOTO ("tier", xl, out);
GF_VALIDATE_OR_GOTO ("tier", local_bricklist_head, out);
@@ -2155,12 +2160,20 @@ tier_get_bricklist (xlator_t *xl, struct list_head *local_bricklist_head)
DHT_MSG_LOG_TIER_STATUS,
"Failed to allocate memory for"
" bricklist.");
+ ret = -1;
goto out;
}
- snprintf(local_brick->brick_db_path,
- PATH_MAX, "%s/%s/%s", rv,
- GF_HIDDEN_PATH, db_name);
+ len = snprintf(local_brick->brick_db_path,
+ PATH_MAX, "%s/%s/%s", rv,
+ GF_HIDDEN_PATH, db_name);
+ if ((len < 0) || (len >= PATH_MAX)) {
+ gf_msg ("tier", GF_LOG_ERROR, EINVAL,
+ DHT_MSG_LOG_TIER_STATUS,
+ "DB path too long");
+ ret = -1;
+ goto out;
+ }
local_brick->xlator = xl;