Current exec_req() receives the parameter wlen as unsigned int *. But I believe this is confusing, because exec_req() never updates the content of wlen. So this patch changes the type of wlen from unsigned int * to unsigned int.
Signed-off-by: Hitoshi Mitake <[email protected]> --- collie/cluster.c | 8 ++++---- collie/collie.c | 2 +- collie/common.c | 8 ++++---- collie/debug.c | 2 +- collie/node.c | 2 +- collie/vdi.c | 16 ++++++++-------- include/net.h | 4 ++-- lib/net.c | 12 ++++++------ sheep/gateway.c | 4 ++-- sheep/group.c | 2 +- sheep/recovery.c | 4 ++-- sheep/sheep_priv.h | 2 +- sheep/sockfd_cache.c | 2 +- sheep/store.c | 2 +- sheepfs/volume.c | 6 +++--- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/collie/cluster.c b/collie/cluster.c index ace5254..d3746c7 100644 --- a/collie/cluster.c +++ b/collie/cluster.c @@ -57,7 +57,7 @@ static int list_store(void) sd_init_req(&hdr, SD_OP_GET_STORE_LIST); hdr.data_length = rlen; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); close(fd); if (ret) { @@ -112,7 +112,7 @@ static int cluster_format(int argc, char **argv) rlen = 0; printf("using backend %s store\n", store_name); - ret = exec_req(fd, (struct sd_req *)&hdr, store_name, &wlen, &rlen); + ret = exec_req(fd, (struct sd_req *)&hdr, store_name, wlen, &rlen); close(fd); if (ret) { @@ -165,7 +165,7 @@ again: rlen = hdr.data_length; wlen = 0; - ret = exec_req(fd, &hdr, logs, &wlen, &rlen); + ret = exec_req(fd, &hdr, logs, wlen, &rlen); close(fd); if (ret != 0) @@ -286,7 +286,7 @@ static int list_snap(void) sd_init_req(&hdr, SD_OP_GET_SNAP_FILE); hdr.data_length = rlen; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); close(fd); if (ret) { diff --git a/collie/collie.c b/collie/collie.c index 18c3cf2..68db243 100644 --- a/collie/collie.c +++ b/collie/collie.c @@ -71,7 +71,7 @@ static int update_node_list(int max_nodes, uint32_t epoch) wlen = 0; - ret = exec_req(fd, (struct sd_req *)&hdr, buf, &wlen, &size); + ret = exec_req(fd, (struct sd_req *)&hdr, buf, wlen, &size); if (ret) { ret = -1; goto out; diff --git a/collie/common.c b/collie/common.c index bca213b..15d766b 100644 --- a/collie/common.c +++ b/collie/common.c @@ -64,7 +64,7 @@ int sd_read_object(uint64_t oid, void *data, unsigned int datalen, if (direct) hdr.flags |= SD_FLAG_CMD_DIRECT; - ret = exec_req(fd, &hdr, data, &wlen, &rlen); + ret = exec_req(fd, &hdr, data, wlen, &rlen); close(fd); if (ret) { @@ -115,7 +115,7 @@ int sd_write_object(uint64_t oid, uint64_t cow_oid, void *data, hdr.obj.cow_oid = cow_oid; hdr.obj.offset = offset; - ret = exec_req(fd, &hdr, data, &wlen, &rlen); + ret = exec_req(fd, &hdr, data, wlen, &rlen); close(fd); if (ret) { @@ -157,7 +157,7 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data) sd_init_req(&req, SD_OP_GET_VDI_COPIES); req.data_length = rlen; - ret = exec_req(fd, &req, (char *)vc, &wlen, &rlen); + ret = exec_req(fd, &req, (char *)vc, wlen, &rlen); if (ret < 0) { fprintf(stderr, "Failed to read VDIs from %s:%d\n", sdhost, sdport); @@ -217,7 +217,7 @@ int send_light_req_get_response(struct sd_req *hdr, const char *host, int port) rlen = 0; wlen = 0; - ret = exec_req(fd, hdr, NULL, &wlen, &rlen); + ret = exec_req(fd, hdr, NULL, wlen, &rlen); close(fd); if (ret) { fprintf(stderr, "failed to connect to %s:%d\n", diff --git a/collie/debug.c b/collie/debug.c index b2d63d9..006e576 100644 --- a/collie/debug.c +++ b/collie/debug.c @@ -97,7 +97,7 @@ read_buffer: hdr.epoch = sd_epoch; wlen = 0; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); if (ret) { fprintf(stderr, "Failed to connect\n"); diff --git a/collie/node.c b/collie/node.c index b5aeec1..2f1be00 100644 --- a/collie/node.c +++ b/collie/node.c @@ -165,7 +165,7 @@ static int node_cache(int argc, char **argv) hdr.flags = SD_FLAG_CMD_WRITE; hdr.data_length = wlen; - ret = exec_req(fd, &hdr, (void *)&cache_size, &wlen, &rlen); + ret = exec_req(fd, &hdr, (void *)&cache_size, wlen, &rlen); close(fd); if (ret) { diff --git a/collie/vdi.c b/collie/vdi.c index e0581b8..0c83517 100644 --- a/collie/vdi.c +++ b/collie/vdi.c @@ -307,7 +307,7 @@ static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data, unsigne hdr.obj.oid = oid; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); close(fd); sprintf(name + strlen(name), ":%d", sd_nodes[i].nid.port); @@ -399,7 +399,7 @@ static int find_vdi_name(char *vdiname, uint32_t snapid, const char *tag, hdr.flags = SD_FLAG_CMD_WRITE; hdr.vdi.snapid = snapid; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); if (ret) { ret = -1; goto out; @@ -481,7 +481,7 @@ static int do_vdi_create(char *vdiname, int64_t vdi_size, uint32_t base_vid, hdr.vdi.vdi_size = roundup(vdi_size, 512); hdr.vdi.copies = nr_copies; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); close(fd); @@ -748,7 +748,7 @@ static int do_vdi_delete(const char *vdiname, int snap_id, const char *snap_tag) if (snap_tag) strncpy(data + SD_MAX_VDI_LEN, snap_tag, SD_MAX_VDI_TAG_LEN); - ret = exec_req(fd, &hdr, data, &wlen, &rlen); + ret = exec_req(fd, &hdr, data, wlen, &rlen); close(fd); if (ret) { @@ -895,7 +895,7 @@ again: rlen = hdr.data_length; wlen = 0; - ret = exec_req(fd, &hdr, logs, &wlen, &rlen); + ret = exec_req(fd, &hdr, logs, wlen, &rlen); close(fd); if (ret != 0) @@ -1025,7 +1025,7 @@ static int find_vdi_attr_oid(char *vdiname, char *tag, uint32_t snapid, if (delete) hdr.flags |= SD_FLAG_CMD_DEL; - ret = exec_req(fd, &hdr, &vattr, &wlen, &rlen); + ret = exec_req(fd, &hdr, &vattr, wlen, &rlen); if (ret) { ret = SD_RES_EIO; goto out; @@ -1387,7 +1387,7 @@ static void *read_object_from(struct sd_vnode *vnode, uint64_t oid) hdr.obj.oid = oid; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); close(fd); if (ret) { @@ -1429,7 +1429,7 @@ static void write_object_to(struct sd_vnode *vnode, uint64_t oid, void *buf) hdr.obj.oid = oid; - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); close(fd); if (ret) { diff --git a/include/net.h b/include/net.h index 7fd9f46..bce21f0 100644 --- a/include/net.h +++ b/include/net.h @@ -41,9 +41,9 @@ int do_read(int sockfd, void *buf, int len); int rx(struct connection *conn, enum conn_state next_state); int tx(struct connection *conn, enum conn_state next_state, int flags); int connect_to(const char *name, int port); -int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int *wlen); +int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int wlen); int exec_req(int sockfd, struct sd_req *hdr, void *data, - unsigned int *wlen, unsigned int *rlen); + unsigned int wlen, unsigned int *rlen); int create_listen_ports(char *bindaddr, int port, int (*callback)(int fd, void *), void *data); diff --git a/lib/net.c b/lib/net.c index 1c6a632..bdb666d 100644 --- a/lib/net.c +++ b/lib/net.c @@ -320,7 +320,7 @@ rewrite: return 0; } -int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int *wlen) +int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int wlen) { int ret; struct msghdr msg; @@ -334,16 +334,16 @@ int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int *wlen) iov[0].iov_base = hdr; iov[0].iov_len = sizeof(*hdr); - if (*wlen) { + if (wlen) { msg.msg_iovlen++; iov[1].iov_base = data; - iov[1].iov_len = *wlen; + iov[1].iov_len = wlen; } - ret = do_write(sockfd, &msg, sizeof(*hdr) + *wlen); + ret = do_write(sockfd, &msg, sizeof(*hdr) + wlen); if (ret) { eprintf("failed to send request %x, %d: %m\n", hdr->opcode, - *wlen); + wlen); ret = -1; } @@ -351,7 +351,7 @@ int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int *wlen) } int exec_req(int sockfd, struct sd_req *hdr, void *data, - unsigned int *wlen, unsigned int *rlen) + unsigned int wlen, unsigned int *rlen) { int ret; struct sd_rsp *rsp = (struct sd_rsp *)hdr; diff --git a/sheep/gateway.c b/sheep/gateway.c index f9419ec..1b5382e 100644 --- a/sheep/gateway.c +++ b/sheep/gateway.c @@ -78,7 +78,7 @@ int gateway_read_obj(struct request *req) gateway_init_fwd_hdr(&fwd_hdr, &req->rq); wlen = 0; rlen = fwd_hdr.data_length; - ret = sheep_exec_req(&v->nid, &fwd_hdr, req->data, &wlen, + ret = sheep_exec_req(&v->nid, &fwd_hdr, req->data, wlen, &rlen); if (ret != SD_RES_SUCCESS) continue; @@ -288,7 +288,7 @@ static int gateway_forward_request(struct request *req, bool all_node) break; } - ret = send_req(sfd->fd, &hdr, req->data, &wlen); + ret = send_req(sfd->fd, &hdr, req->data, wlen); if (ret) { sheep_del_sockfd(nid, sfd); err_ret = SD_RES_NETWORK_ERROR; diff --git a/sheep/group.c b/sheep/group.c index ebb6192..e08c887 100644 --- a/sheep/group.c +++ b/sheep/group.c @@ -625,7 +625,7 @@ static int get_vdis_from(struct sd_node *node) hdr.epoch = sys->epoch; hdr.data_length = rlen; wlen = 0; - ret = sheep_exec_req(&node->nid, &hdr, (char *)vc, &wlen, &rlen); + ret = sheep_exec_req(&node->nid, &hdr, (char *)vc, wlen, &rlen); if (ret != SD_RES_SUCCESS) goto out; diff --git a/sheep/recovery.c b/sheep/recovery.c index f455a2b..456c798 100644 --- a/sheep/recovery.c +++ b/sheep/recovery.c @@ -91,7 +91,7 @@ static int recover_object_from_replica(uint64_t oid, struct sd_vnode *vnode, hdr.obj.oid = oid; hdr.obj.tgt_epoch = tgt_epoch; - ret = sheep_exec_req(&vnode->nid, &hdr, buf, &wlen, &rlen); + ret = sheep_exec_req(&vnode->nid, &hdr, buf, wlen, &rlen); if (ret != SD_RES_SUCCESS) goto out; iocb.epoch = epoch; @@ -525,7 +525,7 @@ static int fetch_object_list(struct sd_node *e, uint32_t epoch, hdr.flags = 0; hdr.data_length = rlen; - ret = sheep_exec_req(&e->nid, (struct sd_req *)&hdr, buf, &wlen, &rlen); + ret = sheep_exec_req(&e->nid, (struct sd_req *)&hdr, buf, wlen, &rlen); if (ret != SD_RES_SUCCESS) return -1; diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h index 7ed5130..daa3bff 100644 --- a/sheep/sheep_priv.h +++ b/sheep/sheep_priv.h @@ -405,7 +405,7 @@ struct sockfd *sheep_get_sockfd(struct node_id *); void sheep_put_sockfd(struct node_id *, struct sockfd *); void sheep_del_sockfd(struct node_id *, struct sockfd *); int sheep_exec_req(struct node_id *nid, struct sd_req *hdr, void *data, - unsigned int *wlen, unsigned int *rlen); + unsigned int wlen, unsigned int *rlen); static inline bool is_object_cache_enabled(void) { diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c index ac1c9ce..b1b86d4 100644 --- a/sheep/sockfd_cache.c +++ b/sheep/sockfd_cache.c @@ -464,7 +464,7 @@ void sheep_del_sockfd(struct node_id *nid, struct sockfd *sfd) } int sheep_exec_req(struct node_id *nid, struct sd_req *hdr, void *buf, - unsigned int *wlen, unsigned int *rlen) + unsigned int wlen, unsigned int *rlen) { struct sd_rsp *rsp = (struct sd_rsp *)hdr; struct sockfd *sfd; diff --git a/sheep/store.c b/sheep/store.c index e3c95bd..939a07b 100644 --- a/sheep/store.c +++ b/sheep/store.c @@ -101,7 +101,7 @@ int epoch_log_read_remote(uint32_t epoch, struct sd_node *nodes, int len) hdr.data_length = rlen = len; hdr.obj.tgt_epoch = epoch; wlen = 0; - ret = sheep_exec_req(&local_nodes[i].nid, &hdr, nodes, &wlen, + ret = sheep_exec_req(&local_nodes[i].nid, &hdr, nodes, wlen, &rlen); if (ret != SD_RES_SUCCESS) continue; diff --git a/sheepfs/volume.c b/sheepfs/volume.c index 20cf029..fd60b46 100644 --- a/sheepfs/volume.c +++ b/sheepfs/volume.c @@ -200,7 +200,7 @@ static int volume_rw_object(char *buf, uint64_t oid, size_t size, hdr.flags |= SD_FLAG_CMD_CACHE; fd = get_socket_fd(vdi, &sock_idx); - ret = exec_req(fd, &hdr, buf, &wlen, &rlen); + ret = exec_req(fd, &hdr, buf, wlen, &rlen); put_socket_fd(vdi, sock_idx); if (ret || rsp->result != SD_RES_SUCCESS) { @@ -307,7 +307,7 @@ static int volume_do_sync(uint32_t vid) hdr.obj.oid = vid_to_vdi_oid(vid); fd = get_socket_fd(vdi, &idx); - ret = exec_req(fd, &hdr, NULL, &wlen, &rlen); + ret = exec_req(fd, &hdr, NULL, wlen, &rlen); put_socket_fd(vdi, idx); if (ret || rsp->result != SD_RES_SUCCESS) { @@ -495,7 +495,7 @@ static int volume_sync_and_delete(uint32_t vid) hdr.obj.oid = vid_to_vdi_oid(vid); fd = get_socket_fd(vdi, &idx); - ret = exec_req(fd, &hdr, NULL, &wlen, &rlen); + ret = exec_req(fd, &hdr, NULL, wlen, &rlen); put_socket_fd(vdi, idx); if (ret || rsp->result != SD_RES_SUCCESS) { -- 1.7.5.1 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
