aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Makefile.nmake5
-rw-r--r--src/common/compat.h12
-rw-r--r--src/common/crypto.c2
-rw-r--r--src/common/torint.h4
-rw-r--r--src/common/tortls.c15
-rw-r--r--src/common/util.c3
6 files changed, 31 insertions, 10 deletions
diff --git a/src/common/Makefile.nmake b/src/common/Makefile.nmake
index e54827367..9672f4fe9 100644
--- a/src/common/Makefile.nmake
+++ b/src/common/Makefile.nmake
@@ -1,6 +1,6 @@
all: libor.lib libor-crypto.lib libor-event.lib
-CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include
+CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\ext
LIBOR_OBJECTS = address.obj compat.obj container.obj di_ops.obj \
log.obj memarea.obj mempool.obj procmon.obj util.obj \
@@ -18,3 +18,6 @@ libor-crypto.lib: $(LIBOR_CRYPTO_OBJECTS)
libor-event.lib: $(LIBOR_EVENT_OBJECTS)
lib $(LIBOR_EVENT_OBJECTS) /out:libor-event.lib
+
+clean:
+ del *.obj *.lib libor*.lib
diff --git a/src/common/compat.h b/src/common/compat.h
index 5fbfd59cd..25293a4ed 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -60,7 +60,6 @@
#include <io.h>
#include <math.h>
#include <projects.h>
-#define snprintf _snprintf
/* this is not exported as W .... */
#define SHGetPathFromIDListW SHGetPathFromIDList
/* wcecompat has vasprintf */
@@ -133,6 +132,17 @@ extern INLINE double U64_TO_DBL(uint64_t x) {
#define DBL_TO_U64(x) ((uint64_t) (x))
#endif
+#if defined(_MSC_VER)
+/* XXXX024 we should instead have a more general check for "Is enum signed?"*/
+#define ENUM_BF(t) unsigned
+#else
+/** Wrapper for having a bitfield of an enumerated type. Where possible, we
+ * just use the enumerated type (so the compiler can help us and notice
+ * problems), but if enumerated types are unsigned, we must use unsigned,
+ * so that the loss of precision doesn't make large values negative. */
+#define ENUM_BF(t) t
+#endif
+
/* GCC has several useful attributes. */
#if defined(__GNUC__) && __GNUC__ >= 3
#define ATTR_NORETURN __attribute__((noreturn))
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 1403ba61d..672ab2d55 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1505,7 +1505,7 @@ struct crypto_digest_t {
SHA256_CTX sha2; /**< state for SHA256 */
} d; /**< State for the digest we're using. Only one member of the
* union is usable, depending on the value of <b>algorithm</b>. */
- digest_algorithm_t algorithm : 8; /**< Which algorithm is in use? */
+ ENUM_BF(digest_algorithm_t) algorithm : 8; /**< Which algorithm is in use? */
};
/** Allocate and return a new digest object to compute SHA1 digests.
diff --git a/src/common/torint.h b/src/common/torint.h
index 8681eb745..a993d7649 100644
--- a/src/common/torint.h
+++ b/src/common/torint.h
@@ -214,16 +214,20 @@ typedef int32_t ssize_t;
#if (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8)
#ifndef HAVE_INTPTR_T
typedef int64_t intptr_t;
+#define SIZEOF_INTPTR_T 8
#endif
#ifndef HAVE_UINTPTR_T
typedef uint64_t uintptr_t;
+#define SIZEOF_UINTPTR_T 8
#endif
#elif (SIZEOF_VOID_P > 2 && SIZEOF_VOID_P <= 4)
#ifndef HAVE_INTPTR_T
typedef int32_t intptr_t;
+#define SIZEOF_INTPTR_T 4
#endif
#ifndef HAVE_UINTPTR_T
typedef uint32_t uintptr_t;
+#define SIZEOF_UINTPTR_T 4
#endif
#else
#error "void * is either >8 bytes or <= 2. In either case, I am confused."
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 1d093dfcb..251915d98 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -147,6 +147,12 @@ typedef struct tor_tls_context_t {
#define TOR_TLS_MAGIC 0x71571571
+typedef enum {
+ TOR_TLS_ST_HANDSHAKE, TOR_TLS_ST_OPEN, TOR_TLS_ST_GOTCLOSE,
+ TOR_TLS_ST_SENTCLOSE, TOR_TLS_ST_CLOSED, TOR_TLS_ST_RENEGOTIATE,
+ TOR_TLS_ST_BUFFEREVENT
+} tor_tls_state_t;
+
/** Holds a SSL object and its associated data. Members are only
* accessed from within tortls.c.
*/
@@ -156,12 +162,9 @@ struct tor_tls_t {
SSL *ssl; /**< An OpenSSL SSL object. */
int socket; /**< The underlying file descriptor for this TLS connection. */
char *address; /**< An address to log when describing this connection. */
- enum {
- TOR_TLS_ST_HANDSHAKE, TOR_TLS_ST_OPEN, TOR_TLS_ST_GOTCLOSE,
- TOR_TLS_ST_SENTCLOSE, TOR_TLS_ST_CLOSED, TOR_TLS_ST_RENEGOTIATE,
- TOR_TLS_ST_BUFFEREVENT
- } state : 3; /**< The current SSL state, depending on which operations have
- * completed successfully. */
+ ENUM_BF(tor_tls_state_t) state : 3; /**< The current SSL state,
+ * depending on which operations
+ * have completed successfully. */
unsigned int isServer:1; /**< True iff this is a server-side connection */
unsigned int wasV2Handshake:1; /**< True iff the original handshake for
* this connection used the updated version
diff --git a/src/common/util.c b/src/common/util.c
index 5d2135411..49ec75dc4 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -4919,7 +4919,8 @@ tor_check_port_forwarding(const char *filename,
status = tor_spawn_background(filename, argv, NULL, &child_handle);
#endif
- tor_free(argv);
+ tor_free_((void*)argv);
+ argv=NULL;
if (PROCESS_STATUS_ERROR == status) {
log_warn(LD_GENERAL, "Failed to start port forwarding helper %s",