diff options
-rw-r--r-- | cli/src/cli-cmd-volume.c | 5 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 28 | ||||
-rw-r--r-- | contrib/fuse-lib/mount.c | 10 | ||||
-rw-r--r-- | libglusterfs/src/event.h | 2 | ||||
-rw-r--r-- | libglusterfs/src/statedump.c | 5 | ||||
-rw-r--r-- | xlators/lib/src/libxlator.c | 14 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 8 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3.c | 42 |
8 files changed, 78 insertions, 36 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 3f639300f2c..4fa25f92db3 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -305,7 +305,10 @@ cli_cmd_get_confirmation (struct cli_state *state, const char *question) printf ("%s (y/n) ", question); - fgets (answer, 4, stdin); + if (fgets (answer, 4, stdin) == NULL) { + cli_out("gluster cli read error"); + goto out; + } len = strlen (answer); diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 07cfdb0c867..b0e00f63b3e 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1391,7 +1391,9 @@ unmount: #else snprintf (cmd_str, sizeof (cmd_str), "umount %s", mountdir); #endif - system (cmd_str); + ret = system (cmd_str); + if (ret) + gf_log ("cli", GF_LOG_WARNING, "error executing: %s", cmd_str); rm_dir: rmdir (mountdir); out: @@ -2580,6 +2582,7 @@ int gf_cli3_1_gsync_get_command (gf1_cli_gsync_set_rsp rsp) { char cmd[PATH_MAX] = {0,}; + int ret = -1; if (rsp.op_ret < 0) return 0; @@ -2595,20 +2598,19 @@ gf_cli3_1_gsync_get_command (gf1_cli_gsync_set_rsp rsp) " --config-get %s ", rsp.glusterd_workdir, GSYNC_CONF, rsp.master, rsp.slave, rsp.op_name); - system (cmd); - goto out; + ret = system (cmd); + /* + * gf_log() failure from system() ? + */ + } else if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) { + snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/%s " + "%s %s --config-get-all ", + rsp.glusterd_workdir, GSYNC_CONF, + rsp.master, rsp.slave); + + ret = system (cmd); } - if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) { - snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/%s " - "%s %s --config-get-all ", - rsp.glusterd_workdir, GSYNC_CONF, - rsp.master, rsp.slave); - - system (cmd); - goto out; - } -out: return 0; } diff --git a/contrib/fuse-lib/mount.c b/contrib/fuse-lib/mount.c index 59f5837ed40..47592a62dd8 100644 --- a/contrib/fuse-lib/mount.c +++ b/contrib/fuse-lib/mount.c @@ -261,6 +261,7 @@ receive_fd (int fd) int rv; size_t ccmsg[CMSG_SPACE (sizeof (int)) / sizeof (size_t)]; struct cmsghdr *cmsg; + int *recv_fd; iov.iov_base = buf; iov.iov_len = 1; @@ -285,12 +286,17 @@ receive_fd (int fd) } cmsg = CMSG_FIRSTHDR (&msg); - if (!cmsg->cmsg_type == SCM_RIGHTS) { + /* + * simplify condition expression + */ + if (cmsg->cmsg_type != SCM_RIGHTS) { GFFUSE_LOGERR ("got control message of unknown type %d", cmsg->cmsg_type); return -1; } - return *(int*)CMSG_DATA (cmsg); + + recv_fd = (int *) CMSG_DATA (cmsg); + return (*recv_fd); } static int diff --git a/libglusterfs/src/event.h b/libglusterfs/src/event.h index 57884d173ce..eb42663654b 100644 --- a/libglusterfs/src/event.h +++ b/libglusterfs/src/event.h @@ -32,7 +32,7 @@ struct event_ops; struct event_data { int fd; int idx; -} __attribute__ ((__packed__)); +} __attribute__ ((__packed__, __may_alias__)); typedef int (*event_handler_t) (int fd, int idx, void *data, diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 58d81625749..0fd4013ff44 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -284,6 +284,7 @@ gf_proc_dump_parse_set_option (char *key, char *value) gf_boolean_t *opt_key = NULL; gf_boolean_t opt_value = _gf_false; char buf[GF_DUMP_MAX_BUF_LEN]; + int ret = -1; if (!strncasecmp (key, "mem", 3)) { opt_key = &dump_options.dump_mem; @@ -307,7 +308,7 @@ gf_proc_dump_parse_set_option (char *key, char *value) //None of dump options match the key, return back snprintf (buf, sizeof (buf), "[Warning]:None of the options " "matched key : %s\n", key); - write (gf_dump_fd, buf, strlen (buf)); + ret = write (gf_dump_fd, buf, strlen (buf)); return -1; } @@ -395,7 +396,7 @@ gf_proc_dump_options_init () } snprintf (dumpbuf, sizeof (dumpbuf), "[Debug]:key=%s, value=%s\n",key,value); - write (gf_dump_fd, dumpbuf, strlen (dumpbuf)); + ret = write (gf_dump_fd, dumpbuf, strlen (dumpbuf)); gf_proc_dump_parse_set_option (key, value); diff --git a/xlators/lib/src/libxlator.c b/xlators/lib/src/libxlator.c index bd0e11d2134..3991d80ff09 100644 --- a/xlators/lib/src/libxlator.c +++ b/xlators/lib/src/libxlator.c @@ -45,13 +45,13 @@ cluster_markerxtime_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { - int32_t callcnt = 0; - int ret = -1; - uint32_t *net_timebuf; - uint32_t host_timebuf[2]; - char *marker_xattr; - struct marker_str *local; - char *vol_uuid; + int32_t callcnt = 0; + int ret = -1; + uint32_t *net_timebuf = NULL; + uint32_t host_timebuf[2] = {0,}; + char *marker_xattr = NULL; + struct marker_str *local = NULL; + char *vol_uuid = NULL; if (!this || !frame || !frame->local || !cookie) { gf_log (this->name, GF_LOG_DEBUG, "possible NULL deref"); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index e8d107db7b8..0ee0206fa5e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -895,7 +895,9 @@ glusterd_service_stop (const char *service, char *pidfile, int sig, ret = 0; out: if (is_locked && file) - lockf (fileno (file), F_ULOCK, 0); + if (lockf (fileno (file), F_ULOCK, 0) < 0) + gf_log ("", GF_LOG_WARNING, "Cannot unlock pidfile: %s" + " reason: %s", pidfile, strerror(errno)); if (file) fclose (file); return ret; @@ -1085,7 +1087,9 @@ connect: goto out; out: if (is_locked && file) - lockf (fileno (file), F_ULOCK, 0); + if (lockf (fileno (file), F_ULOCK, 0) < 0) + gf_log ("", GF_LOG_WARNING, "Cannot unlock pidfile: %s" + " reason: %s", pidfile, strerror(errno)); if (file) fclose (file); return ret; diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c index e43b666d861..13eb1c0eb7d 100644 --- a/xlators/nfs/server/src/nfs3.c +++ b/xlators/nfs/server/src/nfs3.c @@ -2548,11 +2548,12 @@ out: int nfs3svc_create (rpcsvc_request_t *req) { - char name[NFS_PATH_MAX]; - struct nfs3_fh dirfh = {{0}, }; - create3args args; - int ret = RPCSVC_ACTOR_ERROR; - uint64_t cverf = 0; + char name[NFS_PATH_MAX]; + struct nfs3_fh dirfh = {{0}, }; + create3args args; + int ret = RPCSVC_ACTOR_ERROR; + uint64_t cverf = 0; + uint64_t *cval; if (!req) return ret; @@ -2564,7 +2565,14 @@ nfs3svc_create (rpcsvc_request_t *req) goto rpcerr; } - cverf = *(uint64_t *)args.how.createhow3_u.verf; + cval = (uint64_t *)args.how.createhow3_u.verf; + if (cval) + cverf = *cval; + else { + gf_log(GF_NFS3, GF_LOG_ERROR, "Error getting createverf3 from args"); + goto rpcerr; + } + ret = nfs3_create (req, &dirfh, name, args.how.mode, &args.how.createhow3_u.obj_attributes, cverf); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { @@ -4241,6 +4249,7 @@ nfs3svc_readdir (rpcsvc_request_t *req) struct nfs3_fh fh = {{0},}; int ret = RPCSVC_ACTOR_ERROR; uint64_t verf = 0; + uint64_t *cval; if (!req) return ret; @@ -4251,7 +4260,15 @@ nfs3svc_readdir (rpcsvc_request_t *req) goto rpcerr; } - verf = *(uint64_t *)ra.cookieverf; + cval = (uint64_t *) ra.cookieverf; + + if (cval) + verf = *cval; + else { + gf_log(GF_NFS3, GF_LOG_ERROR, "Error getting cookieverf from readdir args"); + goto rpcerr; + } + ret = nfs3_readdir (req, &fh, ra.cookie, verf, ra.count, 0); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { gf_log (GF_NFS3, GF_LOG_ERROR, "READDIR procedure failed"); @@ -4271,6 +4288,7 @@ nfs3svc_readdirp (rpcsvc_request_t *req) struct nfs3_fh fh = {{0},}; int ret = RPCSVC_ACTOR_ERROR; uint64_t cverf = 0; + uint64_t *cval; if (!req) return ret; @@ -4281,7 +4299,15 @@ nfs3svc_readdirp (rpcsvc_request_t *req) goto rpcerr; } - cverf = *(uint64_t *)ra.cookieverf; + cval = (uint64_t *) ra.cookieverf; + + if (cval) + cverf = *cval; + else { + gf_log (GF_NFS3, GF_LOG_ERROR, "Error getting cookieverf from readdirp args"); + goto rpcerr; + } + ret = nfs3_readdir (req, &fh, ra.cookie, cverf, ra.dircount, ra.maxcount); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { |