summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd.h
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/mgmt/glusterd/src/glusterd.h
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/mgmt/glusterd/src/glusterd.h')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h220
1 files changed, 153 insertions, 67 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 33413976e6d..fa053e0c170 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -612,63 +612,119 @@ typedef enum {
typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args);
-#define GLUSTERD_GET_VOLUME_DIR(path, volinfo, priv) \
- if (volinfo->is_snap_volume) { \
- snprintf (path, PATH_MAX, "%s/snaps/%s/%s", priv->workdir, \
- volinfo->snapshot->snapname, volinfo->volname); \
- } else { \
- snprintf (path, PATH_MAX, "%s/vols/%s", priv->workdir, \
- volinfo->volname); \
- }
+#define GLUSTERD_GET_VOLUME_DIR(path, volinfo, priv) \
+ do { \
+ int32_t len; \
+ if (volinfo->is_snap_volume) { \
+ len = snprintf (path, PATH_MAX, "%s/snaps/%s/%s", \
+ priv->workdir, \
+ volinfo->snapshot->snapname, \
+ volinfo->volname); \
+ } else { \
+ len = snprintf (path, PATH_MAX, "%s/vols/%s", \
+ priv->workdir, volinfo->volname); \
+ } \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
+ } while (0)
+
#define GLUSTERD_GET_TIER_DIR(path, volinfo, priv) do { \
- snprintf (path, PATH_MAX, "%s/tier/%s", priv->workdir, \
- volinfo->volname); \
+ int32_t len; \
+ len = snprintf (path, PATH_MAX, "%s/tier/%s", \
+ priv->workdir, volinfo->volname); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
} while (0)
#define GLUSTERD_GET_TIER_PID_FILE(path, volinfo, priv) do { \
char tier_path[PATH_MAX]; \
+ int32_t len; \
GLUSTERD_GET_TIER_DIR(tier_path, volinfo, priv); \
- snprintf (path, PATH_MAX, "%s/run/%s-tierd.pid", tier_path,\
- volinfo->volname); \
+ len = snprintf (path, PATH_MAX, "%s/run/%s-tierd.pid", \
+ tier_path, volinfo->volname); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
} while (0)
#define GLUSTERD_GET_VOLUME_PID_DIR(path, volinfo, priv) \
do { \
+ int32_t len; \
if (volinfo->is_snap_volume) { \
- snprintf (path, PATH_MAX, "%s/snaps/%s/%s", \
- priv->rundir, \
- volinfo->snapshot->snapname, volinfo->volname); \
+ len = snprintf (path, PATH_MAX, "%s/snaps/%s/%s", \
+ priv->rundir, \
+ volinfo->snapshot->snapname, \
+ volinfo->volname); \
} else { \
- snprintf (path, PATH_MAX, "%s/vols/%s", \
- priv->rundir, \
- volinfo->volname); \
+ len = snprintf (path, PATH_MAX, "%s/vols/%s", \
+ priv->rundir, \
+ volinfo->volname); \
+ } \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
} \
} while (0)
-#define GLUSTERD_GET_SNAP_DIR(path, snap, priv) \
- snprintf (path, PATH_MAX, "%s/snaps/%s", priv->workdir, \
- snap->snapname);
+#define GLUSTERD_GET_SNAP_DIR(path, snap, priv) \
+ do { \
+ int32_t len; \
+ len = snprintf (path, PATH_MAX, "%s/snaps/%s", priv->workdir, \
+ snap->snapname); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
+ } while (0)
#define GLUSTERD_GET_SNAP_GEO_REP_DIR(path, snap, priv) \
- snprintf (path, PATH_MAX, "%s/snaps/%s/%s", priv->workdir, \
- snap->snapname, GEOREP);
+ do { \
+ int32_t len; \
+ len = snprintf (path, PATH_MAX, "%s/snaps/%s/%s", \
+ priv->workdir, snap->snapname, GEOREP); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
+ } while (0)
#define GLUSTERD_GET_BRICK_DIR(path, volinfo, priv) \
- if (volinfo->is_snap_volume) { \
- snprintf (path, PATH_MAX, "%s/snaps/%s/%s/%s", priv->workdir, \
- volinfo->snapshot->snapname, volinfo->volname, \
- GLUSTERD_BRICK_INFO_DIR); \
- } else { \
- snprintf (path, PATH_MAX, "%s/%s/%s/%s", priv->workdir, \
- GLUSTERD_VOLUME_DIR_PREFIX, volinfo->volname, \
- GLUSTERD_BRICK_INFO_DIR); \
- }
+ do { \
+ int32_t len; \
+ if (volinfo->is_snap_volume) { \
+ len = snprintf (path, PATH_MAX, "%s/snaps/%s/%s/%s", \
+ priv->workdir, \
+ volinfo->snapshot->snapname, \
+ volinfo->volname, \
+ GLUSTERD_BRICK_INFO_DIR); \
+ } else { \
+ len = snprintf (path, PATH_MAX, "%s/%s/%s/%s", \
+ priv->workdir, \
+ GLUSTERD_VOLUME_DIR_PREFIX, \
+ volinfo->volname, \
+ GLUSTERD_BRICK_INFO_DIR); \
+ } \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
+ } while (0)
#define GLUSTERD_GET_NFS_DIR(path, priv) \
- snprintf (path, PATH_MAX, "%s/nfs", priv->workdir);
+ do { \
+ int32_t len; \
+ len = snprintf (path, PATH_MAX, "%s/nfs", priv->workdir); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
+ } while (0)
#define GLUSTERD_GET_QUOTAD_DIR(path, priv) \
- snprintf (path, PATH_MAX, "%s/quotad", priv->workdir);
+ do { \
+ int32_t len; \
+ len = snprintf (path, PATH_MAX, "%s/quotad", priv->workdir); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
+ } while (0)
#define GLUSTERD_GET_QUOTA_LIMIT_MOUNT_PATH(abspath, volname, path) do { \
snprintf (abspath, sizeof (abspath)-1, \
@@ -697,32 +753,48 @@ do { \
#define GLUSTERD_GET_BRICK_PIDFILE(pidfile,volinfo,brickinfo, priv) do { \
char exp_path[PATH_MAX] = {0,}; \
char volpath[PATH_MAX] = {0,}; \
+ int32_t len = 0; \
GLUSTERD_GET_VOLUME_PID_DIR (volpath, volinfo, priv); \
GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, exp_path); \
- snprintf (pidfile, PATH_MAX, "%s/%s-%s.pid", \
- volpath, brickinfo->hostname, exp_path); \
+ len = snprintf (pidfile, PATH_MAX, "%s/%s-%s.pid", \
+ volpath, brickinfo->hostname, exp_path); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ pidfile[0] = 0; \
+ } \
} while (0)
-#define GLUSTERD_GET_NFS_PIDFILE(pidfile, nfspath, priv) { \
- snprintf (pidfile, PATH_MAX, "%s/nfs/nfs.pid", \
- priv->rundir); \
- }
+#define GLUSTERD_GET_NFS_PIDFILE(pidfile, nfspath, priv) do { \
+ int32_t len; \
+ len = snprintf (pidfile, PATH_MAX, "%s/nfs/nfs.pid", \
+ priv->rundir); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ pidfile[0] = 0; \
+ } \
+ } while (0)
-#define GLUSTERD_GET_QUOTAD_PIDFILE(pidfile, quotadpath, priv) { \
- snprintf (pidfile, PATH_MAX, "%s/quotad/quotad.pid", \
- priv->rundir); \
- }
+#define GLUSTERD_GET_QUOTAD_PIDFILE(pidfile, quotadpath, priv) do { \
+ int32_t len; \
+ len = snprintf (pidfile, PATH_MAX, "%s/quotad/quotad.pid", \
+ priv->rundir); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ pidfile[0] = 0; \
+ } \
+ } while (0)
#define GLUSTERD_GET_QUOTA_CRAWL_PIDDIR(piddir, volinfo, type) do { \
char _volpath[PATH_MAX] = {0,}; \
+ int32_t len; \
GLUSTERD_GET_VOLUME_DIR (_volpath, volinfo, priv); \
if (type == GF_QUOTA_OPTION_TYPE_ENABLE || \
type == GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS) \
- snprintf (piddir, PATH_MAX, "%s/run/quota/enable", \
- _volpath); \
+ len = snprintf (piddir, PATH_MAX, \
+ "%s/run/quota/enable", _volpath); \
else \
- snprintf (piddir, PATH_MAX, "%s/run/quota/disable", \
- _volpath); \
+ len = snprintf (piddir, PATH_MAX, \
+ "%s/run/quota/disable", _volpath); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ piddir[0] = 0; \
+ } \
} while (0)
#define GLUSTERD_STACK_DESTROY(frame) do {\
@@ -740,31 +812,49 @@ do { \
#define GLUSTERD_GET_DEFRAG_DIR(path, volinfo, priv) do { \
char vol_path[PATH_MAX]; \
char operation[NAME_MAX]; \
+ int32_t len; \
GLUSTERD_GET_VOLUME_DIR(vol_path, volinfo, priv); \
GLUSTERD_GET_DEFRAG_PROCESS(operation, volinfo); \
- snprintf (path, PATH_MAX, "%s/%s", vol_path, operation);\
+ len = snprintf (path, PATH_MAX, "%s/%s", vol_path, \
+ operation); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
} while (0)
#define GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD(path, volinfo, priv) do { \
char defrag_path[PATH_MAX]; \
+ int32_t len; \
GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \
- snprintf (path, PATH_MAX, "%s/%s.sock", defrag_path, \
- uuid_utoa(MY_UUID)); \
+ len = snprintf (path, PATH_MAX, "%s/%s.sock", \
+ defrag_path, uuid_utoa(MY_UUID)); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
} while (0)
-#define GLUSTERD_GET_DEFRAG_SOCK_FILE(path, volinfo) do { \
- char operation[NAME_MAX]; \
- GLUSTERD_GET_DEFRAG_PROCESS(operation, volinfo); \
- snprintf (path, UNIX_PATH_MAX, DEFAULT_VAR_RUN_DIRECTORY \
- "/gluster-%s-%s.sock", operation, \
- uuid_utoa(volinfo->volume_id)); \
+#define GLUSTERD_GET_DEFRAG_SOCK_FILE(path, volinfo) do { \
+ char operation[NAME_MAX]; \
+ int32_t len; \
+ GLUSTERD_GET_DEFRAG_PROCESS(operation, volinfo); \
+ len = snprintf (path, UNIX_PATH_MAX, \
+ DEFAULT_VAR_RUN_DIRECTORY \
+ "/gluster-%s-%s.sock", operation, \
+ uuid_utoa(volinfo->volume_id)); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
} while (0)
#define GLUSTERD_GET_DEFRAG_PID_FILE(path, volinfo, priv) do { \
char defrag_path[PATH_MAX]; \
+ int32_t len; \
GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \
- snprintf (path, PATH_MAX, "%s/%s.pid", defrag_path, \
- uuid_utoa(MY_UUID)); \
+ len = snprintf (path, PATH_MAX, "%s/%s.pid", \
+ defrag_path, uuid_utoa(MY_UUID)); \
+ if ((len < 0) || (len >= PATH_MAX)) { \
+ path[0] = 0; \
+ } \
} while (0)
#define GLUSTERFS_GET_QUOTA_LIMIT_MOUNT_PIDFILE(pidfile, volname) { \
@@ -796,15 +886,11 @@ do { \
} while (0)
#define GLUSTERD_DUMP_PEERS(head, member, xpeers) do { \
- glusterd_peerinfo_t *_peerinfo = NULL; \
- int index = 1; \
- char key[GF_DUMP_MAX_BUF_LEN] = {0,}; \
+ glusterd_peerinfo_t *_peerinfo = NULL; \
+ int index = 1; \
+ char *key = NULL; \
\
- if (!xpeers) \
- snprintf (key, sizeof (key), "glusterd.peer"); \
- else \
- snprintf (key, sizeof (key), \
- "glusterd.xaction_peer"); \
+ key = xpeers ? "glusterd.xaction_peer" : "glusterd.peer"; \
\
rcu_read_lock (); \
cds_list_for_each_entry_rcu (_peerinfo, head, member) { \