[sheepdog] [PATCH 4/4] collie: fix uninitialized values

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Sep 6 03:26:40 CEST 2012


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 collie/cluster.c |    5 ++++-
 collie/common.c  |    2 +-
 collie/vdi.c     |    1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/collie/cluster.c b/collie/cluster.c
index 8b28eab..01c112b 100644
--- a/collie/cluster.c
+++ b/collie/cluster.c
@@ -105,9 +105,12 @@ static int cluster_format(int argc, char **argv)
 		strncpy(store_name, cluster_cmd_data.name, STORE_LEN);
 	else
 		strcpy(store_name, DEFAULT_STORE);
-	hdr.data_length = wlen = strlen(store_name) + 1;
+	hdr.data_length = strlen(store_name) + 1;
 	hdr.flags |= SD_FLAG_CMD_WRITE;
 
+	wlen = hdr.data_length;
+	rlen = 0;
+
 	printf("using backend %s store\n", store_name);
 	ret = exec_req(fd, (struct sd_req *)&hdr, store_name, &wlen, &rlen);
 	close(fd);
diff --git a/collie/common.c b/collie/common.c
index 8bfab30..baae9bd 100644
--- a/collie/common.c
+++ b/collie/common.c
@@ -85,7 +85,7 @@ int sd_write_object(uint64_t oid, uint64_t cow_oid, void *data, unsigned int dat
 	struct sd_req hdr;
 	struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
 	int fd, ret;
-	unsigned wlen = datalen, rlen;
+	unsigned wlen = datalen, rlen = 0;
 
 	fd = connect_to(sdhost, sdport);
 	if (fd < 0) {
diff --git a/collie/vdi.c b/collie/vdi.c
index e37db9c..366c946 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -986,6 +986,7 @@ static int find_vdi_attr_oid(char *vdiname, char *tag, uint32_t snapid,
 	unsigned int wlen, rlen;
 	struct sheepdog_vdi_attr vattr;
 
+	memset(&vattr, 0, sizeof(vattr));
 	strncpy(vattr.name, vdiname, SD_MAX_VDI_LEN);
 	strncpy(vattr.tag, vdi_cmd_data.snapshot_tag, SD_MAX_VDI_TAG_LEN);
 	vattr.snap_id = vdi_cmd_data.snapshot_id;
-- 
1.7.2.5




More information about the sheepdog mailing list