From 1eea7a68ed1534493ba2def4e2086fe8d9046e74 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 9 Sep 2014 12:08:03 -0400 Subject: Use S?SIZE_MAX, not S?SIZE_T_MAX This fixes bug 13102 (not on any released Tor) where using the standard SSIZE_MAX name broke mingw64, and we didn't realize. I did this with perl -i -pe 's/SIZE_T_MAX/SIZE_MAX/' src/*/*.[ch] src/*/*/*.[ch] --- src/common/compat.c | 6 +++--- src/common/torint.h | 20 ++++++++++---------- src/common/util.c | 8 ++++---- src/ext/OpenBSD_malloc_Linux.c | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/common/compat.c b/src/common/compat.c index ad627f13f3..4dd04455a2 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -3566,12 +3566,12 @@ get_total_system_memory(size_t *mem_out) return 0; } -#if SIZE_T_MAX != UINT64_MAX - if (m > SIZE_T_MAX) { +#if SIZE_MAX != UINT64_MAX + if (m > SIZE_MAX) { /* I think this could happen if we're a 32-bit Tor running on a 64-bit * system: we could have more system memory than would fit in a * size_t. */ - m = SIZE_T_MAX; + m = SIZE_MAX; } #endif diff --git a/src/common/torint.h b/src/common/torint.h index a993d7649a..b46f306668 100644 --- a/src/common/torint.h +++ b/src/common/torint.h @@ -332,30 +332,30 @@ typedef uint32_t uintptr_t; #endif /* time_t_is_signed */ #endif /* ifndef(TIME_MAX) */ -#ifndef SIZE_T_MAX +#ifndef SIZE_MAX #if (SIZEOF_SIZE_T == 4) -#define SIZE_T_MAX UINT32_MAX +#define SIZE_MAX UINT32_MAX #elif (SIZEOF_SIZE_T == 8) -#define SIZE_T_MAX UINT64_MAX +#define SIZE_MAX UINT64_MAX #else -#error "Can't define SIZE_T_MAX" +#error "Can't define SIZE_MAX" #endif #endif -#ifndef SSIZE_T_MAX +#ifndef SSIZE_MAX #if (SIZEOF_SIZE_T == 4) -#define SSIZE_T_MAX INT32_MAX +#define SSIZE_MAX INT32_MAX #elif (SIZEOF_SIZE_T == 8) -#define SSIZE_T_MAX INT64_MAX +#define SSIZE_MAX INT64_MAX #else -#error "Can't define SSIZE_T_MAX" +#error "Can't define SSIZE_MAX" #endif #endif /** Any ssize_t larger than this amount is likely to be an underflow. */ -#define SSIZE_T_CEILING ((ssize_t)(SSIZE_T_MAX-16)) +#define SSIZE_T_CEILING ((ssize_t)(SSIZE_MAX-16)) /** Any size_t larger than this amount is likely to be an underflow. */ -#define SIZE_T_CEILING ((size_t)(SSIZE_T_MAX-16)) +#define SIZE_T_CEILING ((size_t)(SSIZE_MAX-16)) #endif /* __TORINT_H */ diff --git a/src/common/util.c b/src/common/util.c index 75dd6ed7f6..97cedd519d 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1786,7 +1786,7 @@ write_all(tor_socket_t fd, const char *buf, size_t count, int isSocket) { size_t written = 0; ssize_t result; - tor_assert(count < SSIZE_T_MAX); + tor_assert(count < SSIZE_MAX); while (written != count) { if (isSocket) @@ -1811,7 +1811,7 @@ read_all(tor_socket_t fd, char *buf, size_t count, int isSocket) size_t numread = 0; ssize_t result; - if (count > SIZE_T_CEILING || count > SSIZE_T_MAX) + if (count > SIZE_T_CEILING || count > SSIZE_MAX) return -1; while (numread != count) { @@ -4409,7 +4409,7 @@ tor_read_all_handle(HANDLE h, char *buf, size_t count, DWORD byte_count; BOOL process_exited = FALSE; - if (count > SIZE_T_CEILING || count > SSIZE_T_MAX) + if (count > SIZE_T_CEILING || count > SSIZE_MAX) return -1; while (numread != count) { @@ -4475,7 +4475,7 @@ tor_read_all_handle(FILE *h, char *buf, size_t count, if (eof) *eof = 0; - if (count > SIZE_T_CEILING || count > SSIZE_T_MAX) + if (count > SIZE_T_CEILING || count > SSIZE_MAX) return -1; while (numread != count) { diff --git a/src/ext/OpenBSD_malloc_Linux.c b/src/ext/OpenBSD_malloc_Linux.c index da82729811..e296a77be9 100644 --- a/src/ext/OpenBSD_malloc_Linux.c +++ b/src/ext/OpenBSD_malloc_Linux.c @@ -58,7 +58,7 @@ #include #include #include -/* For SIZE_T_MAX */ +/* For SIZE_MAX */ #include "torint.h" //#include "thread_private.h" @@ -1968,7 +1968,7 @@ realloc(void *ptr, size_t size) //#if defined(__x86_64__) //#define SIZE_MAX 0xffffffffffffffff //#endif -#define SIZE_MAX SIZE_T_MAX +#define SIZE_MAX SIZE_MAX #endif void * -- cgit v1.2.3-54-g00ecf