[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Split some long #if lines to make the #endif annotator happy



commit 7a597718bb9cda3dd553c2b12fd42f04ead44c85
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Sep 15 16:15:27 2017 -0400

    Split some long #if lines to make the #endif annotator happy
---
 src/common/compat.c          | 22 +++++++++++++---------
 src/common/compat.h          | 10 +++++++---
 src/common/compat_libevent.c |  5 +++--
 src/common/compat_pthreads.c |  3 ++-
 src/common/compat_time.h     |  5 +++--
 src/common/util.c            |  2 +-
 src/or/connection_edge.c     |  3 ++-
 7 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/src/common/compat.c b/src/common/compat.c
index 836b3813e..38f735dcd 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -212,7 +212,8 @@ tor_rename(const char *path_old, const char *path_new)
 #define COMPAT_HAS_MMAN_AND_PAGESIZE
 #endif
 
-#if defined(COMPAT_HAS_MMAN_AND_PAGESIZE) || defined(RUNNING_DOXYGEN)
+#if defined(COMPAT_HAS_MMAN_AND_PAGESIZE) || \
+  defined(RUNNING_DOXYGEN)
 /** Try to create a memory mapping for <b>filename</b> and return it.  On
  * failure, return NULL.  Sets errno properly, using ERANGE to mean
  * "empty file". */
@@ -1316,7 +1317,8 @@ tor_accept_socket_with_extensions(tor_socket_t sockfd, struct sockaddr *addr,
     return TOR_INVALID_SOCKET;
   }
 
-#if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
+#if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) \
+  && defined(SOCK_NONBLOCK)
   int ext_flags = (cloexec ? SOCK_CLOEXEC : 0) |
                   (nonblock ? SOCK_NONBLOCK : 0);
   s = accept4(sockfd, addr, len, ext_flags);
@@ -2193,8 +2195,8 @@ switch_id(const char *user, const unsigned flags)
 
   have_already_switched_id = 1; /* mark success so we never try again */
 
-#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && defined(HAVE_PRCTL)
-#ifdef PR_SET_DUMPABLE
+#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && \
+  defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
   if (pw->pw_uid) {
     /* Re-enable core dumps if we're not running as root. */
     log_info(LD_CONFIG, "Re-enabling coredumps");
@@ -2203,7 +2205,6 @@ switch_id(const char *user, const unsigned flags)
     }
   }
 #endif
-#endif
   return 0;
 
 #else
@@ -2241,12 +2242,11 @@ tor_disable_debugger_attach(void)
   log_debug(LD_CONFIG,
             "Attemping to disable debugger attachment to Tor for "
             "unprivileged users.");
-#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && defined(HAVE_PRCTL)
-#ifdef PR_SET_DUMPABLE
+#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) \
+  && defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
   attempted = 1;
   r = prctl(PR_SET_DUMPABLE, 0);
 #endif
-#endif
 #if defined(__APPLE__) && defined(PT_DENY_ATTACH)
   if (r < 0) {
     attempted = 1;
@@ -3050,6 +3050,10 @@ tor_gmtime_r(const time_t *timep, struct tm *result)
 #endif
 
 #if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
+#define HAVE_UNIX_MLOCKALL
+#endif
+
+#ifdef HAVE_UNIX_MLOCKALL
 /** Attempt to raise the current and max rlimit to infinity for our process.
  * This only needs to be done once and can probably only be done when we have
  * not already dropped privileges.
@@ -3105,7 +3109,7 @@ tor_mlockall(void)
    * http://msdn.microsoft.com/en-us/library/aa366895(VS.85).aspx
    */
 
-#if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
+#ifdef HAVE_UNIX_MLOCKALL
   if (tor_set_max_memlock() == 0) {
     log_debug(LD_GENERAL, "RLIMIT_MEMLOCK is now set to RLIM_INFINITY.");
   }
diff --git a/src/common/compat.h b/src/common/compat.h
index 473ad2b95..0b0c75bc5 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -281,7 +281,11 @@ size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
 #define I64_LITERAL(n) (n ## ll)
 #endif
 
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(__MINGW32__) || defined(__MINGW64__)
+#define MINGW_ANY
+#endif
+
+#if defined(_MSC_VER) || defined(MINGW_ANY)
 /** The formatting string used to put a uint64_t value in a printf() or
  * scanf() function.  See also U64_PRINTF_ARG and U64_SCANF_ARG. */
 #define U64_FORMAT "%I64u"
@@ -526,8 +530,8 @@ struct in6_addr
 
 /** @{ */
 /** Many BSD variants seem not to define these. */
-#if defined(__APPLE__) || defined(__darwin__) || defined(__FreeBSD__) \
-    || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__APPLE__) || defined(__darwin__) || \
+  defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
 #ifndef s6_addr16
 #define s6_addr16 __u6_addr.__u6_addr16
 #endif
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 31eb4ac49..df61a7d8e 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -237,8 +237,9 @@ tor_init_libevent_rng(void)
   return rv;
 }
 
-#if defined(LIBEVENT_VERSION_NUMBER) && LIBEVENT_VERSION_NUMBER >= V(2,1,1) \
-  && !defined(TOR_UNIT_TESTS)
+#if defined(LIBEVENT_VERSION_NUMBER) &&         \
+  LIBEVENT_VERSION_NUMBER >= V(2,1,1) &&        \
+  !defined(TOR_UNIT_TESTS)
 void
 tor_gettimeofday_cached(struct timeval *tv)
 {
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c
index 8e4b83357..f50f5d1f3 100644
--- a/src/common/compat_pthreads.c
+++ b/src/common/compat_pthreads.c
@@ -201,7 +201,8 @@ tor_cond_init(tor_cond_t *cond)
   }
 
 #if defined(HAVE_CLOCK_GETTIME)
-#if defined(CLOCK_MONOTONIC) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK)
+#if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && \
+  defined(CLOCK_MONOTONIC)
   /* Use monotonic time so when we timedwait() on it, any clock adjustment
    * won't affect the timeout value. */
   if (pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC)) {
diff --git a/src/common/compat_time.h b/src/common/compat_time.h
index 90194c5eb..e5181beac 100644
--- a/src/common/compat_time.h
+++ b/src/common/compat_time.h
@@ -28,7 +28,7 @@
 #include <time.h>
 #endif
 
-#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
+#if !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
 /** Implementation of timeval for platforms that don't have it. */
 struct timeval {
   time_t tv_sec;
@@ -54,7 +54,8 @@ typedef struct monotime_t {
 #endif
 } monotime_t;
 
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC_COARSE)
+#if defined(CLOCK_MONOTONIC_COARSE) && \
+  defined(HAVE_CLOCK_GETTIME)
 #define MONOTIME_COARSE_FN_IS_DIFFERENT
 #define monotime_coarse_t monotime_t
 #elif defined(_WIN32)
diff --git a/src/common/util.c b/src/common/util.c
index 788d2501b..2092fab28 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -5623,7 +5623,7 @@ clamp_double_to_int64(double number)
 {
   int exponent;
 
-#if (defined(__MINGW32__) || defined(__MINGW64__)) && GCC_VERSION >= 409
+#if defined(MINGW_ANY) && GCC_VERSION >= 409
 /*
   Mingw's math.h uses gcc's __builtin_choose_expr() facility to declare
   isnan, isfinite, and signbit.  But as implemented in at least some
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 94a9f5fc3..8bb2af322 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -2079,7 +2079,8 @@ get_pf_socket(void)
 }
 #endif
 
-#if defined(TRANS_NETFILTER) || defined(TRANS_PF) || defined(TRANS_TPROXY)
+#if defined(TRANS_NETFILTER) || defined(TRANS_PF) || \
+  defined(TRANS_TPROXY)
 /** Try fill in the address of <b>req</b> from the socket configured
  * with <b>conn</b>. */
 static int



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits