chiark / gitweb /
cleanup: move declarations of external objects into header files
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 May 2011 10:13:59 +0000 (11:13 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jun 2011 15:34:21 +0000 (16:34 +0100)
It is not a good idea to declare external objects in .c files.  Every
external object (ie, object with external linkage) should be declared
exactly once in a .h file, and every .c file that refers to it or
defines it should #include that header.

When combined with appropriate compiler warnings, this ensures that
every file sees the same signature for every such object.  (At least
for functions.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
conffile.c
log.c
modules.c
secnet.h

index 660606eabcab3edf69b166e8b1a59c39485120a3..90235290fb03a72b436524892c28240fa2f82186 100644 (file)
@@ -10,9 +10,6 @@
 #include "util.h"
 #include "ipaddr.h"
 
 #include "util.h"
 #include "ipaddr.h"
 
-/* from modules.c */
-extern void init_builtin_modules(dict_t *dict);
-
 static struct cloc no_loc={"none",0};
 
 struct atomlist {
 static struct cloc no_loc={"none",0};
 
 struct atomlist {
@@ -568,7 +565,7 @@ uint32_t list_length(list_t *a)
     return l;
 }
 
     return l;
 }
 
-list_t *list_copy(list_t *a)
+static list_t *list_copy(list_t *a)
 {
     list_t *r, *i, *b, *l;
 
 {
     list_t *r, *i, *b, *l;
 
diff --git a/log.c b/log.c
index 32aed704b06e20e595ef366661426103fac6342f..16ed60a1cb24a074fa11c1c05905a8e3125132d9 100644 (file)
--- a/log.c
+++ b/log.c
@@ -8,6 +8,7 @@
 #include <assert.h>
 #include <unistd.h>
 #include "process.h"
 #include <assert.h>
 #include <unistd.h>
 #include "process.h"
+#include "util.h"
 
 bool_t secnet_is_daemon=False;
 uint32_t message_level=M_WARNING|M_ERR|M_SECURITY|M_FATAL;
 
 bool_t secnet_is_daemon=False;
 uint32_t message_level=M_WARNING|M_ERR|M_SECURITY|M_FATAL;
index 8658106c2691575136ae108ff4906d4a48834795..9b94e2573cb420df5a3148ce77267a5dce3e2b16 100644 (file)
--- a/modules.c
+++ b/modules.c
@@ -1,20 +1,5 @@
 #include "secnet.h"
 
 #include "secnet.h"
 
-extern init_module resolver_module;
-extern init_module random_module;
-extern init_module udp_module;
-extern init_module util_module;
-extern init_module site_module;
-extern init_module transform_module;
-extern init_module netlink_module;
-extern init_module rsa_module;
-extern init_module dh_module;
-extern init_module md5_module;
-extern init_module slip_module;
-extern init_module tun_module;
-extern init_module sha1_module;
-extern init_module log_module;
-
 void init_builtin_modules(dict_t *dict)
 {
     resolver_module(dict);
 void init_builtin_modules(dict_t *dict)
 {
     resolver_module(dict);
index c3cadb9737a0feb03301017c6a04dd0afd4e6e21..656c86d262a54e0910ca5dc580becf720236270c 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -34,6 +34,14 @@ typedef enum {False,True} bool_t;
 #define ASSERT(x) do { if (!(x)) { fatal("assertion failed line %d file " \
                                         __FILE__,__LINE__); } } while(0)
 
 #define ASSERT(x) do { if (!(x)) { fatal("assertion failed line %d file " \
                                         __FILE__,__LINE__); } } while(0)
 
+/* from logmsg.c */
+extern uint32_t message_level;
+extern bool_t secnet_is_daemon;
+extern struct log_if *system_log;
+
+/* from process.c */
+extern void start_signal_handling(void);
+
 /***** CONFIGURATION support *****/
 
 extern bool_t just_check_config; /* If True then we're going to exit after
 /***** CONFIGURATION support *****/
 
 extern bool_t just_check_config; /* If True then we're going to exit after
@@ -198,6 +206,23 @@ extern cstring_t require_root_privileges_explanation;
    modules it's called "secnet_module". */
 typedef void init_module(dict_t *dict);
 
    modules it's called "secnet_module". */
 typedef void init_module(dict_t *dict);
 
+extern void init_builtin_modules(dict_t *dict);
+
+extern init_module resolver_module;
+extern init_module random_module;
+extern init_module udp_module;
+extern init_module util_module;
+extern init_module site_module;
+extern init_module transform_module;
+extern init_module netlink_module;
+extern init_module rsa_module;
+extern init_module dh_module;
+extern init_module md5_module;
+extern init_module slip_module;
+extern init_module tun_module;
+extern init_module sha1_module;
+extern init_module log_module;
+
 /***** END of module support *****/
 
 /***** CLOSURE TYPES and interface definitions *****/
 /***** END of module support *****/
 
 /***** CLOSURE TYPES and interface definitions *****/