From: Ian Jackson Date: Mon, 16 May 2011 10:13:59 +0000 (+0100) Subject: cleanup: move declarations of external objects into header files X-Git-Tag: v0.2.0~90 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=commitdiff_plain;h=08ee90a207d1a9c0b3e34d1db06cd7502ad48990;ds=sidebyside cleanup: move declarations of external objects into header files 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 --- diff --git a/conffile.c b/conffile.c index 660606e..9023529 100644 --- a/conffile.c +++ b/conffile.c @@ -10,9 +10,6 @@ #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 { @@ -568,7 +565,7 @@ uint32_t list_length(list_t *a) return l; } -list_t *list_copy(list_t *a) +static list_t *list_copy(list_t *a) { list_t *r, *i, *b, *l; diff --git a/log.c b/log.c index 32aed70..16ed60a 100644 --- a/log.c +++ b/log.c @@ -8,6 +8,7 @@ #include #include #include "process.h" +#include "util.h" bool_t secnet_is_daemon=False; uint32_t message_level=M_WARNING|M_ERR|M_SECURITY|M_FATAL; diff --git a/modules.c b/modules.c index 8658106..9b94e25 100644 --- a/modules.c +++ b/modules.c @@ -1,20 +1,5 @@ #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); diff --git a/secnet.h b/secnet.h index c3cadb9..656c86d 100644 --- 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) +/* 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 @@ -198,6 +206,23 @@ extern cstring_t require_root_privileges_explanation; 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 *****/