test/buffer_tests.c

changeset 230
4044131874f9
parent 227
740fbd7bab71
child 250
b7d1317b138e
     1.1 --- a/test/buffer_tests.c	Fri Nov 18 15:33:58 2016 +0100
     1.2 +++ b/test/buffer_tests.c	Fri Dec 16 23:22:18 2016 +0100
     1.3 @@ -27,6 +27,7 @@
     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 @@ -97,8 +98,12 @@
    1.12              "failed seek shall leave pos unchanged");
    1.13      
    1.14      b->pos = 0;
    1.15 -    b->size = sizemax / 2 + 32;
    1.16 -    off_t bigoff = sizemax / 2 - 16;
    1.17 +    b->size = (sizemax >> 1) + 32;
    1.18 +    
    1.19 +    // we don't want to risk overflows in implicit constant casts
    1.20 +    const size_t bigoff_comp = (sizemax >> 1) - 16;
    1.21 +    off_t bigoff = (off_t)bigoff_comp;
    1.22 +    
    1.23      r = ucx_buffer_seek(b, -bigoff, SEEK_CUR);
    1.24      UCX_TEST_ASSERT(r != 0, "seek cur underflow");
    1.25      UCX_TEST_ASSERT(b->pos == 0,

mercurial