aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-15 16:15:27 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-15 16:24:21 -0400
commit7a597718bb9cda3dd553c2b12fd42f04ead44c85 (patch)
tree4f469c213ce1a688c8bf4c8f6874823117e705f9 /src/common/compat.c
parent40ce9819dd7c589f624715c9c800cff714140a70 (diff)
downloadtor-7a597718bb9cda3dd553c2b12fd42f04ead44c85.tar.gz
tor-7a597718bb9cda3dd553c2b12fd42f04ead44c85.zip
Split some long #if lines to make the #endif annotator happy
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 836b3813e0..38f735dcd5 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.");
}