[sheepdog] [PATCH 1/2] sheep: clean up #include headers

Liu Yuan namei.unix at gmail.com
Fri Jul 5 05:30:00 CEST 2013


Current #include are messy duplicating #include everythere, since sheep_priv.h
already have most of system #include, it is convenient to have most common
system includes in it. Then source files in sheep/ will mostly need only
include sheep_priv.h.

Rare header files like <fcgiapp.h> aren't included in sheep_priv.h.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/config.c            |    6 ------
 sheep/gateway.c           |    4 ----
 sheep/group.c             |   20 +-------------------
 sheep/http.c              |    4 ----
 sheep/journal.c           |    8 --------
 sheep/md.c                |   15 ---------------
 sheep/migrate.c           |    8 --------
 sheep/object_cache.c      |   16 ----------------
 sheep/object_list_cache.c |    8 --------
 sheep/ops.c               |   15 ---------------
 sheep/plain_store.c       |    9 +--------
 sheep/recovery.c          |    6 ------
 sheep/request.c           |   12 +-----------
 sheep/sheep.c             |   17 -----------------
 sheep/sheep_priv.h        |   16 ++++++++++++++++
 sheep/sockfd_cache.c      |    9 ---------
 sheep/store.c             |   16 ----------------
 sheep/trace/graph.c       |    5 -----
 sheep/trace/stabs.c       |    2 --
 sheep/trace/trace.c       |   10 ----------
 sheep/trace/trace.h       |    7 +------
 sheep/vdi.c               |    5 -----
 22 files changed, 20 insertions(+), 198 deletions(-)

diff --git a/sheep/config.c b/sheep/config.c
index da0cd33..787dee1 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -9,12 +9,6 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
 #include "sheep_priv.h"
 
 #define SD_FORMAT_VERSION 0x0002
diff --git a/sheep/gateway.c b/sheep/gateway.c
index 2496709..ad5850c 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -9,10 +9,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <poll.h>
 
 #include "sheep_priv.h"
 
diff --git a/sheep/group.c b/sheep/group.c
index 83c3445..6e01a8d 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -8,26 +8,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <sys/time.h>
-#include <sys/epoll.h>
-#include <sys/eventfd.h>
-#include <pthread.h>
-#include <urcu/uatomic.h>
-#include <math.h>
-#include <time.h>
-
-#include "sheepdog_proto.h"
+
 #include "sheep_priv.h"
-#include "list.h"
-#include "util.h"
-#include "logger.h"
-#include "work.h"
-#include "cluster.h"
 
 struct node {
 	struct sd_node ent;
diff --git a/sheep/http.c b/sheep/http.c
index 30d4c59..204ee20 100644
--- a/sheep/http.c
+++ b/sheep/http.c
@@ -13,12 +13,8 @@
 
 /* This files implement RESTful interface to sheepdog storage via fastcgi */
 
-#include <string.h>
 #include <fcgiapp.h>
-#include <errno.h>
-#include <pthread.h>
 
-#include "util.h"
 #include "sheep_priv.h"
 
 struct http_request {
diff --git a/sheep/journal.c b/sheep/journal.c
index 8380849..3726278 100644
--- a/sheep/journal.c
+++ b/sheep/journal.c
@@ -10,14 +10,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <stdint.h>
-#include <sys/mman.h>
 
 #include "sheep_priv.h"
 
diff --git a/sheep/md.c b/sheep/md.c
index c8a3448..5ee3339 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -10,23 +10,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <linux/limits.h>
-#include <sys/types.h>
-#include <sys/statvfs.h>
-#include <sys/stat.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <errno.h>
-#include <math.h>
-#include <sys/xattr.h>
-#include <dirent.h>
-#include <pthread.h>
-#include <string.h>
-#include <fcntl.h>
 
 #include "sheep_priv.h"
-#include "util.h"
-#include "strbuf.h"
 
 #define MD_DEFAULT_VDISKS 128
 #define MD_MAX_VDISK (MD_MAX_DISK * MD_DEFAULT_VDISKS)
diff --git a/sheep/migrate.c b/sheep/migrate.c
index 33cb2cf..b35548c 100644
--- a/sheep/migrate.c
+++ b/sheep/migrate.c
@@ -9,14 +9,6 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <time.h>
-#include <dirent.h>
-
 #include "sheep_priv.h"
 
 /* sheepdog 0.4.0 */
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index aec3a6b..0aaf882 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -11,23 +11,7 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <errno.h>
-#include <sys/file.h>
-#include <dirent.h>
-#include <urcu/uatomic.h>
-#include <sys/eventfd.h>
-
 #include "sheep_priv.h"
-#include "util.h"
-#include "strbuf.h"
-#include "rbtree.h"
 
 /*
  * Object Cache ID
diff --git a/sheep/object_list_cache.c b/sheep/object_list_cache.c
index 7147191..6d5139f 100644
--- a/sheep/object_list_cache.c
+++ b/sheep/object_list_cache.c
@@ -11,15 +11,7 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <pthread.h>
-
 #include "sheep_priv.h"
-#include "strbuf.h"
-#include "util.h"
 
 struct objlist_cache_entry {
 	uint64_t oid;
diff --git a/sheep/ops.c b/sheep/ops.c
index 3d92c52..87f1e5e 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -8,24 +8,9 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdio.h>
-#include <stdlib.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <mntent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/statvfs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pthread.h>
 
 #include "sheep_priv.h"
-#include "strbuf.h"
 #include "trace/trace.h"
-#include "util.h"
 
 enum sd_op_type {
 	SD_OP_TYPE_CLUSTER = 1, /* cluster operations */
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 65c82d8..4854be8 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -8,17 +8,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/xattr.h>
-#include <unistd.h>
+
 #include <libgen.h>
 
 #include "sheep_priv.h"
-#include "config.h"
-#include "sha1.h"
 
 #define sector_algined(x) ({ ((x) & (SECTOR_SIZE - 1)) == 0; })
 
diff --git a/sheep/recovery.c b/sheep/recovery.c
index f751bfd..df785ee 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -8,14 +8,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
 
 #include "sheep_priv.h"
-#include "sha1.h"
 
 enum rw_state {
 	RW_PREPARE_LIST, /* the recovery thread is preparing object list */
diff --git a/sheep/request.c b/sheep/request.c
index a6000d3..c0ed943 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -8,20 +8,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <pthread.h>
-#include <sys/eventfd.h>
-#include <arpa/inet.h>
+
 #include <netinet/tcp.h>
-#include <sys/epoll.h>
-#include <fcntl.h>
-#include <errno.h>
 
 #include "sheep_priv.h"
-#include "util.h"
 
 static void requeue_request(struct request *req);
 
diff --git a/sheep/sheep.c b/sheep/sheep.c
index ecd61e1..441aa9a 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -9,29 +9,12 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "../include/config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <signal.h>
-#include <linux/limits.h>
-#include <sys/syslog.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/signalfd.h>
-#include <pthread.h>
-#include <sys/eventfd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <arpa/inet.h>
 #include <sys/resource.h>
 #include <malloc.h>
 
 #include "sheep_priv.h"
 #include "trace/trace.h"
-#include "util.h"
 #include "option.h"
 
 #define EPOLL_SIZE 4096
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index c406534..382d246 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -15,6 +15,21 @@
 #include <stdbool.h>
 #include <urcu/uatomic.h>
 #include <time.h>
+#include <pthread.h>
+#include <math.h>
+#include <errno.h>
+#include <poll.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/xattr.h>
+#include <dirent.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/eventfd.h>
+#include <sys/time.h>
+#include <sys/epoll.h>
+#include <signal.h>
 
 #include "sheepdog_proto.h"
 #include "event.h"
@@ -25,6 +40,7 @@
 #include "cluster.h"
 #include "rbtree.h"
 #include "strbuf.h"
+#include "sha1.h"
 #include "config.h"
 
 struct client_info {
diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
index 82ce0aa..55c337c 100644
--- a/sheep/sockfd_cache.c
+++ b/sheep/sockfd_cache.c
@@ -26,17 +26,8 @@
  *    6 total 3 APIs: sheep_{get,put,del}_sockfd().
  *    7 support dual connections to a single node.
  */
-#include <urcu/uatomic.h>
-#include <pthread.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
 
 #include "sheep_priv.h"
-#include "list.h"
-#include "rbtree.h"
-#include "logger.h"
-#include "util.h"
 
 struct sockfd_cache {
 	struct rb_root root;
diff --git a/sheep/store.c b/sheep/store.c
index bc9531b..d07a100 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -8,24 +8,8 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <mntent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/vfs.h>
-#include <sys/statvfs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <pthread.h>
 
 #include "sheep_priv.h"
-#include "strbuf.h"
-#include "util.h"
 
 char *obj_path;
 char *epoch_path;
diff --git a/sheep/trace/graph.c b/sheep/trace/graph.c
index c9c58a8..ce2ff7a 100644
--- a/sheep/trace/graph.c
+++ b/sheep/trace/graph.c
@@ -11,12 +11,7 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <time.h>
-#include <sched.h>
-
 #include "trace.h"
-#include "logger.h"
-#include "util.h"
 
 static __thread int ret_stack_index;
 static __thread struct trace_ret_stack {
diff --git a/sheep/trace/stabs.c b/sheep/trace/stabs.c
index 4aa8a70..eeae153 100644
--- a/sheep/trace/stabs.c
+++ b/sheep/trace/stabs.c
@@ -12,8 +12,6 @@
  */
 
 #include <stab.h>
-#include <stdint.h>
-#include <string.h>
 
 #include "trace.h"
 
diff --git a/sheep/trace/trace.c b/sheep/trace/trace.c
index dc0af97..e166f96 100644
--- a/sheep/trace/trace.c
+++ b/sheep/trace/trace.c
@@ -11,17 +11,7 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <string.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <signal.h>
-
 #include "trace.h"
-#include "logger.h"
-#include "list.h"
-#include "sheepdog_proto.h"
-#include "strbuf.h"
 
 #define TRACE_HASH_BITS       7
 #define TRACE_HASH_SIZE       (1 << TRACE_HASH_BITS)
diff --git a/sheep/trace/trace.h b/sheep/trace/trace.h
index 8437140..92f5166 100644
--- a/sheep/trace/trace.h
+++ b/sheep/trace/trace.h
@@ -4,13 +4,8 @@
 #define INSN_SIZE       5       /* call(1b) + offset(4b) = 5b */
 
 #ifndef __ASSEMBLY__
-#include <stdlib.h>
 
-#include "sheepdog_proto.h"
-#include "sheep.h"
-#include "list.h"
-#include "util.h"
-#include "config.h"
+#include "sheep_priv.h"
 
 struct ipinfo {
 	const char *file;           /* Source code filename for EIP */
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 41e451e..944e1f7 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -8,12 +8,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <sys/time.h>
 
-#include "sheepdog_proto.h"
 #include "sheep_priv.h"
 
 struct vdi_state_entry {
-- 
1.7.9.5




More information about the sheepdog mailing list