]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix some mingw build warnings
authorNick Mathewson <nickm@torproject.org>
Tue, 5 Jun 2012 15:06:26 +0000 (11:06 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 5 Jun 2012 15:06:26 +0000 (11:06 -0400)
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
src/common/util.c
src/common/util.h
src/test/test.c
src/test/test_util.c

index e942949bf2c8a6fa058cccf3aa37c9b326e4ea6f..c6c126862a7055b0a32a81cd775a4c15b744222a 100644 (file)
@@ -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);
index 74f8bd84b628096a6376f2a62da4e19247a43bd3..4c086e86fce6d93ea5bd249727923809f8f0c97b 100644 (file)
@@ -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
index c9754418a040ec2ba79845bfa7ca46648a30fbb5..527dc486f7f3a2cac1f77df6faa732e6d571536d 100644 (file)
 #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,
index 5f0b47000c56e10c259927fdee96b12d72e1ae51..4f19f36eab8fc1660ba203f9cdb0efdebaf7ec0f 100644 (file)
@@ -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;
 
index bf33344039b30a0e22370ed7226c8e19e8663506..4b628ea54d1a2de7aac7cf0b0fdf2e0818b483db 100644 (file)
@@ -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,