[sheepdog] [PATCH 2/4] sheep: fix format of printf for uint64_t
Robin Dong
robin.k.dong at gmail.com
Fri Dec 27 10:14:03 CET 2013
From: Robin Dong <sanbai at taobao.com>
Previously, we use '%lu' to printf uint64_t argument, that is incorrect especially
int 32bit machines. So change it to '%PRIu64'.
Signed-off-by: Robin Dong <sanbai at taobao.com>
---
sheep/cluster/zookeeper.c | 14 ++++++++------
sheep/http/kv.c | 6 +++---
sheep/sheep.c | 2 +-
sheep/store.c | 2 +-
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index f082c03..b80d3c7 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -343,7 +343,7 @@ static struct cluster_lock *lock_table_lookup_acquire(uint64_t lock_id)
ret_lock = xzalloc(sizeof(*ret_lock));
ret_lock->id = lock_id;
ret_lock->ref = 1;
- snprintf(path, MAX_NODE_STR_LEN, LOCK_ZNODE "/%lu",
+ snprintf(path, MAX_NODE_STR_LEN, LOCK_ZNODE "/%"PRIu64,
ret_lock->id);
rc = zk_init_node(path);
if (rc)
@@ -393,7 +393,7 @@ static void lock_table_lookup_release(uint64_t lock_id)
/* free all resource used by this lock */
sd_destroy_mutex(&lock->id_lock);
sd_destroy_mutex(&lock->wait_wakeup);
- snprintf(path, MAX_NODE_STR_LEN, LOCK_ZNODE "/%lu",
+ snprintf(path, MAX_NODE_STR_LEN, LOCK_ZNODE "/%"PRIu64,
lock->id);
/*
* If deletion of directory 'lock_id' fail, we only get
@@ -675,11 +675,12 @@ static void zk_watcher(zhandle_t *zh, int type, int state, const char *path,
struct zk_node *n;
/* process distributed lock */
- ret = sscanf(path, LOCK_ZNODE "/%lu/%s", &lock_id, str);
+ ret = sscanf(path, LOCK_ZNODE "/%"PRIu64"/%s", &lock_id, str);
if (ret == 2) {
ret = lock_table_lookup_wakeup(lock_id);
if (ret)
- sd_debug("release lock %lu %s", lock_id, str);
+ sd_debug("release lock %"PRIu64" %s",
+ lock_id, str);
return;
}
@@ -1242,7 +1243,7 @@ static void zk_lock(uint64_t lock_id)
my_path = cluster_lock->lock_path;
/* compete owner of lock is just like zk_compete_master() */
- snprintf(parent, MAX_NODE_STR_LEN, LOCK_ZNODE "/%lu/",
+ snprintf(parent, MAX_NODE_STR_LEN, LOCK_ZNODE "/%"PRIu64"/",
cluster_lock->id);
while (true) {
rc = zoo_create(zhandle, parent, "", 0, &ZOO_OPEN_ACL_UNSAFE,
@@ -1255,7 +1256,8 @@ static void zk_lock(uint64_t lock_id)
sd_debug("create path %s success", my_path);
/* create node ok now */
- snprintf(parent, MAX_NODE_STR_LEN, LOCK_ZNODE "/%lu", cluster_lock->id);
+ snprintf(parent, MAX_NODE_STR_LEN, LOCK_ZNODE "/%"PRIu64"",
+ cluster_lock->id);
while (true) {
zk_get_least_seq(parent, lowest_seq_path, MAX_NODE_STR_LEN,
owner_name, &len);
diff --git a/sheep/http/kv.c b/sheep/http/kv.c
index dd1712a..c2e8b29 100644
--- a/sheep/http/kv.c
+++ b/sheep/http/kv.c
@@ -133,7 +133,7 @@ static void bucket_iterater(void *data, enum btree_node_type type, void *arg)
oid = vid_to_data_oid(ext->vdi_id, ext->idx);
ret = sd_read_object(oid, (char *)&bnode, sizeof(bnode), 0);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read data object %lx", oid);
+ sd_err("Failed to read data object %"PRIx64, oid);
return;
}
@@ -164,7 +164,7 @@ static int read_account_meta(const char *account, uint64_t *bucket_count,
inode = xmalloc(sizeof(*inode));
ret = sd_read_object(oid, (char *)inode, sizeof(struct sd_inode), 0);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read inode header %lx", oid);
+ sd_err("Failed to read inode header %"PRIx64, oid);
goto out;
}
@@ -475,7 +475,7 @@ static void object_iterater(void *data, enum btree_node_type type, void *arg)
oid = vid_to_data_oid(ext->vdi_id, ext->idx);
ret = sd_read_object(oid, (char *)onode, SD_DATA_OBJ_SIZE, 0);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read data object %lx", oid);
+ sd_err("Failed to read data object %"PRIx64, oid);
goto out;
}
diff --git a/sheep/sheep.c b/sheep/sheep.c
index a87c49d..953739c 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -823,7 +823,7 @@ int main(int argc, char **argv)
if (!strlen(jpath))
/* internal journal */
memcpy(jpath, dir, strlen(dir));
- sd_debug("%s, %zd, %d", jpath, jsize, jskip);
+ sd_debug("%s, %"PRIu64", %d", jpath, jsize, jskip);
ret = journal_file_init(jpath, jsize, jskip);
if (ret)
exit(1);
diff --git a/sheep/store.c b/sheep/store.c
index e7c04ab..d74be4c 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -470,7 +470,7 @@ int sd_discard_object(uint64_t oid)
ret = exec_local_req(&hdr, NULL);
if (ret != SD_RES_SUCCESS)
- sd_err("Failed to discard data obj %lu %s", oid,
+ sd_err("Failed to discard data obj %"PRIu64" %s", oid,
sd_strerror(ret));
return ret;
--
1.7.12.4
More information about the sheepdog
mailing list