Fri, 26 Feb 2016 16:33:04 +0100
fixed further usages of SIZE_MAX
test/buffer_tests.c | file | annotate | diff | comparison | revisions | |
ucx/avl.h | file | annotate | diff | comparison | revisions | |
ucx/utils.h | file | annotate | diff | comparison | revisions |
1.1 --- a/test/buffer_tests.c Fri Feb 26 16:22:20 2016 +0100 1.2 +++ b/test/buffer_tests.c Fri Feb 26 16:33:04 2016 +0100 1.3 @@ -27,7 +27,6 @@ 1.4 */ 1.5 1.6 #include "buffer_tests.h" 1.7 -#include <stdint.h> 1.8 1.9 UCX_TEST(test_ucx_buffer_new) { 1.10 UcxBuffer *b = ucx_buffer_new(NULL, 16, UCX_BUFFER_AUTOEXTEND); 1.11 @@ -88,7 +87,8 @@ 1.12 int r; 1.13 1.14 UCX_TEST_BEGIN 1.15 - size_t bigpos = SIZE_MAX - 5000; 1.16 + const size_t sizemax = (size_t)-1; 1.17 + size_t bigpos = sizemax - 5000; 1.18 b->pos = bigpos; 1.19 r = ucx_buffer_seek(b, 5016, SEEK_CUR); 1.20 UCX_TEST_ASSERT(r != 0, "seek cur overflow"); 1.21 @@ -96,8 +96,8 @@ 1.22 "failed seek shall leave pos unchanged"); 1.23 1.24 b->pos = 0; 1.25 - b->size = SIZE_MAX / 2 + 32; 1.26 - off_t bigoff = SIZE_MAX / 2 - 16; 1.27 + b->size = sizemax / 2 + 32; 1.28 + off_t bigoff = sizemax / 2 - 16; 1.29 r = ucx_buffer_seek(b, -bigoff, SEEK_CUR); 1.30 UCX_TEST_ASSERT(r != 0, "seek cur underflow"); 1.31 UCX_TEST_ASSERT(b->pos == 0, 1.32 @@ -593,7 +593,7 @@ 1.33 UCX_TEST_ASSERT((b->size == 0 && b->pos == 0), 1.34 "pos and size shall remain unchanged"); 1.35 1.36 - UCX_TEST_ASSERT(ucx_buffer_extend(b, SIZE_MAX - 60) != 0, 1.37 + UCX_TEST_ASSERT(ucx_buffer_extend(b, (size_t) - 61) != 0, 1.38 "shall fail and return a non-zero value on overflow"); 1.39 1.40 UCX_TEST_END
2.1 --- a/ucx/avl.h Fri Feb 26 16:22:20 2016 +0100 2.2 +++ b/ucx/avl.h Fri Feb 26 16:33:04 2016 +0100 2.3 @@ -44,7 +44,7 @@ 2.4 2.5 #include "ucx.h" 2.6 #include "allocator.h" 2.7 -#include <stdint.h> 2.8 +#include <inttypes.h> 2.9 2.10 #ifdef __cplusplus 2.11 extern "C" {
3.1 --- a/ucx/utils.h Fri Feb 26 16:22:20 2016 +0100 3.2 +++ b/ucx/utils.h Fri Feb 26 16:33:04 2016 +0100 3.3 @@ -45,7 +45,7 @@ 3.4 #include "ucx.h" 3.5 #include "string.h" 3.6 #include "allocator.h" 3.7 -#include <stdint.h> 3.8 +#include <inttypes.h> 3.9 #include <string.h> 3.10 #include <stdarg.h> 3.11 3.12 @@ -95,7 +95,7 @@ 3.13 * @return total number of bytes copied 3.14 */ 3.15 #define ucx_stream_hcopy(src,dest,rfnc,wfnc) ucx_stream_copy(\ 3.16 - src, dest, (read_func)rfnc, (write_func)wfnc, NULL, 0x100, SIZE_MAX) 3.17 + src, dest, (read_func)rfnc, (write_func)wfnc, NULL, 0x100, (size_t)-1) 3.18 3.19 /** 3.20 * Shorthand for ucx_stream_copy using the default copy buffer and a copy limit.