diff options
59 files changed, 288 insertions, 210 deletions
diff --git a/changes/ticket32764 b/changes/ticket32764 new file mode 100644 index 0000000000..7795339f37 --- /dev/null +++ b/changes/ticket32764 @@ -0,0 +1,9 @@ + o Code simplification and refactoring: + + - Add numerous missing dependencies to our include files, so that + they can be included in different reasonable orders and still + compile. Addresses part of ticket 32764. + + - Fix some small issues in our code that prevented automatic + formatting tools from working. + Addresses part of ticket 32764. diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h index 4fac3ca857..2733bf775c 100644 --- a/src/app/config/or_options_st.h +++ b/src/app/config/or_options_st.h @@ -13,6 +13,7 @@ #ifndef TOR_OR_OPTIONS_ST_H #define TOR_OR_OPTIONS_ST_H +#include "core/or/or.h" #include "lib/cc/torint.h" #include "lib/net/address.h" #include "app/config/tor_cmdline_mode.h" @@ -20,6 +21,7 @@ struct smartlist_t; struct config_line_t; struct config_suite_t; +struct routerset_t; /** Enumeration of outbound address configuration types: * Exit-only, OR-only, or both */ @@ -72,28 +74,29 @@ struct or_options_t { char *Address; /**< OR only: configured address for this onion router. */ char *PidFile; /**< Where to store PID of Tor process. */ - routerset_t *ExitNodes; /**< Structure containing nicknames, digests, + struct routerset_t *ExitNodes; /**< Structure containing nicknames, digests, * country codes and IP address patterns of ORs to * consider as exits. */ - routerset_t *MiddleNodes; /**< Structure containing nicknames, digests, - * country codes and IP address patterns of ORs to - * consider as middles. */ - routerset_t *EntryNodes;/**< Structure containing nicknames, digests, + struct routerset_t *MiddleNodes; /**< Structure containing nicknames, + * digests, country codes and IP address patterns + * of ORs to consider as middles. */ + struct routerset_t *EntryNodes;/**< Structure containing nicknames, digests, * country codes and IP address patterns of ORs to * consider as entry points. */ int StrictNodes; /**< Boolean: When none of our EntryNodes or ExitNodes * are up, or we need to access a node in ExcludeNodes, * do we just fail instead? */ - routerset_t *ExcludeNodes;/**< Structure containing nicknames, digests, - * country codes and IP address patterns of ORs - * not to use in circuits. But see StrictNodes - * above. */ - routerset_t *ExcludeExitNodes;/**< Structure containing nicknames, digests, - * country codes and IP address patterns of - * ORs not to consider as exits. */ + struct routerset_t *ExcludeNodes;/**< Structure containing nicknames, + * digests, country codes and IP address patterns + * of ORs not to use in circuits. But see + * StrictNodes above. */ + struct routerset_t *ExcludeExitNodes;/**< Structure containing nicknames, + * digests, country codes and IP address + * patterns of ORs not to consider as + * exits. */ /** Union of ExcludeNodes and ExcludeExitNodes */ - routerset_t *ExcludeExitNodesUnion_; + struct routerset_t *ExcludeExitNodesUnion_; int DisableAllSwap; /**< Boolean: Attempt to call mlockall() on our * process for all current and future memory. */ @@ -280,11 +283,11 @@ struct or_options_t { /** A routerset that should be used when picking middle nodes for HS * circuits. */ - routerset_t *HSLayer2Nodes; + struct routerset_t *HSLayer2Nodes; /** A routerset that should be used when picking third-hop nodes for HS * circuits. */ - routerset_t *HSLayer3Nodes; + struct routerset_t *HSLayer3Nodes; /** Onion Services in HiddenServiceSingleHopMode make one-hop (direct) * circuits between the onion service server, and the introduction and @@ -815,17 +818,17 @@ struct or_options_t { /** Relays in a testing network which should be voted Exit * regardless of exit policy. */ - routerset_t *TestingDirAuthVoteExit; + struct routerset_t *TestingDirAuthVoteExit; int TestingDirAuthVoteExitIsStrict; /** Relays in a testing network which should be voted Guard * regardless of uptime and bandwidth. */ - routerset_t *TestingDirAuthVoteGuard; + struct routerset_t *TestingDirAuthVoteGuard; int TestingDirAuthVoteGuardIsStrict; /** Relays in a testing network which should be voted HSDir * regardless of uptime and DirPort. */ - routerset_t *TestingDirAuthVoteHSDir; + struct routerset_t *TestingDirAuthVoteHSDir; int TestingDirAuthVoteHSDirIsStrict; /** Enable CONN_BW events. Only altered on testing networks. */ diff --git a/src/core/crypto/hs_ntor.h b/src/core/crypto/hs_ntor.h index 34fad3a8ba..2bce5686cd 100644 --- a/src/core/crypto/hs_ntor.h +++ b/src/core/crypto/hs_ntor.h @@ -19,7 +19,7 @@ struct curve25519_keypair_t; (DIGEST256_LEN*2 + CIPHER256_KEY_LEN*2) /* Key material needed to encode/decode INTRODUCE1 cells */ -typedef struct { +typedef struct hs_ntor_intro_cell_keys_t { /* Key used for encryption of encrypted INTRODUCE1 blob */ uint8_t enc_key[CIPHER256_KEY_LEN]; /* MAC key used to protect encrypted INTRODUCE1 blob */ @@ -27,7 +27,7 @@ typedef struct { } hs_ntor_intro_cell_keys_t; /* Key material needed to encode/decode RENDEZVOUS1 cells */ -typedef struct { +typedef struct hs_ntor_rend_cell_keys_t { /* This is the MAC of the HANDSHAKE_INFO field */ uint8_t rend_cell_auth_mac[DIGEST256_LEN]; /* This is the key seed used to derive further rendezvous crypto keys as diff --git a/src/core/mainloop/.may_include b/src/core/mainloop/.may_include index 580e6d0a8a..8e01cf910e 100644 --- a/src/core/mainloop/.may_include +++ b/src/core/mainloop/.may_include @@ -16,7 +16,9 @@ lib/net/*.h lib/evloop/*.h lib/geoip/*.h lib/sandbox/*.h +lib/smartlist_core/*.h lib/compress/*.h +lib/log/*.h core/mainloop/*.h core/mainloop/*.inc
\ No newline at end of file diff --git a/src/core/mainloop/connection.h b/src/core/mainloop/connection.h index 399c2535eb..0ab601d86f 100644 --- a/src/core/mainloop/connection.h +++ b/src/core/mainloop/connection.h @@ -12,7 +12,25 @@ #ifndef TOR_CONNECTION_H #define TOR_CONNECTION_H -listener_connection_t *TO_LISTENER_CONN(connection_t *); +#include "lib/smartlist_core/smartlist_core.h" +#include "lib/log/log.h" + +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif + +struct listener_connection_t; +struct connection_t; +struct dir_connection_t; +struct or_connection_t; +struct edge_connection_t; +struct entry_connection_t; +struct control_connection_t; +struct port_cfg_t; +struct tor_addr_t; +struct or_options_t; + +struct listener_connection_t *TO_LISTENER_CONN(struct connection_t *); struct buf_t; @@ -56,7 +74,7 @@ struct buf_t; #define CONN_TYPE_MAX_ 19 /* !!!! If _CONN_TYPE_MAX is ever over 31, we must grow the type field in - * connection_t. */ + * struct connection_t. */ /* Proxy client handshake states */ /* We use a proxy but we haven't even connected to it yet. */ @@ -90,34 +108,36 @@ struct buf_t; */ typedef struct { - connection_t *old_conn; /* Old listener connection to be replaced */ - const port_cfg_t *new_port; /* New port configuration */ + struct connection_t *old_conn; /* Old listener connection to be replaced */ + const struct port_cfg_t *new_port; /* New port configuration */ } listener_replacement_t; const char *conn_type_to_string(int type); const char *conn_state_to_string(int type, int state); int conn_listener_type_supports_af_unix(int type); -dir_connection_t *dir_connection_new(int socket_family); -or_connection_t *or_connection_new(int type, int socket_family); -edge_connection_t *edge_connection_new(int type, int socket_family); -entry_connection_t *entry_connection_new(int type, int socket_family); -control_connection_t *control_connection_new(int socket_family); -listener_connection_t *listener_connection_new(int type, int socket_family); -connection_t *connection_new(int type, int socket_family); -int connection_init_accepted_conn(connection_t *conn, - const listener_connection_t *listener); -void connection_link_connections(connection_t *conn_a, connection_t *conn_b); -MOCK_DECL(void,connection_free_,(connection_t *conn)); +struct dir_connection_t *dir_connection_new(int socket_family); +struct or_connection_t *or_connection_new(int type, int socket_family); +struct edge_connection_t *edge_connection_new(int type, int socket_family); +struct entry_connection_t *entry_connection_new(int type, int socket_family); +struct control_connection_t *control_connection_new(int socket_family); +struct listener_connection_t *listener_connection_new(int type, + int socket_family); +struct connection_t *connection_new(int type, int socket_family); +int connection_init_accepted_conn(struct connection_t *conn, + const struct listener_connection_t *listener); +void connection_link_connections(struct connection_t *conn_a, + struct connection_t *conn_b); +MOCK_DECL(void,connection_free_,(struct connection_t *conn)); #define connection_free(conn) \ - FREE_AND_NULL(connection_t, connection_free_, (conn)) + FREE_AND_NULL(struct connection_t, connection_free_, (conn)) void connection_free_all(void); -void connection_about_to_close_connection(connection_t *conn); -void connection_close_immediate(connection_t *conn); -void connection_mark_for_close_(connection_t *conn, +void connection_about_to_close_connection(struct connection_t *conn); +void connection_close_immediate(struct connection_t *conn); +void connection_mark_for_close_(struct connection_t *conn, int line, const char *file); MOCK_DECL(void, connection_mark_for_close_internal_, - (connection_t *conn, int line, const char *file)); + (struct connection_t *conn, int line, const char *file)); #define connection_mark_for_close(c) \ connection_mark_for_close_((c), __LINE__, SHORT_FILE__) @@ -132,11 +152,11 @@ MOCK_DECL(void, connection_mark_for_close_internal_, * connection_or_notify_error()), or you actually are the * connection_or_close_for_error() or connection_or_close_normally function. * For all other cases, use connection_mark_and_flush() instead, which - * checks for or_connection_t properly, instead. See below. + * checks for struct or_connection_t properly, instead. See below. */ #define connection_mark_and_flush_internal_(c,line,file) \ do { \ - connection_t *tmp_conn__ = (c); \ + struct connection_t *tmp_conn__ = (c); \ connection_mark_for_close_internal_(tmp_conn__, (line), (file)); \ tmp_conn__->hold_open_until_flushed = 1; \ } while (0) @@ -149,7 +169,7 @@ MOCK_DECL(void, connection_mark_for_close_internal_, */ #define connection_mark_and_flush_(c,line,file) \ do { \ - connection_t *tmp_conn_ = (c); \ + struct connection_t *tmp_conn_ = (c); \ if (tmp_conn_->type == CONN_TYPE_OR) { \ log_warn(LD_CHANNEL | LD_BUG, \ "Something tried to close (and flush) an or_connection_t" \ @@ -166,13 +186,13 @@ MOCK_DECL(void, connection_mark_for_close_internal_, void connection_expire_held_open(void); -int connection_connect(connection_t *conn, const char *address, - const tor_addr_t *addr, +int connection_connect(struct connection_t *conn, const char *address, + const struct tor_addr_t *addr, uint16_t port, int *socket_error); #ifdef HAVE_SYS_UN_H -int connection_connect_unix(connection_t *conn, const char *socket_path, +int connection_connect_unix(struct connection_t *conn, const char *socket_path, int *socket_error); #endif /* defined(HAVE_SYS_UN_H) */ @@ -185,78 +205,86 @@ int connection_connect_unix(connection_t *conn, const char *socket_path, username and password fields. */ #define MAX_SOCKS5_AUTH_SIZE_TOTAL 2*MAX_SOCKS5_AUTH_FIELD_SIZE -int connection_proxy_connect(connection_t *conn, int type); -int connection_read_proxy_handshake(connection_t *conn); -void log_failed_proxy_connection(connection_t *conn); -int get_proxy_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type, - int *is_pt_out, const connection_t *conn); +int connection_proxy_connect(struct connection_t *conn, int type); +int connection_read_proxy_handshake(struct connection_t *conn); +void log_failed_proxy_connection(struct connection_t *conn); +int get_proxy_addrport(struct tor_addr_t *addr, uint16_t *port, + int *proxy_type, + int *is_pt_out, const struct connection_t *conn); -int retry_all_listeners(smartlist_t *new_conns, +int retry_all_listeners(struct smartlist_t *new_conns, int close_all_noncontrol); void connection_mark_all_noncontrol_listeners(void); void connection_mark_all_noncontrol_connections(void); -ssize_t connection_bucket_write_limit(connection_t *conn, time_t now); -int global_write_bucket_low(connection_t *conn, size_t attempt, int priority); +ssize_t connection_bucket_write_limit(struct connection_t *conn, time_t now); +int global_write_bucket_low(struct connection_t *conn, + size_t attempt, int priority); void connection_bucket_init(void); -void connection_bucket_adjust(const or_options_t *options); +void connection_bucket_adjust(const struct or_options_t *options); void connection_bucket_refill_all(time_t now, uint32_t now_ts); -void connection_read_bw_exhausted(connection_t *conn, bool is_global_bw); -void connection_write_bw_exhausted(connection_t *conn, bool is_global_bw); -void connection_consider_empty_read_buckets(connection_t *conn); -void connection_consider_empty_write_buckets(connection_t *conn); - -int connection_handle_read(connection_t *conn); - -int connection_buf_get_bytes(char *string, size_t len, connection_t *conn); -int connection_buf_get_line(connection_t *conn, char *data, - size_t *data_len); -int connection_fetch_from_buf_http(connection_t *conn, +void connection_read_bw_exhausted(struct connection_t *conn, + bool is_global_bw); +void connection_write_bw_exhausted(struct connection_t *conn, + bool is_global_bw); +void connection_consider_empty_read_buckets(struct connection_t *conn); +void connection_consider_empty_write_buckets(struct connection_t *conn); + +int connection_handle_read(struct connection_t *conn); + +int connection_buf_get_bytes(char *string, size_t len, + struct connection_t *conn); +int connection_buf_get_line(struct connection_t *conn, char *data, + size_t *data_len); +int connection_fetch_from_buf_http(struct connection_t *conn, char **headers_out, size_t max_headerlen, char **body_out, size_t *body_used, size_t max_bodylen, int force_complete); -int connection_wants_to_flush(connection_t *conn); -int connection_outbuf_too_full(connection_t *conn); -int connection_handle_write(connection_t *conn, int force); -int connection_flush(connection_t *conn); +int connection_wants_to_flush(struct connection_t *conn); +int connection_outbuf_too_full(struct connection_t *conn); +int connection_handle_write(struct connection_t *conn, int force); +int connection_flush(struct connection_t *conn); MOCK_DECL(void, connection_write_to_buf_impl_, - (const char *string, size_t len, connection_t *conn, int zlib)); + (const char *string, size_t len, struct connection_t *conn, + int zlib)); /* DOCDOC connection_write_to_buf */ static void connection_buf_add(const char *string, size_t len, - connection_t *conn); + struct connection_t *conn); void connection_dir_buf_add(const char *string, size_t len, - dir_connection_t *dir_conn, int done); + struct dir_connection_t *dir_conn, int done); static inline void -connection_buf_add(const char *string, size_t len, connection_t *conn) +connection_buf_add(const char *string, size_t len, struct connection_t *conn) { connection_write_to_buf_impl_(string, len, conn, 0); } void connection_buf_add_compress(const char *string, size_t len, - dir_connection_t *conn, int done); -void connection_buf_add_buf(connection_t *conn, struct buf_t *buf); - -size_t connection_get_inbuf_len(connection_t *conn); -size_t connection_get_outbuf_len(connection_t *conn); -connection_t *connection_get_by_global_id(uint64_t id); - -connection_t *connection_get_by_type(int type); -MOCK_DECL(connection_t *,connection_get_by_type_nonlinked,(int type)); -MOCK_DECL(connection_t *,connection_get_by_type_addr_port_purpose,(int type, - const tor_addr_t *addr, - uint16_t port, int purpose)); -connection_t *connection_get_by_type_state(int type, int state); -connection_t *connection_get_by_type_state_rendquery(int type, int state, + struct dir_connection_t *conn, int done); +void connection_buf_add_buf(struct connection_t *conn, struct buf_t *buf); + +size_t connection_get_inbuf_len(struct connection_t *conn); +size_t connection_get_outbuf_len(struct connection_t *conn); +struct connection_t *connection_get_by_global_id(uint64_t id); + +struct connection_t *connection_get_by_type(int type); +MOCK_DECL(struct connection_t *,connection_get_by_type_nonlinked,(int type)); +MOCK_DECL(struct connection_t *,connection_get_by_type_addr_port_purpose, + (int type, + const struct tor_addr_t *addr, + uint16_t port, int purpose)); +struct connection_t *connection_get_by_type_state(int type, int state); +struct connection_t *connection_get_by_type_state_rendquery( + int type, int state, const char *rendquery); -smartlist_t *connection_list_by_type_state(int type, int state); -smartlist_t *connection_list_by_type_purpose(int type, int purpose); -smartlist_t *connection_dir_list_by_purpose_and_resource( +struct smartlist_t *connection_list_by_type_state(int type, int state); +struct smartlist_t *connection_list_by_type_purpose(int type, int purpose); +struct smartlist_t *connection_dir_list_by_purpose_and_resource( int purpose, const char *resource); -smartlist_t *connection_dir_list_by_purpose_resource_and_state( +struct smartlist_t *connection_dir_list_by_purpose_resource_and_state( int purpose, const char *resource, int state); @@ -275,7 +303,7 @@ connection_dir_count_by_purpose_and_resource( int purpose, const char *resource) { - smartlist_t *conns = connection_dir_list_by_purpose_and_resource( + struct smartlist_t *conns = connection_dir_list_by_purpose_and_resource( purpose, resource); CONN_LEN_AND_FREE_TEMPLATE(conns); @@ -289,7 +317,7 @@ connection_dir_count_by_purpose_resource_and_state( const char *resource, int state) { - smartlist_t *conns = + struct smartlist_t *conns = connection_dir_list_by_purpose_resource_and_state( purpose, resource, @@ -299,26 +327,26 @@ connection_dir_count_by_purpose_resource_and_state( #undef CONN_LEN_AND_FREE_TEMPLATE -int any_other_active_or_conns(const or_connection_t *this_conn); +int any_other_active_or_conns(const struct or_connection_t *this_conn); /* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */ #define connection_speaks_cells(conn) (((conn)->type == CONN_TYPE_OR) || 0) -int connection_is_listener(connection_t *conn); -int connection_state_is_open(connection_t *conn); -int connection_state_is_connecting(connection_t *conn); +int connection_is_listener(struct connection_t *conn); +int connection_state_is_open(struct connection_t *conn); +int connection_state_is_connecting(struct connection_t *conn); char *alloc_http_authenticator(const char *authenticator); -void assert_connection_ok(connection_t *conn, time_t now); -int connection_or_nonopen_was_started_here(or_connection_t *conn); +void assert_connection_ok(struct connection_t *conn, time_t now); +int connection_or_nonopen_was_started_here(struct or_connection_t *conn); void connection_dump_buffer_mem_stats(int severity); MOCK_DECL(void, clock_skew_warning, - (const connection_t *conn, long apparent_skew, int trusted, + (const struct connection_t *conn, long apparent_skew, int trusted, log_domain_mask_t domain, const char *received, const char *source)); -int connection_is_moribund(connection_t *conn); +int connection_is_moribund(struct connection_t *conn); void connection_check_oos(int n_socks, int failed); /** Execute the statement <b>stmt</b>, which may log events concerning the @@ -340,18 +368,18 @@ void connection_check_oos(int n_socks, int failed); STMT_END #ifdef CONNECTION_PRIVATE -STATIC void connection_free_minimal(connection_t *conn); +STATIC void connection_free_minimal(struct connection_t *conn); /* Used only by connection.c and test*.c */ MOCK_DECL(STATIC int,connection_connect_sockaddr, - (connection_t *conn, + (struct connection_t *conn, const struct sockaddr *sa, socklen_t sa_len, const struct sockaddr *bindaddr, socklen_t bindaddr_len, int *socket_error)); -MOCK_DECL(STATIC void, kill_conn_list_for_oos, (smartlist_t *conns)); -MOCK_DECL(STATIC smartlist_t *, pick_oos_victims, (int n)); +MOCK_DECL(STATIC void, kill_conn_list_for_oos, (struct smartlist_t *conns)); +MOCK_DECL(STATIC struct smartlist_t *, pick_oos_victims, (int n)); #endif /* defined(CONNECTION_PRIVATE) */ diff --git a/src/core/or/.may_include b/src/core/or/.may_include index 5173e8a2b6..beb12f155d 100644 --- a/src/core/or/.may_include +++ b/src/core/or/.may_include @@ -35,4 +35,6 @@ trunnel/*.h core/mainloop/*.h core/proto/*.h core/crypto/*.h -core/or/*.h
\ No newline at end of file +core/or/*.h + +ext/*.h diff --git a/src/core/or/channel.h b/src/core/or/channel.h index 342ffcf16c..51bb2f7fae 100644 --- a/src/core/or/channel.h +++ b/src/core/or/channel.h @@ -14,6 +14,7 @@ #include "lib/container/handles.h" #include "lib/crypt_ops/crypto_ed25519.h" +#include "ext/ht.h" #include "tor_queue.h" #define tor_timer_t timeout diff --git a/src/core/or/circuit_st.h b/src/core/or/circuit_st.h index 8891f6d0fc..4baafb1848 100644 --- a/src/core/or/circuit_st.h +++ b/src/core/or/circuit_st.h @@ -17,6 +17,7 @@ #include "lib/container/handles.h" #include "core/or/cell_queue_st.h" +#include "ext/ht.h" struct hs_token_t; struct circpad_machine_spec_t; diff --git a/src/core/or/scheduler.h b/src/core/or/scheduler.h index 1a14298682..82df2b0b0f 100644 --- a/src/core/or/scheduler.h +++ b/src/core/or/scheduler.h @@ -138,6 +138,8 @@ MOCK_DECL(void, scheduler_channel_has_waiting_cells, (channel_t *chan)); *****************************************************************************/ #ifdef SCHEDULER_PRIVATE +#include "ext/ht.h" + /********************************* * Defined in scheduler.c *********************************/ @@ -215,4 +217,3 @@ scheduler_t *get_vanilla_scheduler(void); #endif /* defined(SCHEDULER_PRIVATE) */ #endif /* !defined(TOR_SCHEDULER_H) */ - diff --git a/src/ext/ht.h b/src/ext/ht.h index bb5604131b..9d4add1936 100644 --- a/src/ext/ht.h +++ b/src/ext/ht.h @@ -226,7 +226,8 @@ ht_string_hash(const char *s) (x) = HT_NEXT(name, head, x)) #ifndef HT_NDEBUG -#define HT_ASSERT_(x) tor_assert(x) +#include "lib/err/torerr.h" +#define HT_ASSERT_(x) raw_assert(x) #else #define HT_ASSERT_(x) (void)0 #endif diff --git a/src/ext/siphash.h b/src/ext/siphash.h index 730e49937d..0207a959ff 100644 --- a/src/ext/siphash.h +++ b/src/ext/siphash.h @@ -1,6 +1,8 @@ #ifndef SIPHASH_H #define SIPHASH_H +#include <stdint.h> + struct sipkey { uint64_t k0; uint64_t k1; diff --git a/src/ext/tinytest_macros.h b/src/ext/tinytest_macros.h index c3728d1fdd..6fc2cea2da 100644 --- a/src/ext/tinytest_macros.h +++ b/src/ext/tinytest_macros.h @@ -99,11 +99,11 @@ /* Assert b, but do not stop the test if b fails. Log msg on failure. */ #define tt_want_msg(b, msg) \ - tt_want_(b, msg, ); + tt_want_(b, msg, ) /* Assert b and stop the test if b fails. Log msg on failure. */ #define tt_assert_msg(b, msg) \ - tt_want_(b, msg, TT_EXIT_TEST_FUNCTION); + tt_want_(b, msg, TT_EXIT_TEST_FUNCTION) /* Assert b, but do not stop the test if b fails. */ #define tt_want(b) tt_want_msg( (b), "want("#b")") diff --git a/src/feature/control/control_hs.h b/src/feature/control/control_hs.h index 8b9ebaba19..8a0cd6818d 100644 --- a/src/feature/control/control_hs.h +++ b/src/feature/control/control_hs.h @@ -11,23 +11,24 @@ #ifndef TOR_CONTROL_HS_H #define TOR_CONTROL_HS_H +struct control_connection_t; struct control_cmd_syntax_t; +struct control_cmd_args_t; extern const struct control_cmd_syntax_t onion_client_auth_add_syntax; extern const struct control_cmd_syntax_t onion_client_auth_remove_syntax; extern const struct control_cmd_syntax_t onion_client_auth_view_syntax; int -handle_control_onion_client_auth_add(control_connection_t *conn, - const control_cmd_args_t *args); +handle_control_onion_client_auth_add(struct control_connection_t *conn, + const struct control_cmd_args_t *args); int -handle_control_onion_client_auth_remove(control_connection_t *conn, - const control_cmd_args_t *args); +handle_control_onion_client_auth_remove(struct control_connection_t *conn, + const struct control_cmd_args_t *args); int -handle_control_onion_client_auth_view(control_connection_t *conn, - const control_cmd_args_t *args); +handle_control_onion_client_auth_view(struct control_connection_t *conn, + const struct control_cmd_args_t *args); #endif /* !defined(TOR_CONTROL_HS_H) */ - diff --git a/src/feature/dirauth/authmode.c b/src/feature/dirauth/authmode.c index 62fc1d8873..0fde7bc679 100644 --- a/src/feature/dirauth/authmode.c +++ b/src/feature/dirauth/authmode.c @@ -26,6 +26,15 @@ authdir_mode(const or_options_t *options) { return options->AuthoritativeDir != 0; } + +/* Return true iff we believe ourselves to be a v3 authoritative directory + * server. */ +int +authdir_mode_v3(const or_options_t *options) +{ + return authdir_mode(options) && options->V3AuthoritativeDir != 0; +} + /** Return true iff we are an authoritative directory server that is * authoritative about receiving and serving descriptors of type * <b>purpose</b> on its dirport. diff --git a/src/feature/dirauth/authmode.h b/src/feature/dirauth/authmode.h index a9b9035458..6e6ba7f8ae 100644 --- a/src/feature/dirauth/authmode.h +++ b/src/feature/dirauth/authmode.h @@ -14,19 +14,12 @@ #ifdef HAVE_MODULE_DIRAUTH int authdir_mode(const or_options_t *options); +int authdir_mode_v3(const or_options_t *options); int authdir_mode_handles_descs(const or_options_t *options, int purpose); int authdir_mode_publishes_statuses(const or_options_t *options); int authdir_mode_tests_reachability(const or_options_t *options); int authdir_mode_bridge(const or_options_t *options); -/* Return true iff we believe ourselves to be a v3 authoritative directory - * server. */ -static inline int -authdir_mode_v3(const or_options_t *options) -{ - return authdir_mode(options) && options->V3AuthoritativeDir != 0; -} - /* Is the dirauth module enabled? */ #define have_module_dirauth() (1) diff --git a/src/feature/dirauth/keypin.h b/src/feature/dirauth/keypin.h index 11d0f2cc03..881f010f0e 100644 --- a/src/feature/dirauth/keypin.h +++ b/src/feature/dirauth/keypin.h @@ -45,6 +45,8 @@ int keypin_check_lone_rsa(const uint8_t *rsa_id_digest); #ifdef KEYPIN_PRIVATE +#include "ext/ht.h" + /** * In-memory representation of a key-pinning table entry. */ diff --git a/src/feature/dircache/conscache.h b/src/feature/dircache/conscache.h index d763943819..ace5908e40 100644 --- a/src/feature/dircache/conscache.h +++ b/src/feature/dircache/conscache.h @@ -14,6 +14,8 @@ typedef struct consensus_cache_entry_t consensus_cache_entry_t; typedef struct consensus_cache_t consensus_cache_t; +struct config_line_t; + HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, ) #define consensus_cache_entry_handle_free(h) \ FREE_AND_NULL(consensus_cache_entry_handle_t, \ diff --git a/src/feature/dircache/consdiffmgr.h b/src/feature/dircache/consdiffmgr.h index 72de95f183..27b8165e94 100644 --- a/src/feature/dircache/consdiffmgr.h +++ b/src/feature/dircache/consdiffmgr.h @@ -66,17 +66,19 @@ void consdiffmgr_free_all(void); int consdiffmgr_validate(void); #ifdef CONSDIFFMGR_PRIVATE +struct consensus_cache_t; +struct consensus_cache_entry_t; STATIC unsigned n_diff_compression_methods(void); STATIC unsigned n_consensus_compression_methods(void); -STATIC consensus_cache_t *cdm_cache_get(void); -STATIC consensus_cache_entry_t *cdm_cache_lookup_consensus( +STATIC struct consensus_cache_t *cdm_cache_get(void); +STATIC struct consensus_cache_entry_t *cdm_cache_lookup_consensus( consensus_flavor_t flavor, time_t valid_after); STATIC int cdm_entry_get_sha3_value(uint8_t *digest_out, - consensus_cache_entry_t *ent, + struct consensus_cache_entry_t *ent, const char *label); STATIC int uncompress_or_set_ptr(const char **out, size_t *outlen, char **owned_out, - consensus_cache_entry_t *ent); + struct consensus_cache_entry_t *ent); #endif /* defined(CONSDIFFMGR_PRIVATE) */ #ifdef TOR_UNIT_TESTS diff --git a/src/feature/dirparse/routerparse.h b/src/feature/dirparse/routerparse.h index ca9250fa9a..519044e9b0 100644 --- a/src/feature/dirparse/routerparse.h +++ b/src/feature/dirparse/routerparse.h @@ -41,6 +41,7 @@ void routerparse_init(void); void routerparse_free_all(void); #ifdef ROUTERDESC_TOKEN_TABLE_PRIVATE +#include "feature/dirparse/parsecommon.h" extern const struct token_rule_t routerdesc_token_table[]; #endif diff --git a/src/feature/hs/hs_circuit.h b/src/feature/hs/hs_circuit.h index d9ea90b201..92231369c6 100644 --- a/src/feature/hs/hs_circuit.h +++ b/src/feature/hs/hs_circuit.h @@ -70,13 +70,14 @@ bool hs_circ_is_rend_sent_in_intro1(const origin_circuit_t *circ); #ifdef HS_CIRCUIT_PRIVATE +struct hs_ntor_rend_cell_keys_t; + STATIC hs_ident_circuit_t * create_rp_circuit_identifier(const hs_service_t *service, const uint8_t *rendezvous_cookie, const curve25519_public_key_t *server_pk, - const hs_ntor_rend_cell_keys_t *keys); + const struct hs_ntor_rend_cell_keys_t *keys); #endif /* defined(HS_CIRCUIT_PRIVATE) */ #endif /* !defined(TOR_HS_CIRCUIT_H) */ - diff --git a/src/feature/hs/hs_circuitmap.h b/src/feature/hs/hs_circuitmap.h index c3bc260409..df3e7a6e7e 100644 --- a/src/feature/hs/hs_circuitmap.h +++ b/src/feature/hs/hs_circuitmap.h @@ -14,6 +14,7 @@ typedef HT_HEAD(hs_circuitmap_ht, circuit_t) hs_circuitmap_ht; typedef struct hs_token_t hs_token_t; struct or_circuit_t; struct origin_circuit_t; +struct ed25519_public_key_t; /** Public HS circuitmap API: */ @@ -21,7 +22,7 @@ struct origin_circuit_t; struct or_circuit_t * hs_circuitmap_get_intro_circ_v3_relay_side(const - ed25519_public_key_t *auth_key); + struct ed25519_public_key_t *auth_key); struct or_circuit_t * hs_circuitmap_get_intro_circ_v2_relay_side(const uint8_t *digest); struct or_circuit_t * @@ -32,7 +33,7 @@ void hs_circuitmap_register_rend_circ_relay_side(struct or_circuit_t *circ, void hs_circuitmap_register_intro_circ_v2_relay_side(struct or_circuit_t *circ, const uint8_t *digest); void hs_circuitmap_register_intro_circ_v3_relay_side(struct or_circuit_t *circ, - const ed25519_public_key_t *auth_key); + const struct ed25519_public_key_t *auth_key); smartlist_t *hs_circuitmap_get_all_intro_circ_relay_side(void); @@ -40,7 +41,7 @@ smartlist_t *hs_circuitmap_get_all_intro_circ_relay_side(void); struct origin_circuit_t * hs_circuitmap_get_intro_circ_v3_service_side(const - ed25519_public_key_t *auth_key); + struct ed25519_public_key_t *auth_key); struct origin_circuit_t * hs_circuitmap_get_intro_circ_v2_service_side(const uint8_t *digest); struct origin_circuit_t * @@ -54,8 +55,8 @@ void hs_circuitmap_register_intro_circ_v2_service_side( struct origin_circuit_t *circ, const uint8_t *digest); void hs_circuitmap_register_intro_circ_v3_service_side( - struct origin_circuit_t *circ, - const ed25519_public_key_t *auth_key); + struct origin_circuit_t *circ, + const struct ed25519_public_key_t *auth_key); void hs_circuitmap_register_rend_circ_service_side( struct origin_circuit_t *circ, const uint8_t *cookie); diff --git a/src/feature/hs/hs_service.h b/src/feature/hs/hs_service.h index 2fc5055e89..8809411e01 100644 --- a/src/feature/hs/hs_service.h +++ b/src/feature/hs/hs_service.h @@ -21,6 +21,8 @@ /* Trunnel */ #include "trunnel/hs/cell_establish_intro.h" +#include "ext/ht.h" + /** When loading and configuring a service, this is the default version it will * be configured for as it is possible that no HiddenServiceVersion is * present. */ diff --git a/src/feature/nodelist/microdesc_st.h b/src/feature/nodelist/microdesc_st.h index 51e3bc0b88..410403e965 100644 --- a/src/feature/nodelist/microdesc_st.h +++ b/src/feature/nodelist/microdesc_st.h @@ -17,6 +17,8 @@ struct ed25519_public_key_t; struct nodefamily_t; struct short_policy_t; +#include "ext/ht.h" + /** A microdescriptor is the smallest amount of information needed to build a * circuit through a router. They are generated by the directory authorities, * using information from the uploaded routerinfo documents. They are not diff --git a/src/feature/nodelist/node_st.h b/src/feature/nodelist/node_st.h index f9389a1867..b1ec4db202 100644 --- a/src/feature/nodelist/node_st.h +++ b/src/feature/nodelist/node_st.h @@ -14,6 +14,7 @@ #include "feature/hs/hsdir_index_st.h" #include "lib/crypt_ops/crypto_ed25519.h" +#include "ext/ht.h" /** A node_t represents a Tor router. * diff --git a/src/feature/relay/dns_structs.h b/src/feature/relay/dns_structs.h index 24298db9a1..27a791b9b3 100644 --- a/src/feature/relay/dns_structs.h +++ b/src/feature/relay/dns_structs.h @@ -13,6 +13,8 @@ #ifndef TOR_DNS_STRUCTS_H #define TOR_DNS_STRUCTS_H +#include "ext/ht.h" + /** Longest hostname we're willing to resolve. */ #define MAX_ADDRESSLEN 256 @@ -99,4 +101,3 @@ typedef struct cached_resolve_t { } cached_resolve_t; #endif /* !defined(TOR_DNS_STRUCTS_H) */ - diff --git a/src/feature/stats/geoip_stats.h b/src/feature/stats/geoip_stats.h index c99f4450dc..fcfe7a31f0 100644 --- a/src/feature/stats/geoip_stats.h +++ b/src/feature/stats/geoip_stats.h @@ -13,6 +13,7 @@ #define TOR_GEOIP_STATS_H #include "core/or/dos.h" +#include "ext/ht.h" /** Indicates an action that we might be noting geoip statistics on. * Note that if we're noticing CONNECT, we're a bridge, and if we're noticing diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h index 432487236e..47782fda08 100644 --- a/src/lib/cc/compat_compiler.h +++ b/src/lib/cc/compat_compiler.h @@ -59,8 +59,6 @@ /* Temporarily enable and disable warnings. */ #ifdef __GNUC__ -# define PRAGMA_STRINGIFY_(s) #s -# define PRAGMA_JOIN_STRINGIFY_(a,b) PRAGMA_STRINGIFY_(a ## b) /* Support for macro-generated pragmas (c99) */ # define PRAGMA_(x) _Pragma (#x) # ifdef __clang__ @@ -72,15 +70,15 @@ /* we have push/pop support */ # define DISABLE_GCC_WARNING(warningopt) \ PRAGMA_DIAGNOSTIC_(push) \ - PRAGMA_DIAGNOSTIC_(ignored PRAGMA_JOIN_STRINGIFY_(-W,warningopt)) + PRAGMA_DIAGNOSTIC_(ignored warningopt) # define ENABLE_GCC_WARNING(warningopt) \ PRAGMA_DIAGNOSTIC_(pop) #else /* !(defined(__clang__) || GCC_VERSION >= 406) */ /* older version of gcc: no push/pop support. */ # define DISABLE_GCC_WARNING(warningopt) \ - PRAGMA_DIAGNOSTIC_(ignored PRAGMA_JOIN_STRINGIFY_(-W,warningopt)) + PRAGMA_DIAGNOSTIC_(ignored warningopt) # define ENABLE_GCC_WARNING(warningopt) \ - PRAGMA_DIAGNOSTIC_(warning PRAGMA_JOIN_STRINGIFY_(-W,warningopt)) + PRAGMA_DIAGNOSTIC_(warning warningopt) #endif /* defined(__clang__) || GCC_VERSION >= 406 */ #else /* !defined(__GNUC__) */ /* not gcc at all */ diff --git a/src/lib/compress/compress_zstd.c b/src/lib/compress/compress_zstd.c index 5c354abc01..5913d823e1 100644 --- a/src/lib/compress/compress_zstd.c +++ b/src/lib/compress/compress_zstd.c @@ -29,11 +29,11 @@ #ifdef HAVE_ZSTD #ifdef HAVE_CFLAG_WUNUSED_CONST_VARIABLE -DISABLE_GCC_WARNING(unused-const-variable) +DISABLE_GCC_WARNING("-Wunused-const-variable") #endif #include <zstd.h> #ifdef HAVE_CFLAG_WUNUSED_CONST_VARIABLE -ENABLE_GCC_WARNING(unused-const-variable) +ENABLE_GCC_WARNING("-Wunused-const-variable") #endif #endif /* defined(HAVE_ZSTD) */ diff --git a/src/lib/conf/conftesting.h b/src/lib/conf/conftesting.h index 158456db19..4707c919d3 100644 --- a/src/lib/conf/conftesting.h +++ b/src/lib/conf/conftesting.h @@ -12,6 +12,8 @@ #ifndef TOR_LIB_CONF_CONFTESTING_H #define TOR_LIB_CONF_CONFTESTING_H +#include "lib/cc/torint.h" + #ifndef COCCI #ifdef TOR_UNIT_TESTS #define USE_CONF_TESTING diff --git a/src/lib/crypt_ops/aes_nss.c b/src/lib/crypt_ops/aes_nss.c index e54a4d4d5e..71d2f01449 100644 --- a/src/lib/crypt_ops/aes_nss.c +++ b/src/lib/crypt_ops/aes_nss.c @@ -15,10 +15,10 @@ #include "lib/crypt_ops/crypto_util.h" #include "lib/log/util_bug.h" -DISABLE_GCC_WARNING(strict-prototypes) +DISABLE_GCC_WARNING("-Wstrict-prototypes") #include <pk11pub.h> #include <secerr.h> -ENABLE_GCC_WARNING(strict-prototypes) +ENABLE_GCC_WARNING("-Wstrict-prototypes") aes_cnt_cipher_t * aes_new_cipher(const uint8_t *key, const uint8_t *iv, diff --git a/src/lib/crypt_ops/aes_openssl.c b/src/lib/crypt_ops/aes_openssl.c index 4ee22647de..502f7703bd 100644 --- a/src/lib/crypt_ops/aes_openssl.c +++ b/src/lib/crypt_ops/aes_openssl.c @@ -28,7 +28,7 @@ #error "We require OpenSSL >= 1.0.0" #endif -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <stdlib.h> #include <string.h> @@ -37,7 +37,7 @@ DISABLE_GCC_WARNING(redundant-decls) #include <openssl/engine.h> #include <openssl/modes.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #include "lib/log/log.h" #include "lib/ctime/di_ops.h" diff --git a/src/lib/crypt_ops/crypto_dh_openssl.c b/src/lib/crypt_ops/crypto_dh_openssl.c index 30ddcaca25..c5f7271596 100644 --- a/src/lib/crypt_ops/crypto_dh_openssl.c +++ b/src/lib/crypt_ops/crypto_dh_openssl.c @@ -17,11 +17,11 @@ #include "lib/log/log.h" #include "lib/log/util_bug.h" -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/dh.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/bn.h> #include <string.h> diff --git a/src/lib/crypt_ops/crypto_digest_nss.c b/src/lib/crypt_ops/crypto_digest_nss.c index 093973ab81..7e7464273e 100644 --- a/src/lib/crypt_ops/crypto_digest_nss.c +++ b/src/lib/crypt_ops/crypto_digest_nss.c @@ -23,9 +23,9 @@ #include "lib/arch/bytes.h" -DISABLE_GCC_WARNING(strict-prototypes) +DISABLE_GCC_WARNING("-Wstrict-prototypes") #include <pk11pub.h> -ENABLE_GCC_WARNING(strict-prototypes) +ENABLE_GCC_WARNING("-Wstrict-prototypes") /** * Convert a digest_algorithm_t (used by tor) to a HashType (used by NSS). diff --git a/src/lib/crypt_ops/crypto_digest_openssl.c b/src/lib/crypt_ops/crypto_digest_openssl.c index 1af26eab63..bc076df619 100644 --- a/src/lib/crypt_ops/crypto_digest_openssl.c +++ b/src/lib/crypt_ops/crypto_digest_openssl.c @@ -25,12 +25,12 @@ #include "lib/crypt_ops/crypto_openssl_mgt.h" -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/hmac.h> #include <openssl/sha.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") /* Crypto digest functions */ diff --git a/src/lib/crypt_ops/crypto_nss_mgt.c b/src/lib/crypt_ops/crypto_nss_mgt.c index b334c149d3..d82e51249c 100644 --- a/src/lib/crypt_ops/crypto_nss_mgt.c +++ b/src/lib/crypt_ops/crypto_nss_mgt.c @@ -16,7 +16,7 @@ #include "lib/log/util_bug.h" #include "lib/string/printf.h" -DISABLE_GCC_WARNING(strict-prototypes) +DISABLE_GCC_WARNING("-Wstrict-prototypes") #include <nss.h> #include <pk11func.h> #include <ssl.h> @@ -24,7 +24,7 @@ DISABLE_GCC_WARNING(strict-prototypes) #include <prerror.h> #include <prtypes.h> #include <prinit.h> -ENABLE_GCC_WARNING(strict-prototypes) +ENABLE_GCC_WARNING("-Wstrict-prototypes") const char * crypto_nss_get_version_str(void) diff --git a/src/lib/crypt_ops/crypto_openssl_mgt.c b/src/lib/crypt_ops/crypto_openssl_mgt.c index eb4f087e5f..f2f5a55d05 100644 --- a/src/lib/crypt_ops/crypto_openssl_mgt.c +++ b/src/lib/crypt_ops/crypto_openssl_mgt.c @@ -21,7 +21,7 @@ #include "lib/testsupport/testsupport.h" #include "lib/thread/threads.h" -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/err.h> #include <openssl/rsa.h> @@ -36,7 +36,7 @@ DISABLE_GCC_WARNING(redundant-decls) #include <openssl/crypto.h> #include <openssl/ssl.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #include <string.h> diff --git a/src/lib/crypt_ops/crypto_rand.c b/src/lib/crypt_ops/crypto_rand.c index 0c1aa04fa0..ac5f10da64 100644 --- a/src/lib/crypt_ops/crypto_rand.c +++ b/src/lib/crypt_ops/crypto_rand.c @@ -43,10 +43,10 @@ #endif #ifdef ENABLE_OPENSSL -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/rand.h> #include <openssl/sha.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #endif /* defined(ENABLE_OPENSSL) */ #ifdef ENABLE_NSS diff --git a/src/lib/crypt_ops/crypto_rsa_nss.c b/src/lib/crypt_ops/crypto_rsa_nss.c index f251a3581d..0a5041aad4 100644 --- a/src/lib/crypt_ops/crypto_rsa_nss.c +++ b/src/lib/crypt_ops/crypto_rsa_nss.c @@ -645,7 +645,7 @@ crypto_pk_asn1_decode(const char *str, size_t len) return result; } -DISABLE_GCC_WARNING(unused-parameter) +DISABLE_GCC_WARNING("-Wunused-parameter") /** Given a crypto_pk_t <b>pk</b>, allocate a new buffer containing the Base64 * encoding of the DER representation of the private key into the diff --git a/src/lib/crypt_ops/crypto_rsa_openssl.c b/src/lib/crypt_ops/crypto_rsa_openssl.c index 9b553ea7be..e5025108ae 100644 --- a/src/lib/crypt_ops/crypto_rsa_openssl.c +++ b/src/lib/crypt_ops/crypto_rsa_openssl.c @@ -16,7 +16,7 @@ #include "lib/log/util_bug.h" #include "lib/fs/files.h" -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/err.h> #include <openssl/rsa.h> @@ -27,7 +27,7 @@ DISABLE_GCC_WARNING(redundant-decls) #include <openssl/bn.h> #include <openssl/conf.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #include "lib/log/log.h" #include "lib/encoding/binascii.h" diff --git a/src/lib/crypt_ops/crypto_util.c b/src/lib/crypt_ops/crypto_util.c index c79b4b5fee..60e81af165 100644 --- a/src/lib/crypt_ops/crypto_util.c +++ b/src/lib/crypt_ops/crypto_util.c @@ -24,10 +24,10 @@ #include <stdlib.h> #ifdef ENABLE_OPENSSL -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/err.h> #include <openssl/crypto.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #endif /* defined(ENABLE_OPENSSL) */ #include "lib/log/log.h" diff --git a/src/lib/evloop/timers.h b/src/lib/evloop/timers.h index 4243c67b73..dd55446121 100644 --- a/src/lib/evloop/timers.h +++ b/src/lib/evloop/timers.h @@ -13,6 +13,7 @@ #include "lib/testsupport/testsupport.h" struct monotime_t; +struct timeval; typedef struct timeout tor_timer_t; typedef void (*timer_cb_fn_t)(tor_timer_t *, void *, const struct monotime_t *); diff --git a/src/lib/fdio/fdio.h b/src/lib/fdio/fdio.h index 9aa6bfd796..99bc33c64b 100644 --- a/src/lib/fdio/fdio.h +++ b/src/lib/fdio/fdio.h @@ -13,6 +13,9 @@ #define TOR_FDIO_H #include <stddef.h> +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif off_t tor_fd_getpos(int fd); int tor_fd_setpos(int fd, off_t pos); diff --git a/src/lib/math/fp.c b/src/lib/math/fp.c index 1ff0a255fb..c09555209e 100644 --- a/src/lib/math/fp.c +++ b/src/lib/math/fp.c @@ -74,7 +74,7 @@ clamp_double_to_int64(double number) branches that are not taken. */ #define PROBLEMATIC_FLOAT_CONVERSION_WARNING -DISABLE_GCC_WARNING(float-conversion) +DISABLE_GCC_WARNING("-Wfloat-conversion") #endif /* (defined(MINGW_ANY)||defined(__FreeBSD__)) && GCC_VERSION >= 409 */ /* @@ -84,7 +84,7 @@ DISABLE_GCC_WARNING(float-conversion) #if defined(__clang__) #if __has_warning("-Wdouble-promotion") #define PROBLEMATIC_DOUBLE_PROMOTION_WARNING -DISABLE_GCC_WARNING(double-promotion) +DISABLE_GCC_WARNING("-Wdouble-promotion") #endif #endif /* defined(__clang__) */ @@ -115,10 +115,10 @@ DISABLE_GCC_WARNING(double-promotion) return signbit(number) ? INT64_MIN : INT64_MAX; #ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING -ENABLE_GCC_WARNING(double-promotion) +ENABLE_GCC_WARNING("-Wdouble-promotion") #endif #ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING -ENABLE_GCC_WARNING(float-conversion) +ENABLE_GCC_WARNING("-Wfloat-conversion") #endif } @@ -128,16 +128,16 @@ tor_isinf(double x) { /* Same as above, work around the "double promotion" warnings */ #ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING -DISABLE_GCC_WARNING(float-conversion) +DISABLE_GCC_WARNING("-Wfloat-conversion") #endif #ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING -DISABLE_GCC_WARNING(double-promotion) +DISABLE_GCC_WARNING("-Wdouble-promotion") #endif return isinf(x); #ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING -ENABLE_GCC_WARNING(double-promotion) +ENABLE_GCC_WARNING("-Wdouble-promotion") #endif #ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING -ENABLE_GCC_WARNING(float-conversion) +ENABLE_GCC_WARNING("-Wfloat-conversion") #endif } diff --git a/src/lib/meminfo/meminfo.c b/src/lib/meminfo/meminfo.c index c01fa33f29..0c5e0ed665 100644 --- a/src/lib/meminfo/meminfo.c +++ b/src/lib/meminfo/meminfo.c @@ -37,7 +37,7 @@ #include <sys/sysctl.h> #endif -DISABLE_GCC_WARNING(aggregate-return) +DISABLE_GCC_WARNING("-Waggregate-return") /** Call the platform malloc info function, and dump the results to the log at * level <b>severity</b>. If no such function exists, do nothing. */ void @@ -58,7 +58,7 @@ tor_log_mallinfo(int severity) (void)severity; #endif /* defined(HAVE_MALLINFO) */ } -ENABLE_GCC_WARNING(aggregate-return) +ENABLE_GCC_WARNING("-Waggregate-return") #if defined(HW_PHYSMEM64) /* OpenBSD and NetBSD define this */ diff --git a/src/lib/process/process.h b/src/lib/process/process.h index a003bf4dca..8879ec4f21 100644 --- a/src/lib/process/process.h +++ b/src/lib/process/process.h @@ -15,6 +15,8 @@ #include "lib/malloc/malloc.h" #include "lib/string/printf.h" +#include <stdbool.h> + /** Maximum number of bytes to write to a process' stdin. */ #define PROCESS_MAX_WRITE (1024) @@ -127,18 +129,19 @@ void process_notify_event_exit(process_t *process, process_exit_code_t); #ifdef PROCESS_PRIVATE -MOCK_DECL(STATIC int, process_read_stdout, (process_t *, buf_t *)); -MOCK_DECL(STATIC int, process_read_stderr, (process_t *, buf_t *)); -MOCK_DECL(STATIC void, process_write_stdin, (process_t *, buf_t *)); +struct buf_t; +MOCK_DECL(STATIC int, process_read_stdout, (process_t *, struct buf_t *)); +MOCK_DECL(STATIC int, process_read_stderr, (process_t *, struct buf_t *)); +MOCK_DECL(STATIC void, process_write_stdin, (process_t *, struct buf_t *)); STATIC void process_read_data(process_t *process, - buf_t *buffer, + struct buf_t *buffer, process_read_callback_t callback); STATIC void process_read_buffer(process_t *process, - buf_t *buffer, + struct buf_t *buffer, process_read_callback_t callback); STATIC void process_read_lines(process_t *process, - buf_t *buffer, + struct buf_t *buffer, process_read_callback_t callback); #endif /* defined(PROCESS_PRIVATE) */ diff --git a/src/lib/tls/tortls_internal.h b/src/lib/tls/tortls_internal.h index bc17012261..3f56f181ee 100644 --- a/src/lib/tls/tortls_internal.h +++ b/src/lib/tls/tortls_internal.h @@ -11,6 +11,8 @@ #ifndef TORTLS_INTERNAL_H #define TORTLS_INTERNAL_H +#include "lib/tls/x509.h" + int tor_errno_to_tls_error(int e); #ifdef ENABLE_OPENSSL int tor_tls_get_error(tor_tls_t *tls, int r, int extra, diff --git a/src/lib/tls/tortls_nss.c b/src/lib/tls/tortls_nss.c index 915a8eacff..62e8262115 100644 --- a/src/lib/tls/tortls_nss.c +++ b/src/lib/tls/tortls_nss.c @@ -34,7 +34,7 @@ #include "lib/tls/nss_countbytes.h" #include "lib/log/util_bug.h" -DISABLE_GCC_WARNING(strict-prototypes) +DISABLE_GCC_WARNING("-Wstrict-prototypes") #include <prio.h> // For access to rar sockets. #include <private/pprio.h> @@ -42,7 +42,7 @@ DISABLE_GCC_WARNING(strict-prototypes) #include <sslt.h> #include <sslproto.h> #include <certt.h> -ENABLE_GCC_WARNING(strict-prototypes) +ENABLE_GCC_WARNING("-Wstrict-prototypes") static SECStatus always_accept_cert_cb(void *, PRFileDesc *, PRBool, PRBool); diff --git a/src/lib/tls/tortls_openssl.c b/src/lib/tls/tortls_openssl.c index ad0d68e6ac..68d6e2aa50 100644 --- a/src/lib/tls/tortls_openssl.c +++ b/src/lib/tls/tortls_openssl.c @@ -37,7 +37,7 @@ /* Some versions of OpenSSL declare SSL_get_selected_srtp_profile twice in * srtp.h. Suppress the GCC warning so we can build with -Wredundant-decl. */ -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/opensslv.h> @@ -54,7 +54,7 @@ DISABLE_GCC_WARNING(redundant-decls) #include <openssl/bn.h> #include <openssl/rsa.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #include "lib/tls/tortls.h" #include "lib/tls/tortls_st.h" diff --git a/src/lib/tls/x509_openssl.c b/src/lib/tls/x509_openssl.c index 97a6c18cb4..2abf02851d 100644 --- a/src/lib/tls/x509_openssl.c +++ b/src/lib/tls/x509_openssl.c @@ -19,7 +19,7 @@ /* Some versions of OpenSSL declare SSL_get_selected_srtp_profile twice in * srtp.h. Suppress the GCC warning so we can build with -Wredundant-decl. */ -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/opensslv.h> @@ -36,7 +36,7 @@ DISABLE_GCC_WARNING(redundant-decls) #include <openssl/rsa.h> #include <openssl/x509.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #include "lib/log/log.h" #include "lib/log/util_bug.h" diff --git a/src/test/test_bt_cl.c b/src/test/test_bt_cl.c index 865876ec96..5f9a88705c 100644 --- a/src/test/test_bt_cl.c +++ b/src/test/test_bt_cl.c @@ -33,7 +33,7 @@ int a_tangled_web(int x) NOINLINE; int we_weave(int x) NOINLINE; #ifdef HAVE_CFLAG_WNULL_DEREFERENCE -DISABLE_GCC_WARNING(null-dereference) +DISABLE_GCC_WARNING("-Wnull-dereference") #endif int crash(int x) @@ -55,7 +55,7 @@ crash(int x) return crashtype; } #ifdef HAVE_CFLAG_WNULL_DEREFERENCE -ENABLE_GCC_WARNING(null-dereference) +ENABLE_GCC_WARNING("-Wnull-dereference") #endif int diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c index ee3389cfd5..63c4418f29 100644 --- a/src/test/test_circuitlist.c +++ b/src/test/test_circuitlist.c @@ -136,7 +136,7 @@ test_clist_maps(void *arg) channel_note_destroy_pending(ch2, 200); channel_note_destroy_pending(ch2, 205); channel_note_destroy_pending(ch1, 100); - tt_assert(circuit_id_in_use_on_channel(205, ch2)) + tt_assert(circuit_id_in_use_on_channel(205, ch2)); tt_assert(circuit_id_in_use_on_channel(200, ch2)); tt_assert(circuit_id_in_use_on_channel(100, ch1)); diff --git a/src/test/test_config.c b/src/test/test_config.c index 39af34b1ee..1d152ca971 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -4726,7 +4726,7 @@ test_config_parse_port_config__ports__ports_given(void *data) port_cfg = (port_cfg_t *)smartlist_get(slout, 0); tt_int_op(port_cfg->port, OP_EQ, CFG_AUTO_PORT); tor_addr_parse(&addr, "127.0.0.46"); - tt_assert(tor_addr_eq(&port_cfg->addr, &addr)) + tt_assert(tor_addr_eq(&port_cfg->addr, &addr)); // Test success with a port of auto in mixed case config_free_lines(config_port_valid); config_port_valid = NULL; @@ -4740,7 +4740,7 @@ test_config_parse_port_config__ports__ports_given(void *data) port_cfg = (port_cfg_t *)smartlist_get(slout, 0); tt_int_op(port_cfg->port, OP_EQ, CFG_AUTO_PORT); tor_addr_parse(&addr, "127.0.0.46"); - tt_assert(tor_addr_eq(&port_cfg->addr, &addr)) + tt_assert(tor_addr_eq(&port_cfg->addr, &addr)); // Test success with parsing both an address and an auto port config_free_lines(config_port_valid); config_port_valid = NULL; @@ -4754,7 +4754,7 @@ test_config_parse_port_config__ports__ports_given(void *data) port_cfg = (port_cfg_t *)smartlist_get(slout, 0); tt_int_op(port_cfg->port, OP_EQ, CFG_AUTO_PORT); tor_addr_parse(&addr, "127.0.0.122"); - tt_assert(tor_addr_eq(&port_cfg->addr, &addr)) + tt_assert(tor_addr_eq(&port_cfg->addr, &addr)); // Test failure when asked to parse an invalid address followed by auto config_free_lines(config_port_invalid); config_port_invalid = NULL; @@ -4777,7 +4777,7 @@ test_config_parse_port_config__ports__ports_given(void *data) port_cfg = (port_cfg_t *)smartlist_get(slout, 0); tt_int_op(port_cfg->port, OP_EQ, 656); tor_addr_parse(&addr, "127.0.0.123"); - tt_assert(tor_addr_eq(&port_cfg->addr, &addr)) + tt_assert(tor_addr_eq(&port_cfg->addr, &addr)); // Test failure if we can't parse anything at all config_free_lines(config_port_invalid); config_port_invalid = NULL; diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c index 00d678f4c6..46e1a19ca8 100644 --- a/src/test/test_crypto.c +++ b/src/test/test_crypto.c @@ -29,9 +29,9 @@ #if defined(ENABLE_OPENSSL) #include "lib/crypt_ops/compat_openssl.h" -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/dh.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #endif /* defined(ENABLE_OPENSSL) */ /** Run unit tests for Diffie-Hellman functionality. */ diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index 06236f8066..49034fd32c 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -55,13 +55,13 @@ #endif /* defined(_WIN32) */ #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS -DISABLE_GCC_WARNING(overlength-strings) +DISABLE_GCC_WARNING("-Woverlength-strings") /* We allow huge string constants in the unit tests, but not in the code * at large. */ #endif #include "vote_descriptors.inc" #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS -ENABLE_GCC_WARNING(overlength-strings) +ENABLE_GCC_WARNING("-Woverlength-strings") #endif #define NS_MODULE dir_handle_get @@ -258,7 +258,7 @@ test_dir_handle_get_rendezvous2_not_found_if_not_encrypted(void *data) conn = new_dir_conn(); // connection is not encrypted - tt_assert(!connection_dir_is_encrypted(conn)) + tt_assert(!connection_dir_is_encrypted(conn)); tt_int_op(directory_handle_command_get(conn, RENDEZVOUS2_GET(), NULL, 0), OP_EQ, 0); diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c index 2581411c87..f31c28b24d 100644 --- a/src/test/test_helpers.c +++ b/src/test/test_helpers.c @@ -45,14 +45,14 @@ #include "test/test_connection.h" #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS -DISABLE_GCC_WARNING(overlength-strings) +DISABLE_GCC_WARNING("-Woverlength-strings") /* We allow huge string constants in the unit tests, but not in the code * at large. */ #endif #include "test_descriptors.inc" #include "core/or/circuitlist.h" #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS -ENABLE_GCC_WARNING(overlength-strings) +ENABLE_GCC_WARNING("-Woverlength-strings") #endif /* Return a statically allocated string representing yesterday's date diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c index a022222801..43ac5490a1 100644 --- a/src/test/test_hs_descriptor.c +++ b/src/test/test_hs_descriptor.c @@ -24,12 +24,12 @@ #include "test/rng_test_helpers.h" #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS -DISABLE_GCC_WARNING(overlength-strings) +DISABLE_GCC_WARNING("-Woverlength-strings") /* We allow huge string constants in the unit tests, but not in the code * at large. */ #endif #include "test_hs_descriptor.inc" -ENABLE_GCC_WARNING(overlength-strings) +ENABLE_GCC_WARNING("-Woverlength-strings") /* Test certificate encoding put in a descriptor. */ static void diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 63c7c6f709..f89025aa6c 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -491,7 +491,7 @@ test_md_generate(void *arg) } #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS -DISABLE_GCC_WARNING(overlength-strings) +DISABLE_GCC_WARNING("-Woverlength-strings") /* We allow huge string constants in the unit tests, but not in the code * at large. */ #endif @@ -686,7 +686,7 @@ static const char MD_PARSE_TEST_DATA[] = "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n" ; #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS -ENABLE_GCC_WARNING(overlength-strings) +ENABLE_GCC_WARNING("-Woverlength-strings") #endif /** More tests for parsing different kinds of microdescriptors, and getting diff --git a/src/test/test_tortls_openssl.c b/src/test/test_tortls_openssl.c index ee66458e13..8ccad20bb0 100644 --- a/src/test/test_tortls_openssl.c +++ b/src/test/test_tortls_openssl.c @@ -16,7 +16,7 @@ /* Some versions of OpenSSL declare SSL_get_selected_srtp_profile twice in * srtp.h. Suppress the GCC warning so we can build with -Wredundant-decl. */ -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/opensslv.h> @@ -29,7 +29,7 @@ DISABLE_GCC_WARNING(redundant-decls) #include <openssl/evp.h> #include <openssl/bn.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #include "core/or/or.h" #include "lib/log/log.h" diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c index 03ed0ff1e1..e4f6530b46 100644 --- a/src/tools/tor-gencert.c +++ b/src/tools/tor-gencert.c @@ -21,7 +21,7 @@ /* Some versions of OpenSSL declare X509_STORE_CTX_set_verify_cb twice in * x509.h and x509_vfy.h. Suppress the GCC warning so we can build with * -Wredundant-decl. */ -DISABLE_GCC_WARNING(redundant-decls) +DISABLE_GCC_WARNING("-Wredundant-decls") #include <openssl/evp.h> #include <openssl/pem.h> @@ -30,7 +30,7 @@ DISABLE_GCC_WARNING(redundant-decls) #include <openssl/obj_mac.h> #include <openssl/err.h> -ENABLE_GCC_WARNING(redundant-decls) +ENABLE_GCC_WARNING("-Wredundant-decls") #endif /* defined(ENABLE_OPENSSL) */ #include <errno.h> |