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]
This commit is contained in:
Nick Mathewson
2014-09-09 12:08:03 -04:00
parent 409a56281e
commit 1eea7a68ed
5 changed files with 21 additions and 19 deletions
+2
View File
@@ -0,0 +1,2 @@
o Code refactoring:
- Use the standard macro name SIZE_MAX, instead of our own SIZE_T_MAX.
+3 -3
View File
@@ -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
+10 -10
View File
@@ -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 */
+4 -4
View File
@@ -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) {
+2 -2
View File
@@ -58,7 +58,7 @@
#include <limits.h>
#include <errno.h>
#include <err.h>
/* 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 *