From 0c1cee625818275dd1b3f6718bd246d2e30dabd1 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Tue, 10 Jul 2012 10:19:16 -0400 Subject: calls to dict_allocate_and_serialize() are not 64-bit clean All calls to dict_allocate_and_serialize() pass the address of a 32-bit type, but must cast it to the 64-bit pointer type (size_t *). This happens to work on LE machines, but even if it's apparently benign, it's still a bug. On BE machines it is not benign. GF_PROTOCOL_DICT_SERIALIZE() hacks around it by creating a size_t temp var, but that's, well, a hack, IMO when you consider that all the callers are actually passing &; the param should just be a u_int * and eliminate the buggy casts and the temp var in the macro. Nobody apparently uses the Fedora/EPEL PPC RPMs, but they might. People are trying to build gluster.org bits on SPARC and tripping over this. Change-Id: I92ea139f9e3e91ddbbb32a51b96fa582a9515626 Signed-off-by: Kaleb S. KEITHLEY BUG: 838928 Reviewed-on: http://review.gluster.com/3643 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-handler.c | 18 ++++++++---------- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 4 ++-- xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 16 ++++++---------- xlators/mgmt/glusterd/src/glusterd-syncop.c | 8 ++++---- 4 files changed, 20 insertions(+), 26 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 0e3c211b3f9..2dcfd28148f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -928,7 +928,7 @@ glusterd_handle_cli_list_volume (rpcsvc_request_t *req) goto out; ret = dict_allocate_and_serialize (dict, &rsp.dict.dict_val, - (size_t *)&rsp.dict.dict_len); + &rsp.dict.dict_len); if (ret) goto out; @@ -1229,7 +1229,7 @@ glusterd_fsm_log_send_resp (rpcsvc_request_t *req, int op_ret, rsp.op_errstr = op_errstr; if (rsp.op_ret == 0) ret = dict_allocate_and_serialize (dict, &rsp.fsm_log.fsm_log_val, - (size_t *)&rsp.fsm_log.fsm_log_len); + &rsp.fsm_log.fsm_log_len); ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf1_cli_fsm_log_rsp); @@ -1401,9 +1401,8 @@ glusterd_op_stage_send_resp (rpcsvc_request_t *req, else rsp.op_errstr = ""; - ret = dict_allocate_and_serialize (rsp_dict, - &rsp.dict.dict_val, - (size_t *)&rsp.dict.dict_len); + ret = dict_allocate_and_serialize (rsp_dict, &rsp.dict.dict_val, + &rsp.dict.dict_len); if (ret < 0) { gf_log ("", GF_LOG_DEBUG, "failed to get serialized length of dict"); @@ -1440,9 +1439,8 @@ glusterd_op_commit_send_resp (rpcsvc_request_t *req, rsp.op_errstr = ""; if (rsp_dict) { - ret = dict_allocate_and_serialize (rsp_dict, - &rsp.dict.dict_val, - (size_t *)&rsp.dict.dict_len); + ret = dict_allocate_and_serialize (rsp_dict, &rsp.dict.dict_val, + &rsp.dict.dict_len); if (ret < 0) { gf_log ("", GF_LOG_DEBUG, "failed to get serialized length of dict"); @@ -2469,7 +2467,7 @@ glusterd_list_friends (rpcsvc_request_t *req, dict_t *dict, int32_t flags) } ret = dict_allocate_and_serialize (friends, &rsp.friends.friends_val, - (size_t *)&rsp.friends.friends_len); + &rsp.friends.friends_len); if (ret) goto out; @@ -2576,7 +2574,7 @@ respond: if (ret) goto out; ret = dict_allocate_and_serialize (volumes, &rsp.dict.dict_val, - (size_t *)&rsp.dict.dict_len); + &rsp.dict.dict_len); if (ret) goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 2d56778102f..586312a9c53 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -233,7 +233,7 @@ glusterd_brick_op_build_payload (glusterd_op_t op, glusterd_brickinfo_t *brickin } ret = dict_allocate_and_serialize (dict, &brick_req->input.input_val, - (size_t*)&brick_req->input.input_len); + &brick_req->input.input_len); if (ret) goto out; *req = brick_req; @@ -285,7 +285,7 @@ glusterd_node_op_build_payload (glusterd_op_t op, gd1_mgmt_brick_op_req **req, } ret = dict_allocate_and_serialize (dict, &brick_req->input.input_val, - (size_t*)&brick_req->input.input_len); + &brick_req->input.input_len); if (ret) goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index a7ccda71f72..f47b5b70db3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -167,7 +167,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, if (ctx) { ret = dict_allocate_and_serialize (ctx, &rsp.dict.dict_val, - (size_t*)&rsp.dict.dict_len); + &rsp.dict.dict_len); if (ret < 0 ) gf_log (THIS->name, GF_LOG_ERROR, "failed to " "serialize buffer"); @@ -1493,7 +1493,7 @@ glusterd3_1_friend_add (call_frame_t *frame, xlator_t *this, req.port = peerinfo->port; ret = dict_allocate_and_serialize (vols, &req.vols.vols_val, - (size_t *)&req.vols.vols_len); + &req.vols.vols_len); if (ret) goto out; @@ -1558,8 +1558,6 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this, int ret = 0; glusterd_conf_t *priv = NULL; dict_t *friends = NULL; - char *dict_buf = NULL; - size_t len = -1; call_frame_t *dummy_frame = NULL; glusterd_peerinfo_t *peerinfo = NULL; @@ -1574,13 +1572,11 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this, if (ret) goto out; - ret = dict_allocate_and_serialize (friends, &dict_buf, (size_t *)&len); + ret = dict_allocate_and_serialize (friends, &req.friends.friends_val, + &req.friends.friends_len); if (ret) goto out; - req.friends.friends_val = dict_buf; - req.friends.friends_len = len; - uuid_copy (req.uuid, priv->uuid); dummy_frame = create_frame (this, this->ctx->pool); @@ -1698,7 +1694,7 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this, req.op = glusterd_op_get_op (); ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); + &req.buf.buf_len); if (ret) goto out; @@ -1752,7 +1748,7 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this, req.op = glusterd_op_get_op (); ret = dict_allocate_and_serialize (dict, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); + &req.buf.buf_len); if (ret) goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c index 7cdc1c3c28b..2b2e9d2e69d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.c +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c @@ -295,8 +295,8 @@ gd_syncop_mgmt_stage_op (struct rpc_clnt *rpc, uuid_t my_uuid, uuid_t recv_uuid, args.op_ret = -1; args.op_errno = ENOTCONN; - ret = dict_allocate_and_serialize (dict_out, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); + ret = dict_allocate_and_serialize (dict_out, + &req.buf.buf_val, &req.buf.buf_len); if (ret) goto out; @@ -395,8 +395,8 @@ gd_syncop_mgmt_commit_op (struct rpc_clnt *rpc, uuid_t my_uuid, uuid_t recv_uuid args.op_ret = -1; args.op_errno = ENOTCONN; - ret = dict_allocate_and_serialize (dict_out, &req.buf.buf_val, - (size_t *)&req.buf.buf_len); + ret = dict_allocate_and_serialize (dict_out, + &req.buf.buf_val, &req.buf.buf_len); if (ret) goto out; -- cgit