fixed further usages of SIZE_MAX

Fri, 26 Feb 2016 16:33:04 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 26 Feb 2016 16:33:04 +0100
changeset 218
b20d6088795c
parent 217
e056e4e0b08e
child 219
2df780a4482b

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
--- a/test/buffer_tests.c	Fri Feb 26 16:22:20 2016 +0100
+++ b/test/buffer_tests.c	Fri Feb 26 16:33:04 2016 +0100
@@ -27,7 +27,6 @@
  */
 
 #include "buffer_tests.h"
-#include <stdint.h>
 
 UCX_TEST(test_ucx_buffer_new) {
     UcxBuffer *b = ucx_buffer_new(NULL, 16, UCX_BUFFER_AUTOEXTEND);
@@ -88,7 +87,8 @@
     int r;
     
     UCX_TEST_BEGIN
-    size_t bigpos = SIZE_MAX - 5000;
+    const size_t sizemax = (size_t)-1;
+    size_t bigpos = sizemax - 5000;
     b->pos = bigpos;
     r = ucx_buffer_seek(b, 5016, SEEK_CUR);
     UCX_TEST_ASSERT(r != 0, "seek cur overflow");
@@ -96,8 +96,8 @@
             "failed seek shall leave pos unchanged");
     
     b->pos = 0;
-    b->size = SIZE_MAX / 2 + 32;
-    off_t bigoff = SIZE_MAX / 2 - 16;
+    b->size = sizemax / 2 + 32;
+    off_t bigoff = sizemax / 2 - 16;
     r = ucx_buffer_seek(b, -bigoff, SEEK_CUR);
     UCX_TEST_ASSERT(r != 0, "seek cur underflow");
     UCX_TEST_ASSERT(b->pos == 0,
@@ -593,7 +593,7 @@
     UCX_TEST_ASSERT((b->size == 0 && b->pos == 0),
         "pos and size shall remain unchanged");
     
-    UCX_TEST_ASSERT(ucx_buffer_extend(b, SIZE_MAX - 60) != 0,
+    UCX_TEST_ASSERT(ucx_buffer_extend(b, (size_t) - 61) != 0,
         "shall fail and return a non-zero value on overflow");
     
     UCX_TEST_END
--- a/ucx/avl.h	Fri Feb 26 16:22:20 2016 +0100
+++ b/ucx/avl.h	Fri Feb 26 16:33:04 2016 +0100
@@ -44,7 +44,7 @@
 
 #include "ucx.h"
 #include "allocator.h"
-#include <stdint.h>
+#include <inttypes.h>
 
 #ifdef	__cplusplus
 extern "C" {
--- a/ucx/utils.h	Fri Feb 26 16:22:20 2016 +0100
+++ b/ucx/utils.h	Fri Feb 26 16:33:04 2016 +0100
@@ -45,7 +45,7 @@
 #include "ucx.h"
 #include "string.h"
 #include "allocator.h"
-#include <stdint.h>
+#include <inttypes.h>
 #include <string.h>
 #include <stdarg.h>
 
@@ -95,7 +95,7 @@
  * @return total number of bytes copied
  */
 #define ucx_stream_hcopy(src,dest,rfnc,wfnc) ucx_stream_copy(\
-        src, dest, (read_func)rfnc, (write_func)wfnc, NULL, 0x100, SIZE_MAX)
+        src, dest, (read_func)rfnc, (write_func)wfnc, NULL, 0x100, (size_t)-1)
 
 /**
  * Shorthand for ucx_stream_copy using the default copy buffer and a copy limit.

mercurial