aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat_pthreads.c11
-rw-r--r--src/common/crypto.c4
-rw-r--r--src/common/include.am8
-rw-r--r--src/common/log.c14
-rw-r--r--src/common/tortls.c4
-rw-r--r--src/common/util.c10
-rw-r--r--src/common/util.h1
7 files changed, 28 insertions, 24 deletions
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c
index 246076b276..fdc504690b 100644
--- a/src/common/compat_pthreads.c
+++ b/src/common/compat_pthreads.c
@@ -91,10 +91,9 @@ static pthread_mutexattr_t attr_recursive;
void
tor_mutex_init(tor_mutex_t *mutex)
{
- int err;
if (PREDICT_UNLIKELY(!threads_initialized))
tor_threads_init();
- err = pthread_mutex_init(&mutex->mutex, &attr_recursive);
+ const int err = pthread_mutex_init(&mutex->mutex, &attr_recursive);
if (PREDICT_UNLIKELY(err)) {
log_err(LD_GENERAL, "Error %d creating a mutex.", err);
tor_fragile_assert();
@@ -278,12 +277,14 @@ tor_threads_init(void)
if (!threads_initialized) {
pthread_mutexattr_init(&attr_recursive);
pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE);
- tor_assert(0==pthread_attr_init(&attr_detached));
+ const int ret1 = pthread_attr_init(&attr_detached);
+ tor_assert(ret1 == 0);
#ifndef PTHREAD_CREATE_DETACHED
#define PTHREAD_CREATE_DETACHED 1
#endif
- tor_assert(0==pthread_attr_setdetachstate(&attr_detached,
- PTHREAD_CREATE_DETACHED));
+ const int ret2 =
+ pthread_attr_setdetachstate(&attr_detached, PTHREAD_CREATE_DETACHED);
+ tor_assert(ret2 == 0);
threads_initialized = 1;
set_main_thread();
}
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 218c7bea1e..91c4025ac2 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -51,9 +51,9 @@
#define CRYPTO_PRIVATE
#include "crypto.h"
-#include "../common/torlog.h"
+#include "torlog.h"
#include "aes.h"
-#include "../common/util.h"
+#include "util.h"
#include "container.h"
#include "compat.h"
#include "sandbox.h"
diff --git a/src/common/include.am b/src/common/include.am
index 5b63392541..ec4893594b 100644
--- a/src/common/include.am
+++ b/src/common/include.am
@@ -11,9 +11,7 @@ noinst_LIBRARIES += \
src/common/libor-event-testing.a
endif
-EXTRA_DIST+= \
- src/common/common_sha1.i \
- src/common/Makefile.nmake
+EXTRA_DIST += src/common/Makefile.nmake
#CFLAGS = -Wall -Wpointer-arith -O2
AM_CPPFLAGS += -I$(srcdir)/src/common -Isrc/common -I$(srcdir)/src/ext/trunnel -I$(srcdir)/src/trunnel
@@ -72,6 +70,8 @@ LIBOR_A_SOURCES = \
$(libor_extra_source) \
$(threads_impl_source)
+src/common/log.o: micro-revision.i
+
LIBOR_CRYPTO_A_SOURCES = \
src/common/aes.c \
src/common/crypto.c \
@@ -133,7 +133,7 @@ COMMONHEADERS = \
noinst_HEADERS+= $(COMMONHEADERS)
-DISTCLEANFILES+= src/common/common_sha1.i
+CLEANFILES+= src/common/common_sha1.i
src/common/common_sha1.i: $(libor_SOURCES) $(libor_crypto_a_SOURCES) $(COMMONHEADERS)
$(AM_V_GEN)if test "@SHA1SUM@" != none; then \
diff --git a/src/common/log.c b/src/common/log.c
index e8cc30c312..396eb6b0e8 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -263,6 +263,13 @@ log_tor_version(logfile_t *lf, int reset)
return 0;
}
+const char bug_suffix[] = " (on Tor " VERSION
+#ifndef _MSC_VER
+ " "
+#include "micro-revision.i"
+#endif
+ ")";
+
/** Helper: Format a log message into a fixed-sized buffer. (This is
* factored out of <b>logv</b> so that we never format a message more
* than once.) Return a pointer to the first character of the message
@@ -341,6 +348,13 @@ format_msg(char *buf, size_t buf_len,
}
}
}
+
+ if (domain == LD_BUG &&
+ buf_len - n > strlen(bug_suffix)+1) {
+ memcpy(buf+n, bug_suffix, strlen(bug_suffix));
+ n += strlen(bug_suffix);
+ }
+
buf[n]='\n';
buf[n+1]='\0';
*msg_len_out = n+1;
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 97a82bf6e1..32106eb2df 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -789,7 +789,7 @@ const char UNRESTRICTED_SERVER_CIPHER_LIST[] =
/** List of ciphers that clients should advertise, omitting items that
* our OpenSSL doesn't know about. */
static const char CLIENT_CIPHER_LIST[] =
-#include "./ciphers.inc"
+#include "ciphers.inc"
/* Tell it not to use SSLv2 ciphers, so that it can select an SSLv3 version
* of any cipher we say. */
"!SSLv2"
@@ -804,7 +804,7 @@ typedef struct cipher_info_t { unsigned id; const char *name; } cipher_info_t;
static const cipher_info_t CLIENT_CIPHER_INFO_LIST[] = {
#define CIPHER(id, name) { id, name },
#define XCIPHER(id, name) { id, #name },
-#include "./ciphers.inc"
+#include "ciphers.inc"
#undef CIPHER
#undef XCIPHER
};
diff --git a/src/common/util.c b/src/common/util.c
index 442d57a2cf..2c3a1a1019 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -771,16 +771,6 @@ fast_memcmpstart(const void *mem, size_t memlen,
return fast_memcmp(mem, prefix, plen);
}
-/** Given a nul-terminated string s, set every character before the nul
- * to zero. */
-void
-tor_strclear(char *s)
-{
- while (*s) {
- *s++ = '\0';
- }
-}
-
/** Return a pointer to the first char of s that is not whitespace and
* not a comment, or to the terminating NUL if no such character exists.
*/
diff --git a/src/common/util.h b/src/common/util.h
index ea774bd9bd..783c2a13db 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -209,7 +209,6 @@ int strcasecmpstart(const char *s1, const char *s2) ATTR_NONNULL((1,2));
int strcmpend(const char *s1, const char *s2) ATTR_NONNULL((1,2));
int strcasecmpend(const char *s1, const char *s2) ATTR_NONNULL((1,2));
int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
-void tor_strclear(char *s);
void tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2));
long tor_parse_long(const char *s, int base, long min,