diff options
author | Xavi Hernandez <xhernandez@redhat.com> | 2018-07-06 20:23:35 +0200 |
---|---|---|
committer | Xavi Hernandez <xhernandez@redhat.com> | 2018-07-10 16:28:24 +0200 |
commit | 6dc5dfef819cad69d6d4b4c1c305efa74236ad84 (patch) | |
tree | 6b325caf478689d8113279191ca1916e5f5b32ea /xlators/mgmt/glusterd/src/glusterd-quota.c | |
parent | 03f1f5bdc46076178f1afdf8e2a76c5b973fe11f (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-quota.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quota.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index 6231fe3a7f4..847c1a721d0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -249,6 +249,7 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, runner_t runner = {0}; char *volfileserver = NULL; FILE *pidfp = NULL; + int32_t len = 0; GF_VALIDATE_OR_GOTO ("glusterd", THIS, out); @@ -272,16 +273,25 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, } GLUSTERD_REMOVE_SLASH_FROM_PATH (brick->path, brickpath); - snprintf (logfile, sizeof (logfile), - DEFAULT_QUOTA_CRAWL_LOG_DIRECTORY"/%s.log", - brickpath); + len = snprintf (logfile, sizeof (logfile), + DEFAULT_QUOTA_CRAWL_LOG_DIRECTORY"/%s.log", + brickpath); + if ((len < 0) || (len >= sizeof(vol_id))) { + ret = -1; + goto out; + } if (dict_get_str (THIS->options, "transport.socket.bind-address", &volfileserver) != 0) volfileserver = "localhost"; - snprintf (vol_id, sizeof (vol_id), "client_per_brick/%s.%s.%s.%s.vol", - volinfo->volname, "client", brick->hostname, brickpath); + len = snprintf (vol_id, sizeof (vol_id), + "client_per_brick/%s.%s.%s.%s.vol", volinfo->volname, + "client", brick->hostname, brickpath); + if ((len < 0) || (len >= sizeof(vol_id))) { + ret = -1; + goto out; + } runinit (&runner); @@ -370,13 +380,15 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, _exit (EXIT_FAILURE); } - snprintf (pidfile, sizeof (pidfile), "%s/%s.pid", pid_dir, - brickpath); - pidfp = fopen (pidfile, "w"); - if (pidfp) { - fprintf (pidfp, "%d\n", runner.chpid); - fflush (pidfp); - fclose (pidfp); + len = snprintf (pidfile, sizeof (pidfile), "%s/%s.pid", + pid_dir, brickpath); + if ((len >= 0) && (len < sizeof(pidfile))) { + pidfp = fopen (pidfile, "w"); + if (pidfp >= 0) { + fprintf (pidfp, "%d\n", runner.chpid); + fflush (pidfp); + fclose (pidfp); + } } #ifndef GF_LINUX_HOST_OS @@ -402,6 +414,7 @@ glusterd_stop_all_quota_crawl_service (glusterd_conf_t *priv, struct dirent scratch[2] = {{0,},}; char pid_dir[PATH_MAX] = {0,}; char pidfile[PATH_MAX] = {0,}; + int32_t len = 0; GLUSTERD_GET_QUOTA_CRAWL_PIDDIR (pid_dir, volinfo, type); @@ -411,12 +424,13 @@ glusterd_stop_all_quota_crawl_service (glusterd_conf_t *priv, GF_SKIP_IRRELEVANT_ENTRIES (entry, dir, scratch); while (entry) { - snprintf (pidfile, sizeof (pidfile), "%s/%s", - pid_dir, entry->d_name); - - glusterd_service_stop_nolock ("quota_crawl", pidfile, SIGKILL, - _gf_true); - sys_unlink (pidfile); + len = snprintf (pidfile, sizeof (pidfile), "%s/%s", + pid_dir, entry->d_name); + if ((len >= 0) && (len < sizeof(pidfile))) { + glusterd_service_stop_nolock ("quota_crawl", pidfile, + SIGKILL, _gf_true); + sys_unlink (pidfile); + } GF_SKIP_IRRELEVANT_ENTRIES (entry, dir, scratch); } |