[sheepdog] [PATCH 3/3] fix sparse errors

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sat Oct 6 17:36:33 CEST 2012


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 collie/cluster.c          |    2 +-
 collie/debug.c            |    2 +-
 collie/vdi.c              |    4 ++--
 lib/logger.c              |    2 +-
 sheep/cluster/accord.c    |    2 +-
 sheep/cluster/corosync.c  |    2 +-
 sheep/cluster/local.c     |    8 ++++----
 sheep/cluster/zookeeper.c |    5 +++--
 sheep/farm/farm.c         |    2 +-
 sheep/group.c             |    4 ++--
 sheep/migrate.c           |    2 --
 sheep/object_list_cache.c |    2 +-
 sheep/plain_store.c       |    2 +-
 sheep/sheep_priv.h        |    1 +
 sheep/trace/trace.c       |    2 +-
 sheep/vdi.c               |    2 +-
 sheepfs/core.c            |    2 +-
 sheepfs/sheepfs.h         |    2 +-
 18 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/collie/cluster.c b/collie/cluster.c
index 517b090..ace5254 100644
--- a/collie/cluster.c
+++ b/collie/cluster.c
@@ -27,7 +27,7 @@ static struct sd_option cluster_options[] = {
 	{ 0, NULL, false, NULL },
 };
 
-struct cluster_cmd_data {
+static struct cluster_cmd_data {
 	uint32_t epoch;
 	bool list;
 	int copies;
diff --git a/collie/debug.c b/collie/debug.c
index d0eed13..b2d63d9 100644
--- a/collie/debug.c
+++ b/collie/debug.c
@@ -70,7 +70,7 @@ static void parse_trace_buffer(char *buf, int size)
 	return;
 }
 
-const char *tracefile = "/tmp/tracefile";
+static const char *tracefile = "/tmp/tracefile";
 
 static int trace_read_buffer(void)
 {
diff --git a/collie/vdi.c b/collie/vdi.c
index e5d05c5..e0581b8 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -31,7 +31,7 @@ static struct sd_option vdi_options[] = {
 	{ 0, NULL, false, NULL },
 };
 
-struct vdi_cmd_data {
+static struct vdi_cmd_data {
 	unsigned int index;
 	int snapshot_id;
 	char snapshot_tag[SD_MAX_VDI_TAG_LEN];
@@ -1452,7 +1452,7 @@ static void write_object_to(struct sd_vnode *vnode, uint64_t oid, void *buf)
  */
 static void do_check_repair(uint64_t oid, int nr_copies)
 {
-	struct sd_vnode *tgt_vnodes[nr_copies];
+	struct sd_vnode *tgt_vnodes[SD_MAX_COPIES];
 	void *buf, *buf_cmp;
 	int i;
 
diff --git a/lib/logger.c b/lib/logger.c
index 409fad5..c6effe5 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -87,7 +87,7 @@ static key_t semkey;
 
 static int64_t max_logsize = 500 * 1024 * 1024;  /*500MB*/
 
-pthread_mutex_t logsize_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t logsize_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static notrace int logarea_init(int size)
 {
diff --git a/sheep/cluster/accord.c b/sheep/cluster/accord.c
index 770a3a9..d57df58 100644
--- a/sheep/cluster/accord.c
+++ b/sheep/cluster/accord.c
@@ -575,7 +575,7 @@ static int accord_init(const char *option)
 	return 0;
 }
 
-struct cluster_driver cdrv_accord = {
+static struct cluster_driver cdrv_accord = {
 	.name       = "accord",
 
 	.init       = accord_init,
diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index 645d61e..2a564ff 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -817,7 +817,7 @@ again:
 	return 0;
 }
 
-struct cluster_driver cdrv_corosync = {
+static struct cluster_driver cdrv_corosync = {
 	.name		= "corosync",
 
 	.init		= corosync_init,
diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index d17eab5..27b3cfe 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -26,7 +26,7 @@
 #define MAX_EVENTS 500
 #define PROCESS_CHECK_INTERVAL 200 /* ms */
 
-const char *shmfile = "/tmp/sheepdog_shm";
+static const char *shmfile = "/tmp/sheepdog_shm";
 static int shmfd;
 static int sigfd;
 static int block_event_pos;
@@ -82,7 +82,7 @@ struct local_event {
 
 /* shared memory queue */
 
-struct shm_queue {
+static struct shm_queue {
 	int block_event_pos;
 	struct local_event block_events[MAX_EVENTS];
 	int nonblock_event_pos;
@@ -214,7 +214,7 @@ static void shm_queue_init(void)
 	ret = ftruncate(shmfd, sizeof(*shm_queue));
 	assert(ret == 0);
 
-	shm_queue = mmap(0, sizeof(*shm_queue),
+	shm_queue = mmap(NULL, sizeof(*shm_queue),
 			 PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0);
 	assert(shm_queue != MAP_FAILED);
 
@@ -558,7 +558,7 @@ static int local_init(const char *option)
 	return 0;
 }
 
-struct cluster_driver cdrv_local = {
+static struct cluster_driver cdrv_local = {
 	.name		= "local",
 
 	.init		= local_init,
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index ae9a423..9d4216b 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -801,7 +801,8 @@ static int zk_init(const char *option)
 		return -1;
 	}
 
-	zhandle = zookeeper_init(option, watcher, SESSION_TIMEOUT, 0, NULL, 0);
+	zhandle = zookeeper_init(option, watcher, SESSION_TIMEOUT, NULL, NULL,
+				 0);
 	if (!zhandle) {
 		eprintf("failed to connect to zk server %s\n", option);
 		return -1;
@@ -828,7 +829,7 @@ static int zk_init(const char *option)
 	return 0;
 }
 
-struct cluster_driver cdrv_zookeeper = {
+static struct cluster_driver cdrv_zookeeper = {
 	.name       = "zookeeper",
 
 	.init       = zk_init,
diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index 683c1ed..58a26b6 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -274,7 +274,7 @@ out:
 	return ret;
 }
 
-struct store_driver farm = {
+static struct store_driver farm = {
 	.name = "farm",
 	.init = farm_init,
 	.exist = default_exist,
diff --git a/sheep/group.c b/sheep/group.c
index 18564c5..ebb6192 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -40,8 +40,8 @@ struct get_vdis_work {
 	struct sd_node members[];
 };
 
-pthread_mutex_t wait_vdis_lock = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t wait_vdis_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t wait_vdis_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t wait_vdis_cond = PTHREAD_COND_INITIALIZER;
 static int is_vdi_list_ready = true;
 
 static struct vnode_info *current_vnode_info;
diff --git a/sheep/migrate.c b/sheep/migrate.c
index 69ccd0e..51b5fa9 100644
--- a/sheep/migrate.c
+++ b/sheep/migrate.c
@@ -18,8 +18,6 @@
 
 #include "sheep_priv.h"
 
-extern char *config_path;
-
 /* sheepdog 0.4.0 */
 struct node_id_v0 {
 	uint8_t addr[16];
diff --git a/sheep/object_list_cache.c b/sheep/object_list_cache.c
index df94dce..0ad505e 100644
--- a/sheep/object_list_cache.c
+++ b/sheep/object_list_cache.c
@@ -42,7 +42,7 @@ struct objlist_deletion_work {
 	struct work work;
 };
 
-struct objlist_cache obj_list_cache = {
+static struct objlist_cache obj_list_cache = {
 	.tree_version	= 1,
 	.root		= RB_ROOT,
 	.entry_list     = LIST_HEAD_INIT(obj_list_cache.entry_list),
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 6c9b123..640c240 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -499,7 +499,7 @@ int default_flush(void)
 	return ret;
 }
 
-struct store_driver plain_store = {
+static struct store_driver plain_store = {
 	.name = "plain",
 	.init = default_init,
 	.exist = default_exist,
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 9a72f78..7ed5130 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -268,6 +268,7 @@ void queue_cluster_request(struct request *req);
 int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes);
 int log_current_epoch(void);
 
+extern char *config_path;
 int set_cluster_copies(uint8_t copies);
 int get_cluster_copies(uint8_t *copies);
 int set_cluster_flags(uint16_t flags);
diff --git a/sheep/trace/trace.c b/sheep/trace/trace.c
index 326340e..b63f4d2 100644
--- a/sheep/trace/trace.c
+++ b/sheep/trace/trace.c
@@ -362,7 +362,7 @@ void short_thread_end(void)
 		eventfd_write(trace_efd, value);
 }
 
-notrace int trace_init()
+notrace int trace_init(void)
 {
 	sigset_t block;
 	int i;
diff --git a/sheep/vdi.c b/sheep/vdi.c
index c02ec4f..762423a 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -24,7 +24,7 @@ struct vdi_copy_entry {
 
 static uint32_t max_copies;
 static struct rb_root vdi_copy_root = RB_ROOT;
-pthread_rwlock_t vdi_copy_lock = PTHREAD_RWLOCK_INITIALIZER;
+static pthread_rwlock_t vdi_copy_lock = PTHREAD_RWLOCK_INITIALIZER;
 
 static struct vdi_copy_entry *vdi_copy_search(struct rb_root *root,
 					      uint32_t vid)
diff --git a/sheepfs/core.c b/sheepfs/core.c
index f9a0f76..fdb0f97 100644
--- a/sheepfs/core.c
+++ b/sheepfs/core.c
@@ -241,7 +241,7 @@ static int sheepfs_open(const char *path, struct fuse_file_info *fi)
 	return ret;
 }
 
-struct fuse_operations sheepfs_ops =  {
+static struct fuse_operations sheepfs_ops =  {
 	.getattr  = sheepfs_getattr,
 	.readdir  = sheepfs_readdir,
 	.truncate = sheepfs_truncate,
diff --git a/sheepfs/sheepfs.h b/sheepfs/sheepfs.h
index bda109a..1729665 100644
--- a/sheepfs/sheepfs.h
+++ b/sheepfs/sheepfs.h
@@ -31,7 +31,7 @@ extern int sheepfs_set_op(const char *path, unsigned opcode);
 typedef void (*printf_fn)(const char *func, int line, const char *, ...)
 __attribute__ ((format (__printf__, 3, 4)));
 
-printf_fn fs_printf;
+extern printf_fn fs_printf;
 
 #define sheepfs_pr(fmt, args...)			\
 ({							\
-- 
1.7.2.5




More information about the sheepdog mailing list