[Sheepdog] [PATCH] refactor codes to pass semantic check by sparse

OZAWA Tsuyoshi ozawa.tsuyoshi at lab.ntt.co.jp
Thu Apr 22 19:46:00 CEST 2010


Signed-off-by: OZAWA Tsuyoshi <ozawa.tsuyoshi at lab.ntt.co.jp>
---
 collie/collie.c     |   15 ++++++++-------
 collie/collie.h     |    2 +-
 collie/store.c      |    2 +-
 collie/work.c       |    4 ++--
 shepherd/shepherd.c |   28 ++++++++++++++--------------
 shepherd/treeview.c |   11 ++++++-----
 6 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/collie/collie.c b/collie/collie.c
index 9ab14de..121dcd5 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -25,12 +25,12 @@
 static char program_name[] = "collie";
 
 static struct option const long_options[] = {
-	{"port", required_argument, 0, 'p'},
-	{"foreground", no_argument, 0, 'f'},
-	{"loglevel", required_argument, 0, 'l'},
-	{"debug", no_argument, 0, 'd'},
-	{"help", no_argument, 0, 'h'},
-	{0, 0, 0, 0},
+	{"port", required_argument, NULL, 'p'},
+	{"foreground", no_argument, NULL, 'f'},
+	{"loglevel", required_argument, NULL, 'l'},
+	{"debug", no_argument, NULL, 'd'},
+	{"help", no_argument, NULL, 'h'},
+	{NULL, 0, NULL, 0},
 };
 
 static char *short_options = "p:fl:dh";
@@ -54,7 +54,8 @@ Sheepdog Daemon, version %s\n\
 	exit(status);
 }
 
-struct cluster_info __sys, *sys = &__sys;
+static struct cluster_info __sys;
+struct cluster_info *sys = &__sys;
 
 int main(int argc, char **argv)
 {
diff --git a/collie/collie.h b/collie/collie.h
index 8e43492..3d0a8c8 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -85,7 +85,7 @@ struct cluster_info {
 	unsigned long cpg_event_work_flags;
 };
 
-struct cluster_info *sys;
+extern struct cluster_info *sys;
 
 int create_listen_port(int port, void *data);
 
diff --git a/collie/store.c b/collie/store.c
index 1c3d0ad..8220294 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -1595,7 +1595,7 @@ int get_nodeid(uint64_t *nodeid)
 	return attr(epoch_path, ANAME_NODEID, nodeid, sizeof(*nodeid), 0);
 }
 
-int init_base_path(char *d)
+static int init_base_path(char *d)
 {
 	int new = 0;
 
diff --git a/collie/work.c b/collie/work.c
index 6aeded9..6f4cd2e 100644
--- a/collie/work.c
+++ b/collie/work.c
@@ -68,12 +68,12 @@ struct worker_info {
 	pthread_t worker_thread[0];
 };
 
-void work_queue_set_blocked(struct work_queue *q)
+static void work_queue_set_blocked(struct work_queue *q)
 {
 	q->wq_state |= WQ_BLOCKED;
 }
 
-void work_queue_clear_blocked(struct work_queue *q)
+static void work_queue_clear_blocked(struct work_queue *q)
 {
 	q->wq_state &= ~WQ_BLOCKED;
 }
diff --git a/shepherd/shepherd.c b/shepherd/shepherd.c
index e16a952..7c45e44 100644
--- a/shepherd/shepherd.c
+++ b/shepherd/shepherd.c
@@ -37,17 +37,17 @@ static int sdport = SD_LISTEN_PORT;
 
 static struct option const long_options[] =
 {
-	{"port", required_argument, 0, 'p'},
-	{"copies", required_argument, 0, 'c'},
-	{"epoch", required_argument, 0, 'e'},
-	{"index", required_argument, 0, 'i'},
-	{"format", required_argument, 0, 'f'},
-	{"type", required_argument, 0, 't'},
-	{"highlight", required_argument, 0, 'H'},
-	{"resident", required_argument, 0, 'R'},
-	{"op", required_argument, 0, 'o'},
-	{"help", no_argument, 0, 'h'},
-	{0, 0, 0, 0},
+	{"port", required_argument, NULL, 'p'},
+	{"copies", required_argument, NULL, 'c'},
+	{"epoch", required_argument, NULL, 'e'},
+	{"index", required_argument, NULL, 'i'},
+	{"format", required_argument, NULL, 'f'},
+	{"type", required_argument, NULL, 't'},
+	{"highlight", required_argument, NULL, 'H'},
+	{"resident", required_argument, NULL, 'R'},
+	{"op", required_argument, NULL, 'o'},
+	{"help", no_argument, NULL, 'h'},
+	{NULL, 0, NULL, 0},
 };
 
 static char *short_options = "p:f:rR:t:H:o:i:e:h";
@@ -483,7 +483,7 @@ typedef void (*vdi_parser_func_t)(uint64_t oid, char *name, uint32_t tag, uint32
 
 
 
-int parse_vdi(vdi_parser_func_t func, void *data)
+static int parse_vdi(vdi_parser_func_t func, void *data)
 {
 	int ret, fd;
 	unsigned long nr;
@@ -587,7 +587,7 @@ static int graphview_vdi(char *vdiname, int highlight)
 	i.root = -1;
 
 	/* print a header */
-	printf("digraph G \{\n");
+	printf("digraph G {\n");
 
 	parse_vdi(print_graph_tree, &i);
 
@@ -927,7 +927,7 @@ static void print_obj(char *vdiname, unsigned index)
 	}
 }
 
-int info(enum info_type type, enum format_type format, char *name,
+static int info(enum info_type type, enum format_type format, char *name,
 	 int highlight, int real_time, unsigned index)
 {
 	int i, ret = -1;
diff --git a/shepherd/treeview.c b/shepherd/treeview.c
index f9e4389..4762b3e 100644
--- a/shepherd/treeview.c
+++ b/shepherd/treeview.c
@@ -15,6 +15,7 @@
 #include <term.h>
 
 #include "list.h"
+#include "treeview.h"
 
 #ifndef MAX_DEPTH
 #define MAX_DEPTH    100
@@ -34,7 +35,7 @@ static int *width, *more;
 static struct vdi_tree *root;
 
 static struct vdi_tree *find_vdi(struct vdi_tree *parent, uint64_t oid,
-				 char *name)
+				 const char *name)
 {
 	struct vdi_tree *vdi, *ret;
 
@@ -49,8 +50,8 @@ static struct vdi_tree *find_vdi(struct vdi_tree *parent, uint64_t oid,
 	return NULL;
 }
 
-static struct vdi_tree *new_vdi(char *name, char *label, uint64_t oid,
-			   uint64_t poid, int highlight)
+static struct vdi_tree *new_vdi(const char *name, const char *label,
+		uint64_t oid, uint64_t poid, int highlight)
 {
 	struct vdi_tree *vdi;
 
@@ -73,8 +74,8 @@ void init_tree(void)
 	root = new_vdi("", "", 0, 0, 0);
 }
 
-void add_vdi_tree(char *name, char *label, uint64_t oid, uint64_t poid,
-		  int highlight)
+void add_vdi_tree(const char *name, const char *label, uint64_t oid,
+		uint64_t poid, int highlight)
 {
 	struct vdi_tree *vdi, *parent;
 
-- 
1.7.0




More information about the sheepdog mailing list