From 459382986102dd1bd84bca24a0fddfe04efefd76 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 5 Jul 2018 15:04:18 -0400 Subject: [PATCH] Remove util.h Inline its contents (which were all includes) into or.h, and some of its contents into other places that didn't include or.h at all. --- src/common/include.am | 1 - src/common/util.h | 52 ---------------------------------- src/or/config.c | 1 - src/or/dirauth/shared_random.c | 1 - src/or/ext_orport.c | 1 - src/or/hs_cell.c | 1 - src/or/keypin.c | 25 ++++++++++++---- src/or/onion_ntor.c | 11 ++++--- src/or/or.h | 38 +++++++++++++++++++++++-- src/or/shared_random_client.c | 1 - src/or/torcert.c | 1 - src/or/transports.c | 1 - src/test/fuzz/fuzz_hsdescv3.c | 1 - src/test/test-memwipe.c | 9 +++--- src/test/test-timers.c | 7 +++-- src/test/test_bridges.c | 1 - src/test/test_bt_cl.c | 1 - src/test/test_checkdir.c | 1 - src/test/test_config.c | 1 - src/test/test_crypto.c | 1 - src/test/test_crypto_openssl.c | 5 ++-- src/test/test_entrynodes.c | 1 - src/test/test_guardfraction.c | 1 - src/test/test_handles.c | 5 ++-- src/test/test_hs_common.c | 1 - src/test/test_hs_ntor_cl.c | 1 - src/test/test_keypin.c | 1 - src/test/test_ntor_cl.c | 1 - src/test/test_pt.c | 1 - src/test/test_routerkeys.c | 1 - src/test/test_util_slow.c | 8 ++++-- 31 files changed, 83 insertions(+), 99 deletions(-) delete mode 100644 src/common/util.h diff --git a/src/common/include.am b/src/common/include.am index de4ecbaeea..0a58a39ae0 100644 --- a/src/common/include.am +++ b/src/common/include.am @@ -52,7 +52,6 @@ COMMONHEADERS = \ src/common/procmon.h \ src/common/timers.h \ src/common/token_bucket.h \ - src/common/util.h \ src/common/workqueue.h noinst_HEADERS+= $(COMMONHEADERS) diff --git a/src/common/util.h b/src/common/util.h deleted file mode 100644 index 55eec2b8c9..0000000000 --- a/src/common/util.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2003-2004, Roger Dingledine - * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. - * Copyright (c) 2007-2018, The Tor Project, Inc. */ -/* See LICENSE for licensing information */ - -/** - * \file util.h - * \brief Headers for util.c - **/ - -#ifndef TOR_UTIL_H -#define TOR_UTIL_H - -#include "orconfig.h" -#include "lib/arch/bytes.h" -#include "lib/cc/compat_compiler.h" -#include "lib/cc/torint.h" -#include "lib/ctime/di_ops.h" -#include "lib/encoding/cstring.h" -#include "lib/encoding/time_fmt.h" -#include "lib/err/torerr.h" -#include "lib/fs/dir.h" -#include "lib/fs/files.h" -#include "lib/fs/mmap.h" -#include "lib/fs/path.h" -#include "lib/fs/userdb.h" -#include "lib/intmath/addsub.h" -#include "lib/intmath/bits.h" -#include "lib/intmath/cmp.h" -#include "lib/intmath/logic.h" -#include "lib/intmath/muldiv.h" -#include "lib/log/escape.h" -#include "lib/log/ratelim.h" -#include "lib/log/util_bug.h" -#include "lib/malloc/util_malloc.h" -#include "lib/net/ipv4.h" -#include "lib/net/ipv6.h" -#include "lib/net/resolve.h" -#include "lib/net/socket.h" -#include "lib/string/compat_ctype.h" -#include "lib/string/compat_string.h" -#include "lib/string/parse_int.h" -#include "lib/string/printf.h" -#include "lib/string/scanf.h" -#include "lib/string/util_string.h" -#include "lib/testsupport/testsupport.h" -#include "lib/thread/threads.h" -#include "lib/time/compat_time.h" -#include "lib/wallclock/approx_time.h" -#include "lib/wallclock/timeval.h" - -#endif /* !defined(TOR_UTIL_H) */ diff --git a/src/or/config.c b/src/or/config.c index 13002dd963..6dc2ad1d5b 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -99,7 +99,6 @@ #include "or/rephist.h" #include "or/router.h" #include "lib/sandbox/sandbox.h" -#include "common/util.h" #include "or/routerlist.h" #include "or/routerset.h" #include "or/scheduler.h" diff --git a/src/or/dirauth/shared_random.c b/src/or/dirauth/shared_random.c index 8b53c1e743..d122690129 100644 --- a/src/or/dirauth/shared_random.c +++ b/src/or/dirauth/shared_random.c @@ -99,7 +99,6 @@ #include "or/routerlist.h" #include "or/shared_random_client.h" #include "or/dirauth/shared_random_state.h" -#include "common/util.h" #include "or/voting_schedule.h" #include "or/dirauth/dirvote.h" diff --git a/src/or/ext_orport.c b/src/or/ext_orport.c index 701dc45288..7342a66e06 100644 --- a/src/or/ext_orport.c +++ b/src/or/ext_orport.c @@ -27,7 +27,6 @@ #include "or/ext_orport.h" #include "or/main.h" #include "or/proto_ext_or.h" -#include "common/util.h" #include "or/or_connection_st.h" diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c index b50c87dfa3..f8b76c5133 100644 --- a/src/or/hs_cell.c +++ b/src/or/hs_cell.c @@ -11,7 +11,6 @@ #include "lib/crypt_ops/crypto_util.h" #include "or/rendservice.h" #include "or/replaycache.h" -#include "common/util.h" #include "or/hs_cell.h" #include "or/hs_ntor.h" diff --git a/src/or/keypin.c b/src/or/keypin.c index 34cf64f5c4..a2f3654b82 100644 --- a/src/or/keypin.c +++ b/src/or/keypin.c @@ -11,17 +11,28 @@ #define KEYPIN_PRIVATE #include "orconfig.h" + +#include "lib/cc/torint.h" #include "lib/crypt_ops/crypto_digest.h" #include "lib/crypt_ops/crypto_format.h" +#include "lib/crypt_ops/crypto_format.h" #include "lib/ctime/di_ops.h" +#include "lib/ctime/di_ops.h" +#include "lib/encoding/binascii.h" +#include "lib/encoding/time_fmt.h" +#include "lib/fdio/fdio.h" +#include "lib/fs/files.h" +#include "lib/fs/mmap.h" +#include "lib/log/torlog.h" +#include "lib/log/util_bug.h" +#include "lib/string/compat_ctype.h" +#include "lib/string/printf.h" +#include "lib/wallclock/approx_time.h" + #include "ht.h" #include "or/keypin.h" + #include "siphash.h" -#include "lib/cc/torint.h" -#include "lib/log/torlog.h" -#include "lib/fdio/fdio.h" -#include "common/util.h" -#include "lib/encoding/binascii.h" #ifdef HAVE_UNISTD_H #include @@ -34,6 +45,10 @@ #include #endif +#include +#include +#include + /** * @file keypin.c * @brief Key-pinning for RSA and Ed25519 identity keys at directory diff --git a/src/or/onion_ntor.c b/src/or/onion_ntor.c index 34b1112020..59c923cb97 100644 --- a/src/or/onion_ntor.c +++ b/src/or/onion_ntor.c @@ -21,14 +21,17 @@ #include "orconfig.h" #define ONION_NTOR_PRIVATE + #include "lib/crypt_ops/crypto.h" -#include "lib/crypt_ops/crypto_hkdf.h" #include "lib/crypt_ops/crypto_digest.h" +#include "lib/crypt_ops/crypto_hkdf.h" #include "lib/crypt_ops/crypto_util.h" -#include "or/onion_ntor.h" -#include "lib/log/torlog.h" #include "lib/ctime/di_ops.h" -#include "common/util.h" +#include "lib/log/torlog.h" +#include "lib/log/util_bug.h" +#include "or/onion_ntor.h" + +#include /** Free storage held in an ntor handshake state. */ void diff --git a/src/or/or.h b/src/or/or.h index b0340ed1a0..826e81e468 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -22,14 +22,48 @@ #include #endif -#include "common/util.h" - +#include "lib/arch/bytes.h" +#include "lib/cc/compat_compiler.h" +#include "lib/cc/torint.h" #include "lib/container/map.h" #include "lib/container/smartlist.h" #include "lib/crypt_ops/crypto.h" +#include "lib/ctime/di_ops.h" #include "lib/defs/dh_sizes.h" #include "lib/encoding/binascii.h" +#include "lib/encoding/cstring.h" +#include "lib/encoding/time_fmt.h" +#include "lib/err/torerr.h" +#include "lib/fs/dir.h" +#include "lib/fs/files.h" +#include "lib/fs/mmap.h" +#include "lib/fs/path.h" +#include "lib/fs/userdb.h" +#include "lib/intmath/addsub.h" +#include "lib/intmath/bits.h" +#include "lib/intmath/cmp.h" +#include "lib/intmath/logic.h" +#include "lib/intmath/muldiv.h" +#include "lib/log/escape.h" +#include "lib/log/ratelim.h" +#include "lib/log/util_bug.h" +#include "lib/malloc/util_malloc.h" #include "lib/net/address.h" +#include "lib/net/ipv4.h" +#include "lib/net/ipv6.h" +#include "lib/net/resolve.h" +#include "lib/net/socket.h" +#include "lib/string/compat_ctype.h" +#include "lib/string/compat_string.h" +#include "lib/string/parse_int.h" +#include "lib/string/printf.h" +#include "lib/string/scanf.h" +#include "lib/string/util_string.h" +#include "lib/testsupport/testsupport.h" +#include "lib/thread/threads.h" +#include "lib/time/compat_time.h" +#include "lib/wallclock/approx_time.h" +#include "lib/wallclock/timeval.h" #include "ht.h" diff --git a/src/or/shared_random_client.c b/src/or/shared_random_client.c index 9a6c0f6644..42a5b42f60 100644 --- a/src/or/shared_random_client.c +++ b/src/or/shared_random_client.c @@ -14,7 +14,6 @@ #include "or/config.h" #include "or/voting_schedule.h" #include "or/networkstatus.h" -#include "common/util.h" #include "lib/encoding/binascii.h" #include "or/networkstatus_st.h" diff --git a/src/or/torcert.c b/src/or/torcert.c index 269fa66cea..39c6605c65 100644 --- a/src/or/torcert.c +++ b/src/or/torcert.c @@ -31,7 +31,6 @@ #include "or/torcert.h" #include "trunnel/ed25519_cert.h" #include "lib/log/torlog.h" -#include "common/util.h" #include "trunnel/link_handshake.h" #include "lib/tls/tortls.h" diff --git a/src/or/transports.c b/src/or/transports.c index ff51ff00eb..1d3cb7b951 100644 --- a/src/or/transports.c +++ b/src/or/transports.c @@ -96,7 +96,6 @@ #include "or/connection.h" #include "or/circuitbuild.h" #include "or/transports.h" -#include "common/util.h" #include "or/router.h" #include "or/statefile.h" #include "or/connection_or.h" diff --git a/src/test/fuzz/fuzz_hsdescv3.c b/src/test/fuzz/fuzz_hsdescv3.c index ada9fa6c2d..de574ac26d 100644 --- a/src/test/fuzz/fuzz_hsdescv3.c +++ b/src/test/fuzz/fuzz_hsdescv3.c @@ -9,7 +9,6 @@ #include "lib/crypt_ops/crypto_ed25519.h" #include "or/hs_descriptor.h" #include "or/routerparse.h" -#include "common/util.h" #include "test/fuzz/fuzzing.h" diff --git a/src/test/test-memwipe.c b/src/test/test-memwipe.c index 552cbbc551..8a4610e904 100644 --- a/src/test/test-memwipe.c +++ b/src/test/test-memwipe.c @@ -2,14 +2,16 @@ /* See LICENSE for licensing information */ #include "orconfig.h" +#include "lib/crypt_ops/crypto_util.h" + +#include "lib/intmath/cmp.h" +#include "lib/malloc/util_malloc.h" + #include #include #include #include -#include "lib/crypt_ops/crypto_util.h" -#include "common/util.h" - static unsigned fill_a_buffer_memset(void) __attribute__((noinline)); static unsigned fill_a_buffer_memwipe(void) __attribute__((noinline)); static unsigned fill_a_buffer_nothing(void) __attribute__((noinline)); @@ -214,4 +216,3 @@ main(int argc, char **argv) return 0; } } - diff --git a/src/test/test-timers.c b/src/test/test-timers.c index aed150bda6..a2365a2e38 100644 --- a/src/test/test-timers.c +++ b/src/test/test-timers.c @@ -8,9 +8,11 @@ #include #include "common/compat_libevent.h" -#include "lib/crypt_ops/crypto_rand.h" #include "common/timers.h" -#include "common/util.h" +#include "lib/crypt_ops/crypto_rand.h" +#include "lib/log/util_bug.h" +#include "lib/time/compat_time.h" +#include "lib/wallclock/timeval.h" #define N_TIMERS 1000 #define MAX_DURATION 30 @@ -138,4 +140,3 @@ main(int argc, char **argv) timers_shutdown(); return ret; } - diff --git a/src/test/test_bridges.c b/src/test/test_bridges.c index 98e85cd6d8..685027c0e0 100644 --- a/src/test/test_bridges.c +++ b/src/test/test_bridges.c @@ -16,7 +16,6 @@ #include "or/bridges.h" #include "or/config.h" #include "or/transports.h" -#include "common/util.h" /* Test suite stuff */ #include "test/test.h" diff --git a/src/test/test_bt_cl.c b/src/test/test_bt_cl.c index 8a8221f190..3f7b0a203a 100644 --- a/src/test/test_bt_cl.c +++ b/src/test/test_bt_cl.c @@ -8,7 +8,6 @@ /* To prevent 'assert' from going away. */ #undef TOR_COVERAGE #include "or/or.h" -#include "common/util.h" #include "lib/err/backtrace.h" #include "lib/log/torlog.h" diff --git a/src/test/test_checkdir.c b/src/test/test_checkdir.c index 09688cf0a9..a80c6ebd3a 100644 --- a/src/test/test_checkdir.c +++ b/src/test/test_checkdir.c @@ -12,7 +12,6 @@ #include "or/config.h" #include "test/test.h" -#include "common/util.h" #ifdef HAVE_SYS_STAT_H #include diff --git a/src/test/test_config.c b/src/test/test_config.c index fb05645930..c7623d0c85 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -19,7 +19,6 @@ #include "or/connection.h" #include "or/connection_edge.h" #include "test/test.h" -#include "common/util.h" #include "or/connection_or.h" #include "or/control.h" #include "or/cpuworker.h" diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c index 341dbc9a4f..2e38dfc279 100644 --- a/src/test/test_crypto.c +++ b/src/test/test_crypto.c @@ -9,7 +9,6 @@ #include "or/or.h" #include "test/test.h" #include "lib/crypt_ops/aes.h" -#include "common/util.h" #include "siphash.h" #include "lib/crypt_ops/crypto_curve25519.h" #include "lib/crypt_ops/crypto_dh.h" diff --git a/src/test/test_crypto_openssl.c b/src/test/test_crypto_openssl.c index d443ba6fd0..1d31ad0279 100644 --- a/src/test/test_crypto_openssl.c +++ b/src/test/test_crypto_openssl.c @@ -7,14 +7,14 @@ #define CRYPTO_RAND_PRIVATE +#include "lib/crypt_ops/compat_openssl.h" #include "lib/crypt_ops/crypto_rand.h" -#include "common/util.h" #include "lib/encoding/binascii.h" #include "test/test.h" #include #include -#include "lib/crypt_ops/compat_openssl.h" +#include /* Test for rectifying openssl RAND engine. */ static void @@ -103,4 +103,3 @@ struct testcase_t crypto_openssl_tests[] = { TT_FORK, NULL, NULL }, END_OF_TESTCASES }; - diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c index 262e2fa680..9c35cdaaf2 100644 --- a/src/test/test_entrynodes.c +++ b/src/test/test_entrynodes.c @@ -28,7 +28,6 @@ #include "or/routerparse.h" #include "or/routerset.h" #include "or/statefile.h" -#include "common/util.h" #include "or/cpath_build_state_st.h" #include "or/crypt_path_st.h" diff --git a/src/test/test_guardfraction.c b/src/test/test_guardfraction.c index b7737cafa8..3c293e378b 100644 --- a/src/test/test_guardfraction.c +++ b/src/test/test_guardfraction.c @@ -10,7 +10,6 @@ #include "or/config.h" #include "or/dirserv.h" #include "or/entrynodes.h" -#include "common/util.h" #include "or/routerparse.h" #include "or/networkstatus.h" diff --git a/src/test/test_handles.c b/src/test/test_handles.c index 26c68aa8a3..2910d7e18f 100644 --- a/src/test/test_handles.c +++ b/src/test/test_handles.c @@ -4,8 +4,10 @@ #include "orconfig.h" #include "test/test.h" -#include "common/util.h" #include "lib/container/handles.h" +#include "lib/log/util_bug.h" + +#include typedef struct demo_t { HANDLE_ENTRY(demo, demo_t); @@ -94,4 +96,3 @@ struct testcase_t handle_tests[] = { HANDLE_TEST(basic, 0), END_OF_TESTCASES }; - diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c index 28c6316bd0..4c39570e30 100644 --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@ -31,7 +31,6 @@ #include "or/statefile.h" #include "or/circuitlist.h" #include "or/dirauth/shared_random.h" -#include "common/util.h" #include "or/voting_schedule.h" #include "or/microdesc_st.h" diff --git a/src/test/test_hs_ntor_cl.c b/src/test/test_hs_ntor_cl.c index 6bf11560b4..8643897db5 100644 --- a/src/test/test_hs_ntor_cl.c +++ b/src/test/test_hs_ntor_cl.c @@ -14,7 +14,6 @@ #define ONION_NTOR_PRIVATE #include "or/or.h" -#include "common/util.h" #include "lib/crypt_ops/crypto.h" #include "lib/crypt_ops/crypto_curve25519.h" #include "lib/crypt_ops/crypto_ed25519.h" diff --git a/src/test/test_keypin.c b/src/test/test_keypin.c index e7e7e62963..e7897a8473 100644 --- a/src/test/test_keypin.c +++ b/src/test/test_keypin.c @@ -5,7 +5,6 @@ #define KEYPIN_PRIVATE #include "or/or.h" #include "or/keypin.h" -#include "common/util.h" #include "test/test.h" diff --git a/src/test/test_ntor_cl.c b/src/test/test_ntor_cl.c index 75d5ccc126..5711a9116a 100644 --- a/src/test/test_ntor_cl.c +++ b/src/test/test_ntor_cl.c @@ -7,7 +7,6 @@ #define ONION_NTOR_PRIVATE #include "or/or.h" -#include "common/util.h" #include "lib/crypt_ops/crypto.h" #include "lib/crypt_ops/crypto_curve25519.h" #include "or/onion_ntor.h" diff --git a/src/test/test_pt.c b/src/test/test_pt.c index e685ab50de..189cb25846 100644 --- a/src/test/test_pt.c +++ b/src/test/test_pt.c @@ -15,7 +15,6 @@ #include "or/control.h" #include "or/transports.h" #include "or/circuitbuild.h" -#include "common/util.h" #include "or/statefile.h" #include "test/test.h" #include "lib/process/subprocess.h" diff --git a/src/test/test_routerkeys.c b/src/test/test_routerkeys.c index 8c2be30a8f..2a761ad6e1 100644 --- a/src/test/test_routerkeys.c +++ b/src/test/test_routerkeys.c @@ -9,7 +9,6 @@ #include "or/config.h" #include "or/router.h" #include "or/routerkeys.h" -#include "common/util.h" #include "lib/crypt_ops/crypto.h" #include "lib/crypt_ops/crypto_format.h" #include "or/torcert.h" diff --git a/src/test/test_util_slow.c b/src/test/test_util_slow.c index aeb0d422c1..5021e89dff 100644 --- a/src/test/test_util_slow.c +++ b/src/test/test_util_slow.c @@ -6,13 +6,17 @@ #include "orconfig.h" #define UTIL_PRIVATE #define SUBPROCESS_PRIVATE -#include "common/util.h" -#include "lib/process/waitpid.h" #include "lib/crypt_ops/crypto.h" #include "lib/log/torlog.h" #include "lib/process/subprocess.h" +#include "lib/process/waitpid.h" +#include "lib/string/printf.h" +#include "lib/time/compat_time.h" #include "test/test.h" +#include +#include + #ifndef BUILDDIR #define BUILDDIR "." #endif