mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
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.
This commit is contained in:
parent
2468a1bd2c
commit
b482c870ca
@ -26,6 +26,8 @@ typedef struct tor_addr_t
|
|||||||
{
|
{
|
||||||
sa_family_t family;
|
sa_family_t family;
|
||||||
union {
|
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 in_addr in_addr;
|
||||||
struct in6_addr in6_addr;
|
struct in6_addr in6_addr;
|
||||||
} addr;
|
} addr;
|
||||||
@ -38,7 +40,7 @@ typedef struct tor_addr_port_t
|
|||||||
uint16_t port;
|
uint16_t port;
|
||||||
} tor_addr_port_t;
|
} 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 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);
|
static INLINE uint32_t tor_addr_to_ipv4n(const tor_addr_t *a);
|
||||||
|
@ -3317,7 +3317,10 @@ process_handle_new(void)
|
|||||||
{
|
{
|
||||||
process_handle_t *out = tor_malloc_zero(sizeof(process_handle_t));
|
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->stdout_pipe = -1;
|
||||||
out->stderr_pipe = -1;
|
out->stderr_pipe = -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
#include "di_ops.h"
|
#include "di_ops.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* for the correct alias to struct stat */
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
#define O_BINARY 0
|
#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. */
|
/** Flag for read_file_to_str: it's okay if the file doesn't exist. */
|
||||||
#define RFTS_IGNORE_MISSING 2
|
#define RFTS_IGNORE_MISSING 2
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
struct stat;
|
struct stat;
|
||||||
|
#endif
|
||||||
char *read_file_to_str(const char *filename, int flags, struct stat *stat_out)
|
char *read_file_to_str(const char *filename, int flags, struct stat *stat_out)
|
||||||
ATTR_MALLOC;
|
ATTR_MALLOC;
|
||||||
const char *parse_config_line_from_str(const char *line,
|
const char *parse_config_line_from_str(const char *line,
|
||||||
|
@ -72,7 +72,7 @@ int have_failed = 0;
|
|||||||
* our files during testing. */
|
* our files during testing. */
|
||||||
static char temp_dir[256];
|
static char temp_dir[256];
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define pid_t unsigned
|
#define pid_t int
|
||||||
#endif
|
#endif
|
||||||
static pid_t temp_dir_setup_in_pid = 0;
|
static pid_t temp_dir_setup_in_pid = 0;
|
||||||
|
|
||||||
|
@ -2274,8 +2274,13 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
|
|||||||
test_assert(process_handle != NULL);
|
test_assert(process_handle != NULL);
|
||||||
test_eq(expected_status, process_handle->status);
|
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->stdout_pipe > 0);
|
||||||
test_assert(process_handle->stderr_pipe > 0);
|
test_assert(process_handle->stderr_pipe > 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check stdout */
|
/* Check stdout */
|
||||||
pos = tor_read_all_from_process_stdout(process_handle, stdout_buf,
|
pos = tor_read_all_from_process_stdout(process_handle, stdout_buf,
|
||||||
|
Loading…
Reference in New Issue
Block a user