commit 6c440da9260b6f8fffca7cb95ed6e51f55c71b14 Author: Nick Mathewson nickm@torproject.org Date: Sun Jul 1 15:02:01 2018 -0400
Remove system headers from or.h --- src/or/config.c | 9 +++++++++ src/or/connection.c | 7 +++++++ src/or/control.c | 7 +++++++ src/or/dns.c | 4 ++++ src/or/hibernate.c | 4 ++++ src/or/hs_service.c | 7 +++++++ src/or/main.c | 4 ++++ src/or/microdesc.c | 4 ++++ src/or/networkstatus.c | 4 ++++ src/or/or.h | 43 +------------------------------------------ src/or/rendservice.c | 10 ++++++++++ src/or/rephist.c | 4 ++++ src/or/routerkeys.c | 4 ++++ src/or/routerlist.c | 4 ++++ src/or/routerparse.c | 3 +++ src/or/scheduler_kist.c | 4 ++++ src/or/statefile.c | 4 ++++ src/test/test_addr.c | 5 ++++- src/test/test_bt_cl.c | 5 ++++- src/test/test_checkdir.c | 5 ++++- src/test/test_config.c | 7 +++++++ src/test/test_crypto.c | 7 +++++++ src/test/test_dir.c | 4 ++++ src/test/test_extorport.c | 5 ++++- src/test/test_hs.c | 4 ++++ src/test/test_logging.c | 4 ++++ src/test/test_microdesc.c | 5 ++++- src/test/test_routerkeys.c | 7 +++++++ src/test/test_shared_random.c | 4 ++++ src/test/test_switch_id.c | 3 +++ src/test/test_util.c | 10 ++++++++++ src/test/testing_common.c | 6 ++++++ 32 files changed, 160 insertions(+), 47 deletions(-)
diff --git a/src/or/config.c b/src/or/config.c index 0507c4312..a29958c57 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -110,6 +110,15 @@ #ifdef _WIN32 #include <shlobj.h> #endif +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif
#include "lib/meminfo/meminfo.h" #include "lib/osinfo/uname.h" diff --git a/src/or/connection.c b/src/or/connection.c index e42288579..66ccc51b5 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -112,6 +112,13 @@ #include <pwd.h> #endif
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + #ifdef HAVE_SYS_UN_H #include <sys/socket.h> #include <sys/un.h> diff --git a/src/or/control.c b/src/or/control.c index 35e8cacd8..67d1a0c68 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -100,6 +100,13 @@ #include "or/routerlist_st.h" #include "or/socks_request_st.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + #ifndef _WIN32 #include <pwd.h> #include <sys/resource.h> diff --git a/src/or/dns.c b/src/or/dns.c index 08a55170e..45c4384eb 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -69,6 +69,10 @@ #include "or/edge_connection_st.h" #include "or/or_circuit_st.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + #include <event2/event.h> #include <event2/dns.h>
diff --git a/src/or/hibernate.c b/src/or/hibernate.c index f98ada02d..c44e974fc 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -46,6 +46,10 @@ hibernating, phase 2: #include "or/or_connection_st.h" #include "or/or_state_st.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /** Are we currently awake, asleep, running out of bandwidth, or shutting * down? */ static hibernate_state_t hibernate_state = HIBERNATE_STATE_INITIAL; diff --git a/src/or/hs_service.c b/src/or/hs_service.c index b651f1e27..6cb01b57c 100644 --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@ -56,6 +56,13 @@ #include "trunnel/hs/cell_common.h" #include "trunnel/hs/cell_establish_intro.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /* Helper macro. Iterate over every service in the global map. The var is the * name of the service pointer. */ #define FOR_EACH_SERVICE_BEGIN(var) \ diff --git a/src/or/main.c b/src/or/main.c index 9851cdb57..b48c0b813 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -136,6 +136,10 @@ #include "or/routerinfo_st.h" #include "or/socks_request_st.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + #ifdef HAVE_SYSTEMD # if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) /* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 838c966a2..a0ee4ba5f 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -30,6 +30,10 @@ #include "or/node_st.h" #include "or/routerstatus_st.h"
+#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + /** A data structure to hold a bunch of cached microdescriptors. There are * two active files in the cache: a "cache file" that we mmap, and a "journal * file" that we append to. Periodically, we rebuild the cache file to hold diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 133ab84b3..f91e46cdd 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -88,6 +88,10 @@ #include "or/vote_microdesc_hash_st.h" #include "or/vote_routerstatus_st.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /** Most recently received and validated v3 "ns"-flavored consensus network * status. */ STATIC networkstatus_t *current_ns_consensus = NULL; diff --git a/src/or/or.h b/src/or/or.h index 4ed774389..b0340ed1a 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -13,56 +13,15 @@ #define TOR_OR_H
#include "orconfig.h" +#include "lib/cc/torint.h"
-#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif #ifdef HAVE_SIGNAL_H #include <signal.h> #endif -#ifdef HAVE_NETDB_H -#include <netdb.h> -#endif -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> /* FreeBSD needs this to know what version it is */ -#endif -#include "lib/cc/torint.h" -#ifdef HAVE_SYS_FCNTL_H -#include <sys/fcntl.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#ifdef HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif -#ifdef HAVE_SYS_UN_H -#include <sys/un.h> -#endif -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#ifdef HAVE_ERRNO_H -#include <errno.h> -#endif #ifdef HAVE_TIME_H #include <time.h> #endif
-#ifdef _WIN32 -#include <winsock2.h> -#include <io.h> -#include <process.h> -#include <direct.h> -#include <windows.h> -#endif /* defined(_WIN32) */ - #include "common/util.h"
#include "lib/container/map.h" diff --git a/src/or/rendservice.c b/src/or/rendservice.c index 6d0861647..8e094b593 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -51,6 +51,16 @@ #include "or/rend_service_descriptor_st.h" #include "or/routerstatus_st.h"
+#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + struct rend_service_t; static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro, const char *pk_digest); diff --git a/src/or/rephist.c b/src/or/rephist.c index 02dc86403..a74a952ce 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -98,6 +98,10 @@ #include "lib/math/fp.h" #include "lib/math/laplace.h"
+#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + static void bw_arrays_init(void); static void predicted_ports_alloc(void);
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c index b92ec76aa..bb04a8b22 100644 --- a/src/or/routerkeys.c +++ b/src/or/routerkeys.c @@ -29,6 +29,10 @@ #define ENC_KEY_HEADER "Boxed Ed25519 key" #define ENC_KEY_TAG "master"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /* DOCDOC */ static ssize_t do_getpass(const char *prompt, char *buf, size_t buflen, diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 189ea8acd..164b0bf86 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -141,6 +141,10 @@
#include "lib/crypt_ops/digestset.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + // #define DEBUG_ROUTERLIST
/****************************************************************************/ diff --git a/src/or/routerparse.c b/src/or/routerparse.c index f07080a4d..29eb48321 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -104,6 +104,9 @@
#undef log #include <math.h> +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif
/****************************************************************************/
diff --git a/src/or/scheduler_kist.c b/src/or/scheduler_kist.c index 3059952b9..5a45ccab8 100644 --- a/src/or/scheduler_kist.c +++ b/src/or/scheduler_kist.c @@ -19,6 +19,10 @@
#define TLS_PER_CELL_OVERHEAD 29
+#ifdef HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif + #ifdef HAVE_KIST_SUPPORT /* Kernel interface needed for KIST. */ #include <netinet/tcp.h> diff --git a/src/or/statefile.c b/src/or/statefile.c index 5631001c0..e9db1ff06 100644 --- a/src/or/statefile.c +++ b/src/or/statefile.c @@ -46,6 +46,10 @@
#include "or/or_state_st.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /** A list of state-file "abbreviations," for compatibility. */ static config_abbrev_t state_abbrevs_[] = { { "AccountingBytesReadInterval", "AccountingBytesReadInInterval", 0, 0 }, diff --git a/src/test/test_addr.c b/src/test/test_addr.c index 0a3212adb..1069e25b4 100644 --- a/src/test/test_addr.c +++ b/src/test/test_addr.c @@ -11,6 +11,10 @@ #include "or/addressmap.h" #include "test/log_test_helpers.h"
+#ifdef HAVE_SYS_UN_H +#include <sys/un.h> +#endif + /** Mocking replacement: only handles localhost. */ static int mock_tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr_out) @@ -1257,4 +1261,3 @@ struct testcase_t addr_tests[] = { { "make_null", test_addr_make_null, 0, NULL, NULL }, END_OF_TESTCASES }; - diff --git a/src/test/test_bt_cl.c b/src/test/test_bt_cl.c index c64ca8e2b..8a8221f19 100644 --- a/src/test/test_bt_cl.c +++ b/src/test/test_bt_cl.c @@ -12,6 +12,10 @@ #include "lib/err/backtrace.h" #include "lib/log/torlog.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /* -1: no crash. * 0: crash with a segmentation fault. * 1x: crash with an assertion failure. */ @@ -118,4 +122,3 @@ main(int argc, char **argv)
return 0; } - diff --git a/src/test/test_checkdir.c b/src/test/test_checkdir.c index d0c899a07..09688cf0a 100644 --- a/src/test/test_checkdir.c +++ b/src/test/test_checkdir.c @@ -14,6 +14,10 @@ #include "test/test.h" #include "common/util.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + #ifdef _WIN32 #define mkdir(a,b) mkdir(a) #define tt_int_op_nowin(a,op,b) do { (void)(a); (void)(b); } while (0) @@ -146,4 +150,3 @@ struct testcase_t checkdir_tests[] = { CHECKDIR(perms, TT_FORK), END_OF_TESTCASES }; - diff --git a/src/test/test_config.c b/src/test/test_config.c index d84cac4e9..25199454e 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -53,6 +53,13 @@ #include "lib/net/gethostname.h" #include "lib/encoding/confline.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + static void test_config_addressmap(void *arg) { diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c index e342c933b..194c54e85 100644 --- a/src/test/test_crypto.c +++ b/src/test/test_crypto.c @@ -19,6 +19,13 @@ #include "lib/crypt_ops/crypto_rand.h" #include "ed25519_vectors.inc"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /** Run unit tests for Diffie-Hellman functionality. */ static void test_crypto_dh(void *arg) diff --git a/src/test/test_dir.c b/src/test/test_dir.c index a2b4ec68a..5adfb9570 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -63,6 +63,10 @@ #include "or/vote_microdesc_hash_st.h" #include "or/vote_routerstatus_st.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + #define NS_MODULE dir
static void diff --git a/src/test/test_extorport.c b/src/test/test_extorport.c index 0032ef5b7..4ddef4e43 100644 --- a/src/test/test_extorport.c +++ b/src/test/test_extorport.c @@ -18,6 +18,10 @@
#include "test/test.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + /* Test connection_or_remove_from_ext_or_id_map and * connection_or_set_ext_or_identifier */ static void @@ -610,4 +614,3 @@ struct testcase_t extorport_tests[] = { { "handshake", test_ext_or_handshake, TT_FORK, NULL, NULL }, END_OF_TESTCASES }; - diff --git a/src/test/test_hs.c b/src/test/test_hs.c index 2a6cd2827..b17e8cf21 100644 --- a/src/test/test_hs.c +++ b/src/test/test_hs.c @@ -30,6 +30,10 @@
#include "test/test_helpers.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /* mock ID digest and longname for node that's in nodelist */ #define HSDIR_EXIST_ID "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" \ "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" diff --git a/src/test/test_logging.c b/src/test/test_logging.c index d97941146..48cdf2e6b 100644 --- a/src/test/test_logging.c +++ b/src/test/test_logging.c @@ -11,6 +11,10 @@ #include "test/test.h" #include "lib/process/subprocess.h"
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + static void dummy_cb_fn(int severity, uint32_t domain, const char *msg) { diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 1b680c02c..2038f5498 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -20,6 +20,10 @@
#include "test/test.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + #ifdef _WIN32 /* For mkdir() */ #include <direct.h> @@ -815,4 +819,3 @@ struct testcase_t microdesc_tests[] = { { "corrupt_desc", test_md_corrupt_desc, TT_FORK, NULL, NULL }, END_OF_TESTCASES }; - diff --git a/src/test/test_routerkeys.c b/src/test/test_routerkeys.c index 3fc381cd2..8c2be30a8 100644 --- a/src/test/test_routerkeys.c +++ b/src/test/test_routerkeys.c @@ -20,6 +20,13 @@ #include <direct.h> #endif
+#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + static void test_routerkeys_write_fingerprint(void *arg) { diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index 293ed6cf3..1b4fdc899 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -26,6 +26,10 @@ #include "or/networkstatus_st.h" #include "or/or_state_st.h"
+#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + static authority_cert_t *mock_cert;
static authority_cert_t * diff --git a/src/test/test_switch_id.c b/src/test/test_switch_id.c index 11fe53b7c..95801822f 100644 --- a/src/test/test_switch_id.c +++ b/src/test/test_switch_id.c @@ -7,6 +7,9 @@ #ifdef HAVE_SYS_CAPABILITY_H #include <sys/capability.h> #endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif
#define TEST_BUILT_WITH_CAPS 0 #define TEST_HAVE_CAPS 1 diff --git a/src/test/test_util.c b/src/test/test_util.c index ab0573e56..3c0b4f77f 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -48,6 +48,16 @@ #ifdef HAVE_UTIME_H #include <utime.h> #endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + #ifdef _WIN32 #include <tchar.h> #endif diff --git a/src/test/testing_common.c b/src/test/testing_common.c index 0b7a3287a..ace564d0f 100644 --- a/src/test/testing_common.c +++ b/src/test/testing_common.c @@ -28,6 +28,12 @@ #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif
#ifdef _WIN32 /* For mkdir() */
tor-commits@lists.torproject.org