[tor-commits] [tor/master] Turn several functions from stubs into macros

nickm at torproject.org nickm at torproject.org
Fri Jan 17 12:51:00 UTC 2020


commit 5cff1ce84bf11d0a3abbfdda30dd3b96ce298c6b
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Jan 15 12:30:43 2020 -0500

    Turn several functions from stubs into macros
    
    This may help the compiler eliminate deadcode.
---
 src/feature/dircache/dircache_stub.c | 44 ------------------------------------
 src/feature/dircache/dirserv.h       | 22 +++++++++++++++++-
 2 files changed, 21 insertions(+), 45 deletions(-)

diff --git a/src/feature/dircache/dircache_stub.c b/src/feature/dircache/dircache_stub.c
index f6804dad7..87811597d 100644
--- a/src/feature/dircache/dircache_stub.c
+++ b/src/feature/dircache/dircache_stub.c
@@ -30,34 +30,6 @@ connection_dirserv_flushed_some(dir_connection_t *conn)
   return -1;
 }
 
-int
-directory_caches_unknown_auth_certs(const or_options_t *options)
-{
-  (void) options;
-  return 0;
-}
-
-int
-directory_caches_dir_info(const or_options_t *options)
-{
-  (void) options;
-  return 0;
-}
-
-int
-directory_permits_begindir_requests(const or_options_t *options)
-{
-  (void) options;
-  return 0;
-}
-
-cached_dir_t *
-dirserv_get_consensus(const char *flavor_name)
-{
-  (void) flavor_name;
-  return NULL;
-}
-
 void
 dir_conn_clear_spool(dir_connection_t *conn)
 {
@@ -71,22 +43,6 @@ consdiffmgr_enable_background_compression(void)
 {
 }
 
-void
-dirserv_set_cached_consensus_networkstatus(const char *networkstatus,
-                                           size_t networkstatus_len,
-                                           const char *flavor_name,
-                                           const common_digests_t *digests,
-                                           const uint8_t *sha3_as_signed,
-                                           time_t published)
-{
-  (void)networkstatus;
-  (void)networkstatus_len;
-  (void)flavor_name;
-  (void)digests;
-  (void)sha3_as_signed;
-  (void)published;
-}
-
 int
 consdiffmgr_add_consensus(const char *consensus,
                           size_t consensus_len,
diff --git a/src/feature/dircache/dirserv.h b/src/feature/dircache/dirserv.h
index 29c5b9ad2..a892d9ff8 100644
--- a/src/feature/dircache/dirserv.h
+++ b/src/feature/dircache/dirserv.h
@@ -80,10 +80,10 @@ int dir_split_resource_into_spoolable(const char *resource,
                                       int *compressed_out,
                                       int flags);
 
+#ifdef HAVE_MODULE_DIRCACHE
 int directory_caches_unknown_auth_certs(const or_options_t *options);
 int directory_caches_dir_info(const or_options_t *options);
 int directory_permits_begindir_requests(const or_options_t *options);
-
 MOCK_DECL(cached_dir_t *, dirserv_get_consensus, (const char *flavor_name));
 void dirserv_set_cached_consensus_networkstatus(const char *consensus,
                                               size_t consensus_len,
@@ -91,6 +91,26 @@ void dirserv_set_cached_consensus_networkstatus(const char *consensus,
                                               const common_digests_t *digests,
                                               const uint8_t *sha3_as_signed,
                                               time_t published);
+#else
+#define directory_caches_unknown_auth_certs(opt) \
+  ((void)(opt), 0)
+#define directory_caches_dir_info(opt) \
+  ((void)(opt), 0)
+#define directory_permits_begindir_requests(opt) \
+  ((void)(opt), 0)
+#define dirserv_get_consensus(flav) \
+  ((void)(flav), NULL)
+#define dirserv_set_cached_consensus_networkstatus(a,b,c,d,e,f) \
+  STMT_BEGIN {                                                  \
+    (void)(a);                                                  \
+    (void)(b);                                                  \
+    (void)(c);                                                  \
+    (void)(d);                                                  \
+    (void)(e);                                                  \
+    (void)(f);                                                  \
+  } STMT_END
+#endif
+
 void dirserv_clear_old_networkstatuses(time_t cutoff);
 int dirserv_get_routerdesc_spool(smartlist_t *spools_out, const char *key,
                                  dir_spool_source_t source,





More information about the tor-commits mailing list