adds missing stdint.h include for int32_t + fixes possible implicit const cast overflow + adds support for DESTDIR variable in Makefile

Fri, 16 Dec 2016 23:22:18 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 16 Dec 2016 23:22:18 +0100
changeset 230
4044131874f9
parent 229
9db71925eaa8
child 231
35490eb48214

adds missing stdint.h include for int32_t + fixes possible implicit const cast overflow + adds support for DESTDIR variable in Makefile

Makefile file | annotate | diff | comparison | revisions
test/buffer_tests.c file | annotate | diff | comparison | revisions
     1.1 --- a/Makefile	Fri Nov 18 15:33:58 2016 +0100
     1.2 +++ b/Makefile	Fri Dec 16 23:22:18 2016 +0100
     1.3 @@ -63,21 +63,21 @@
     1.4  	
     1.5  debug: ucx-debug test-debug
     1.6  
     1.7 -install: ucx $(PREFIX)/lib $(PREFIX)/include/ucx
     1.8 -	cp ./build/release/libucx$(LIB_EXT) $(PREFIX)/lib && \
     1.9 -	cp ./build/release/libucx$(SO_EXT) $(PREFIX)/lib && \
    1.10 -        cp ./ucx/*.h $(PREFIX)/include/ucx
    1.11 +install: ucx $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include/ucx
    1.12 +	cp ./build/release/libucx$(LIB_EXT) $(DESTDIR)$(PREFIX)/lib && \
    1.13 +	cp ./build/release/libucx$(SO_EXT) $(DESTDIR)$(PREFIX)/lib && \
    1.14 +        cp ./ucx/*.h $(DESTDIR)$(PREFIX)/include/ucx
    1.15  
    1.16  uninstall:
    1.17 -	$(RM) $(RMFLAGS) $(PREFIX)/include/ucx &&\
    1.18 -	$(RM) $(RMFLAGS) $(PREFIX)/lib/libucx$(LIB_EXT) &&\
    1.19 -	$(RM) $(RMFLAGS) $(PREFIX)/lib/libucx$(SO_EXT)
    1.20 +	$(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/include/ucx &&\
    1.21 +	$(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/libucx$(LIB_EXT) &&\
    1.22 +	$(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/libucx$(SO_EXT)
    1.23  
    1.24 -$(PREFIX)/lib:
    1.25 -	mkdir -p $(PREFIX)/lib
    1.26 +$(DESTDIR)$(PREFIX)/lib:
    1.27 +	mkdir -p $@
    1.28  
    1.29 -$(PREFIX)/include/ucx:
    1.30 -	mkdir -p $(PREFIX)/include/ucx
    1.31 +$(DESTDIR)$(PREFIX)/include/ucx:
    1.32 +	mkdir -p $@
    1.33  
    1.34  clean: FORCE
    1.35  	$(RM) $(RMFLAGS) build
     2.1 --- a/test/buffer_tests.c	Fri Nov 18 15:33:58 2016 +0100
     2.2 +++ b/test/buffer_tests.c	Fri Dec 16 23:22:18 2016 +0100
     2.3 @@ -27,6 +27,7 @@
     2.4   */
     2.5  
     2.6  #include "buffer_tests.h"
     2.7 +#include <stdint.h>
     2.8  
     2.9  UCX_TEST(test_ucx_buffer_new) {
    2.10      UcxBuffer *b = ucx_buffer_new(NULL, 16, UCX_BUFFER_AUTOEXTEND);
    2.11 @@ -97,8 +98,12 @@
    2.12              "failed seek shall leave pos unchanged");
    2.13      
    2.14      b->pos = 0;
    2.15 -    b->size = sizemax / 2 + 32;
    2.16 -    off_t bigoff = sizemax / 2 - 16;
    2.17 +    b->size = (sizemax >> 1) + 32;
    2.18 +    
    2.19 +    // we don't want to risk overflows in implicit constant casts
    2.20 +    const size_t bigoff_comp = (sizemax >> 1) - 16;
    2.21 +    off_t bigoff = (off_t)bigoff_comp;
    2.22 +    
    2.23      r = ucx_buffer_seek(b, -bigoff, SEEK_CUR);
    2.24      UCX_TEST_ASSERT(r != 0, "seek cur underflow");
    2.25      UCX_TEST_ASSERT(b->pos == 0,

mercurial