[sheepdog] [PATCH 1/6] sheep: fix type warnings on 32 bit machines

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Jul 12 02:51:35 CEST 2012


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/cluster/zookeeper.c |   23 +++++++++++++----------
 sheep/object_cache.c      |   12 ++++++------
 sheep/recovery.c          |    2 +-
 3 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 7bd20bd..c86c757 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -188,7 +188,8 @@ static int32_t zk_queue_push(zhandle_t *zh, struct zk_event *ev)
 	sprintf(path, "%s/", QUEUE_ZNODE);
 	rc = zk_create(zh, path, (char *)ev, len,
 		&ZOO_OPEN_ACL_UNSAFE, ZOO_SEQUENCE, buf, sizeof(buf));
-	dprintf("create path:%s, nr_nodes:%ld, queue_pos:%010d, len:%d, rc:%d\n", buf, nr_zk_nodes, queue_pos, len, rc);
+	dprintf("create path:%s, nr_nodes:%zu, queue_pos:%010d, len:%d,"
+		" rc:%d\n", buf, nr_zk_nodes, queue_pos, len, rc);
 	if (rc != ZOK)
 		panic("failed to zk_create path:%s, rc:%d\n", path, rc);
 
@@ -288,7 +289,8 @@ static int zk_queue_pop(zhandle_t *zh, struct zk_event *ev)
 	len = sizeof(*ev);
 	sprintf(path, QUEUE_ZNODE "/%010d", queue_pos);
 	rc = zk_get(zh, path, 1, (char *)ev, &len, NULL);
-	dprintf("read path:%s, nr_nodes:%ld, type:%d, len:%d, rc:%d\n", path, nr_zk_nodes, ev->type, len, rc);
+	dprintf("read path:%s, nr_nodes:%zu, type:%d, len:%d, rc:%d\n", path,
+		nr_zk_nodes, ev->type, len, rc);
 	if (rc != ZOK)
 		panic("failed to zk_set path:%s, rc:%d\n", path, rc);
 
@@ -401,7 +403,7 @@ static inline void build_node_list(void *btroot)
 	nr_sd_nodes = 0;
 	twalk(btroot, node_btree_build_list_fn);
 	assert(nr_sd_nodes == nr_zk_nodes);
-	dprintf("nr_sd_nodes:%lu\n", nr_sd_nodes);
+	dprintf("nr_sd_nodes:%zu\n", nr_sd_nodes);
 }
 
 static void node_btree_find_master_fn(const void *nodep,
@@ -477,7 +479,7 @@ static void zk_member_init(zhandle_t *zh)
 			}
 		}
 	}
-	dprintf("nr_nodes:%ld\n", nr_zk_nodes);
+	dprintf("nr_nodes:%zu\n", nr_zk_nodes);
 }
 
 
@@ -536,7 +538,7 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path, void*
 	if (type == -1) {
 		cid = zoo_client_id(zh);
 		assert(cid != NULL);
-		dprintf("session change, clientid:%ld\n", cid->client_id);
+		dprintf("session change, clientid:%"PRId64"\n", cid->client_id);
 	}
 
 	/* discard useless event */
@@ -588,7 +590,7 @@ static int zk_join(struct sd_node *myself,
 	assert(cid != NULL);
 	this_node.clientid = *cid;
 
-	dprintf("clientid:%ld\n", cid->client_id);
+	dprintf("clientid:%"PRId64"\n", cid->client_id);
 
 	return add_event(zhandle, EVENT_JOIN_REQUEST, &this_node,
 			 opaque, opaque_len);
@@ -665,7 +667,7 @@ static void zk_handler(int listen_fd, int events, void *data)
 
 	switch (ev.type) {
 	case EVENT_JOIN_REQUEST:
-		dprintf("JOIN REQUEST nr_nodes: %ld, sender: %s, joined: %d\n",
+		dprintf("JOIN REQUEST nr_nodes: %zu, sender: %s, joined: %d\n",
 			nr_zk_nodes, node_to_str(&ev.sender.node),
 			ev.sender.joined);
 
@@ -725,8 +727,9 @@ static void zk_handler(int listen_fd, int events, void *data)
 			node_btree_clear(&zk_node_btroot);
 
 		node_btree_add(&zk_node_btroot, &ev.sender);
-		dprintf("one sheep joined[down], nr_nodes:%ld, sender:%s, joined:%d\n",
-				nr_zk_nodes, node_to_str(&ev.sender.node), ev.sender.joined);
+		dprintf("one sheep joined[down], nr_nodes:%zu, sender:%s,"
+			" joined:%d\n", nr_zk_nodes,
+			node_to_str(&ev.sender.node), ev.sender.joined);
 
 		switch (ev.join_result) {
 		case CJ_RES_SUCCESS:
@@ -761,7 +764,7 @@ static void zk_handler(int listen_fd, int events, void *data)
 		}
 
 		node_btree_del(&zk_node_btroot, n);
-		dprintf("one sheep left, nr_nodes:%ld\n", nr_zk_nodes);
+		dprintf("one sheep left, nr_nodes:%zu\n", nr_zk_nodes);
 
 		build_node_list(zk_node_btroot);
 		sd_leave_handler(&ev.sender.node, sd_nodes, nr_sd_nodes);
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 146b0fd..b014f26 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -93,7 +93,7 @@ static inline int idx_has_vdi_bit(uint32_t idx)
 static uint64_t calc_object_bmap(size_t len, off_t offset)
 {
 	int start, end, nr;
-	uint64_t bmap = 0;
+	unsigned long bmap = 0;
 
 	start = offset / CACHE_BLOCK_SIZE;
 	end = DIV_ROUND_UP(len + offset, CACHE_BLOCK_SIZE);
@@ -102,7 +102,7 @@ static uint64_t calc_object_bmap(size_t len, off_t offset)
 	while (nr--)
 		set_bit(start + nr, &bmap);
 
-	return bmap;
+	return (uint64_t)bmap;
 }
 
 static struct object_cache_entry *
@@ -355,8 +355,8 @@ static int write_cache_object(uint32_t vid, uint32_t idx, void *buf,
 	}
 
 	if (size != count) {
-		eprintf("size %zu, count:%zu, offset %zu %m\n",
-			size, count, offset);
+		eprintf("size %zu, count:%zu, offset %jd %m\n",
+			size, count, (intmax_t)offset);
 		ret = SD_RES_EIO;
 	}
 out_close:
@@ -400,8 +400,8 @@ static int read_cache_object(uint32_t vid, uint32_t idx, void *buf,
 	}
 
 	if (size != count) {
-		eprintf("size %zu, count:%zu, offset %zu %m\n",
-			size, count, offset);
+		eprintf("size %zu, count:%zu, offset %jd %m\n",
+			size, count, (intmax_t)offset);
 		ret = SD_RES_EIO;
 	}
 
diff --git a/sheep/recovery.c b/sheep/recovery.c
index 3a609da..444e99f 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -499,7 +499,7 @@ static int fetch_object_list(struct sd_node *e, uint32_t epoch,
 		return -1;
 	}
 
-	dprintf("%"PRIu64"\n", rsp->data_length / sizeof(uint64_t));
+	dprintf("%zu\n", rsp->data_length / sizeof(uint64_t));
 
 	return rsp->data_length / sizeof(uint64_t);
 }
-- 
1.7.2.5




More information about the sheepdog mailing list