summaryrefslogtreecommitdiffstats
path: root/libglusterfs
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 /libglusterfs
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 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c5
-rw-r--r--libglusterfs/src/statedump.c17
-rw-r--r--libglusterfs/src/statedump.h15
3 files changed, 24 insertions, 13 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 60725769096..09f0caa7e8a 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -3061,8 +3061,9 @@ gf_canonicalize_path (char *path)
strncpy ((path + path_len + 1), dir, dir_path_len);
path_len += dir_path_len + 1;
dir = strtok_r (NULL, "/", &tmpstr);
- if (dir)
- strncpy ((path + path_len), "/", 1);
+ if (dir) {
+ path[path_len] = '/';
+ }
}
path[path_len] = '\0';
ret = 0;
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 874326f44ce..21a916ea6b8 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -858,11 +858,16 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
if (ret < 0)
goto out;
- snprintf (path, sizeof (path), "%s/%s.%d.dump.%"PRIu64,
- ((dump_options.dump_path != NULL)?dump_options.dump_path:
- ((ctx->statedump_path != NULL)?ctx->statedump_path:
- DEFAULT_VAR_RUN_DIRECTORY)), brick_name, getpid(),
- (uint64_t) time (NULL));
+ ret = snprintf (path, sizeof (path), "%s/%s.%d.dump.%"PRIu64,
+ ((dump_options.dump_path != NULL)
+ ? dump_options.dump_path
+ : ((ctx->statedump_path != NULL)
+ ? ctx->statedump_path
+ : DEFAULT_VAR_RUN_DIRECTORY)),
+ brick_name, getpid(), (uint64_t) time (NULL));
+ if ((ret < 0) || (ret >= sizeof(path))) {
+ goto out;
+ }
snprintf (tmp_dump_name, PATH_MAX, "%s/dumpXXXXXX",
((dump_options.dump_path != NULL)?dump_options.dump_path:
@@ -939,10 +944,10 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
timestr);
ret = sys_write (gf_dump_fd, sign_string, strlen (sign_string));
-out:
if (gf_dump_fd != -1)
gf_proc_dump_close ();
sys_rename (tmp_dump_name, path);
+out:
GF_FREE (dump_options.dump_path);
dump_options.dump_path = NULL;
gf_proc_dump_unlock ();
diff --git a/libglusterfs/src/statedump.h b/libglusterfs/src/statedump.h
index 0a7a97e10d4..92246e1e37e 100644
--- a/libglusterfs/src/statedump.h
+++ b/libglusterfs/src/statedump.h
@@ -41,13 +41,18 @@ __attribute__ ((__format__ (__printf__, 3, 4)))
static inline void
_gf_proc_dump_build_key (char *key, const char *prefix, const char *fmt, ...)
{
- char buf[GF_DUMP_MAX_BUF_LEN] = { 0, };
va_list ap;
+ int32_t len;
- va_start(ap, fmt);
- vsnprintf(buf, GF_DUMP_MAX_BUF_LEN, fmt, ap);
- va_end(ap);
- snprintf(key, GF_DUMP_MAX_BUF_LEN, "%s.%s", prefix, buf);
+ len = snprintf(key, GF_DUMP_MAX_BUF_LEN, "%s.", prefix);
+ if (len >= 0) {
+ va_start(ap, fmt);
+ len = vsnprintf(key + len, GF_DUMP_MAX_BUF_LEN - len, fmt, ap);
+ va_end(ap);
+ }
+ if (len < 0) {
+ *key = 0;
+ }
}
#define gf_proc_dump_build_key(key, key_prefix, fmt...) \