[sheepdog] [PATCH] sheep: fix missing extern keyward for global variables

Liu Yuan namei.unix at gmail.com
Thu Jan 24 08:40:05 CET 2013


From: Liu Yuan <tailai.ly at taobao.com>

This mistabke is introduced by the commit 27ca5b65.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 collie/collie.h     |   26 +++++++++++++-------------
 sheep/cluster.h     |    2 +-
 sheep/farm/farm.h   |    5 +++--
 sheep/sheep_priv.h  |   16 ++++++++--------
 sheep/trace/stabs.c |    8 ++++----
 sheepfs/sheepfs.h   |    6 +++---
 6 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/collie/collie.h b/collie/collie.h
index 7269f8e..7e9b6be 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -48,16 +48,16 @@ struct subcommand {
 };
 void subcommand_usage(char *cmd, char *subcmd, int status);
 
-const char *sdhost;
-int sdport;
-bool highlight;
-bool raw_output;
+extern const char *sdhost;
+extern int sdport;
+extern bool highlight;
+extern bool raw_output;
 
-uint32_t sd_epoch;
-struct sd_node sd_nodes[SD_MAX_NODES];
-struct sd_vnode sd_vnodes[SD_MAX_VNODES];
-int sd_nodes_nr, sd_vnodes_nr;
-unsigned master_idx;
+extern uint32_t sd_epoch;
+extern struct sd_node sd_nodes[SD_MAX_NODES];
+extern struct sd_vnode sd_vnodes[SD_MAX_VNODES];
+extern int sd_nodes_nr, sd_vnodes_nr;
+extern unsigned master_idx;
 
 bool is_current(const struct sheepdog_inode *i);
 char *size_to_str(uint64_t _size, char *str, int str_size);
@@ -75,12 +75,12 @@ int send_light_req(struct sd_req *hdr, const char *host, int port);
 int send_light_req_get_response(struct sd_req *hdr, const char *host, int port);
 int collie_exec_req(int sockfd, struct sd_req *hdr, void *data);
 
-struct command vdi_command;
-struct command node_command;
-struct command cluster_command;
+extern struct command vdi_command;
+extern struct command node_command;
+extern struct command cluster_command;
 
 #ifdef ENABLE_TRACE
-  struct command debug_command;
+  extern struct command debug_command;
 #else
   #define debug_command {}
 #endif /* ENABLE_TRACE */
diff --git a/sheep/cluster.h b/sheep/cluster.h
index c796d51..d078f48 100644
--- a/sheep/cluster.h
+++ b/sheep/cluster.h
@@ -114,7 +114,7 @@ struct cluster_driver {
 	struct list_head list;
 };
 
-struct list_head cluster_drivers;
+extern struct list_head cluster_drivers;
 
 #define cdrv_register(driver)						\
 static void __attribute__((constructor)) regist_ ## driver(void) {	\
diff --git a/sheep/farm/farm.h b/sheep/farm/farm.h
index 6190644..0fbdf12 100644
--- a/sheep/farm/farm.h
+++ b/sheep/farm/farm.h
@@ -40,8 +40,9 @@ struct trunk_entry {
 };
 
 /* farm.c */
-char farm_dir[PATH_MAX];
-char farm_obj_dir[PATH_MAX];
+extern char farm_dir[PATH_MAX];
+extern char farm_obj_dir[PATH_MAX];
+
 /* sha1_file.c */
 char *sha1_to_path(const unsigned char *sha1);
 int sha1_file_write(unsigned char *buf, unsigned len, unsigned char *);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 76b0abc..b19ca03 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -203,13 +203,13 @@ static inline struct store_driver *find_store_driver(const char *name)
 	return NULL;
 }
 
-struct cluster_info *sys;
-struct store_driver *sd_store;
-char *obj_path;
-char *jrnl_path;
-char *epoch_path;
-mode_t def_fmode;
-mode_t def_dmode;
+extern struct cluster_info *sys;
+extern struct store_driver *sd_store;
+extern char *obj_path;
+extern char *jrnl_path;
+extern char *epoch_path;
+extern mode_t def_fmode;
+extern mode_t def_dmode;
 
 /* One should call this function to get sys->epoch outside main thread */
 static inline uint32_t sys_epoch(void)
@@ -275,7 +275,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);
 
-char *config_path;
+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/stabs.c b/sheep/trace/stabs.c
index 8e9d30e..4aa8a70 100644
--- a/sheep/trace/stabs.c
+++ b/sheep/trace/stabs.c
@@ -28,10 +28,10 @@ struct stab {
 	uint32_t value;		/* value of symbol */
 };
 
-const struct stab __STAB_BEGIN__[];
-const struct stab __STAB_END__[];
-const char __STABSTR_BEGIN__[];
-const char __STABSTR_END__[];
+extern const struct stab __STAB_BEGIN__[];
+extern const struct stab __STAB_END__[];
+extern const char __STABSTR_BEGIN__[];
+extern const char __STABSTR_END__[];
 
 /*
    stab_bsearch(stabs, region_left, region_right, type, addr)
diff --git a/sheepfs/sheepfs.h b/sheepfs/sheepfs.h
index fa641a5..d1ca83e 100644
--- a/sheepfs/sheepfs.h
+++ b/sheepfs/sheepfs.h
@@ -20,10 +20,10 @@ enum sheepfs_opcode {
 #define COMMAND_LEN  512
 
 extern char sheepfs_shadow[];
-int sheepfs_page_cache;
-int sheepfs_object_cache;
+extern int sheepfs_page_cache;
+extern int sheepfs_object_cache;
 extern char sdhost[];
-int sdport;
+extern int sdport;
 
 struct strbuf *sheepfs_run_cmd(const char *command);
 int sheepfs_set_op(const char *path, unsigned opcode);
-- 
1.7.9.5




More information about the sheepdog mailing list