[tor-commits] [tor/master] Fix some mingw build warnings
nickm at torproject.org
nickm at torproject.org
Tue Jun 5 15:15:40 UTC 2012
commit b482c870ca3d70bc5611b8eb447ebbe3418bf3a9
Author: Nick Mathewson <nickm at torproject.org>
Date: Tue Jun 5 11:06:26 2012 -0400
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.
---
src/common/address.h | 4 +++-
src/common/util.c | 5 ++++-
src/common/util.h | 6 ++++++
src/test/test.c | 2 +-
src/test/test_util.c | 5 +++++
5 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/common/address.h b/src/common/address.h
index e942949..c6c1268 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 74f8bd8..4c086e8 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 c975441..527dc48 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 5f0b470..4f19f36 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 bf33344..4b628ea 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,
More information about the tor-commits
mailing list