aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-06-05 11:06:26 -0400
committerNick Mathewson <nickm@torproject.org>2012-06-05 11:06:26 -0400
commitb482c870ca3d70bc5611b8eb447ebbe3418bf3a9 (patch)
tree653f7663bbe2edd79880a0ddc3579dfb78ae5491
parent2468a1bd2c3a989c4225897e58b5bf09ac08ba61 (diff)
downloadtor-b482c870ca3d70bc5611b8eb447ebbe3418bf3a9.tar.gz
tor-b482c870ca3d70bc5611b8eb447ebbe3418bf3a9.zip
Fix some mingw build warnings
These include: - Having a weird in_addr that can't be initialized with {0} - Needing INVALID_HANDLE_VALUE instead of -1 for file handles. - Having a weird dependent definition for struct stat. - pid is signed, not unsigned.
-rw-r--r--src/common/address.h4
-rw-r--r--src/common/util.c5
-rw-r--r--src/common/util.h6
-rw-r--r--src/test/test.c2
-rw-r--r--src/test/test_util.c5
5 files changed, 19 insertions, 3 deletions
diff --git a/src/common/address.h b/src/common/address.h
index e942949bf2..c6c126862a 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -26,6 +26,8 @@ typedef struct tor_addr_t
{
sa_family_t family;
union {
+ uint32_t dummy_; /* This field is here so we have something to initialize
+ * with a reliable cross-platform type. */
struct in_addr in_addr;
struct in6_addr in6_addr;
} addr;
@@ -38,7 +40,7 @@ typedef struct tor_addr_port_t
uint16_t port;
} tor_addr_port_t;
-#define TOR_ADDR_NULL {AF_UNSPEC, {{0}}};
+#define TOR_ADDR_NULL {AF_UNSPEC, {0}};
static INLINE const struct in6_addr *tor_addr_to_in6(const tor_addr_t *a);
static INLINE uint32_t tor_addr_to_ipv4n(const tor_addr_t *a);
diff --git a/src/common/util.c b/src/common/util.c
index 74f8bd84b6..4c086e86fc 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -3317,7 +3317,10 @@ process_handle_new(void)
{
process_handle_t *out = tor_malloc_zero(sizeof(process_handle_t));
-#ifndef _WIN32
+#ifdef _WIN32
+ out->stdout_pipe = INVALID_HANDLE_VALUE;
+ out->stderr_pipe = INVALID_HANDLE_VALUE;
+#else
out->stdout_pipe = -1;
out->stderr_pipe = -1;
#endif
diff --git a/src/common/util.h b/src/common/util.h
index c9754418a0..527dc486f7 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -17,6 +17,10 @@
#include "di_ops.h"
#include <stdio.h>
#include <stdlib.h>
+#ifdef _WIN32
+/* for the correct alias to struct stat */
+#include <sys/stat.h>
+#endif
#ifndef O_BINARY
#define O_BINARY 0
@@ -350,7 +354,9 @@ int write_bytes_to_new_file(const char *fname, const char *str, size_t len,
/** Flag for read_file_to_str: it's okay if the file doesn't exist. */
#define RFTS_IGNORE_MISSING 2
+#ifndef _WIN32
struct stat;
+#endif
char *read_file_to_str(const char *filename, int flags, struct stat *stat_out)
ATTR_MALLOC;
const char *parse_config_line_from_str(const char *line,
diff --git a/src/test/test.c b/src/test/test.c
index 5f0b47000c..4f19f36eab 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -72,7 +72,7 @@ int have_failed = 0;
* our files during testing. */
static char temp_dir[256];
#ifdef _WIN32
-#define pid_t unsigned
+#define pid_t int
#endif
static pid_t temp_dir_setup_in_pid = 0;
diff --git a/src/test/test_util.c b/src/test/test_util.c
index bf33344039..4b628ea54d 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2274,8 +2274,13 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
test_assert(process_handle != NULL);
test_eq(expected_status, process_handle->status);
+#ifdef _WIN32
+ test_assert(process_handle->stdout_pipe != INVALID_HANDLE_VALUE);
+ test_assert(process_handle->stderr_pipe != INVALID_HANDLE_VALUE);
+#else
test_assert(process_handle->stdout_pipe > 0);
test_assert(process_handle->stderr_pipe > 0);
+#endif
/* Check stdout */
pos = tor_read_all_from_process_stdout(process_handle, stdout_buf,