# HG changeset patch # User Mike Becker # Date 1481926938 -3600 # Node ID 4044131874f978c28a3e5ac9ce2dcf00cedf3020 # Parent 9db71925eaa8408d1c4be689f610c555dc12c9dd adds missing stdint.h include for int32_t + fixes possible implicit const cast overflow + adds support for DESTDIR variable in Makefile diff -r 9db71925eaa8 -r 4044131874f9 Makefile --- a/Makefile Fri Nov 18 15:33:58 2016 +0100 +++ b/Makefile Fri Dec 16 23:22:18 2016 +0100 @@ -63,21 +63,21 @@ debug: ucx-debug test-debug -install: ucx $(PREFIX)/lib $(PREFIX)/include/ucx - cp ./build/release/libucx$(LIB_EXT) $(PREFIX)/lib && \ - cp ./build/release/libucx$(SO_EXT) $(PREFIX)/lib && \ - cp ./ucx/*.h $(PREFIX)/include/ucx +install: ucx $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include/ucx + cp ./build/release/libucx$(LIB_EXT) $(DESTDIR)$(PREFIX)/lib && \ + cp ./build/release/libucx$(SO_EXT) $(DESTDIR)$(PREFIX)/lib && \ + cp ./ucx/*.h $(DESTDIR)$(PREFIX)/include/ucx uninstall: - $(RM) $(RMFLAGS) $(PREFIX)/include/ucx &&\ - $(RM) $(RMFLAGS) $(PREFIX)/lib/libucx$(LIB_EXT) &&\ - $(RM) $(RMFLAGS) $(PREFIX)/lib/libucx$(SO_EXT) + $(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/include/ucx &&\ + $(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/libucx$(LIB_EXT) &&\ + $(RM) $(RMFLAGS) $(DESTDIR)$(PREFIX)/lib/libucx$(SO_EXT) -$(PREFIX)/lib: - mkdir -p $(PREFIX)/lib +$(DESTDIR)$(PREFIX)/lib: + mkdir -p $@ -$(PREFIX)/include/ucx: - mkdir -p $(PREFIX)/include/ucx +$(DESTDIR)$(PREFIX)/include/ucx: + mkdir -p $@ clean: FORCE $(RM) $(RMFLAGS) build diff -r 9db71925eaa8 -r 4044131874f9 test/buffer_tests.c --- a/test/buffer_tests.c Fri Nov 18 15:33:58 2016 +0100 +++ b/test/buffer_tests.c Fri Dec 16 23:22:18 2016 +0100 @@ -27,6 +27,7 @@ */ #include "buffer_tests.h" +#include UCX_TEST(test_ucx_buffer_new) { UcxBuffer *b = ucx_buffer_new(NULL, 16, UCX_BUFFER_AUTOEXTEND); @@ -97,8 +98,12 @@ "failed seek shall leave pos unchanged"); b->pos = 0; - b->size = sizemax / 2 + 32; - off_t bigoff = sizemax / 2 - 16; + b->size = (sizemax >> 1) + 32; + + // we don't want to risk overflows in implicit constant casts + const size_t bigoff_comp = (sizemax >> 1) - 16; + off_t bigoff = (off_t)bigoff_comp; + r = ucx_buffer_seek(b, -bigoff, SEEK_CUR); UCX_TEST_ASSERT(r != 0, "seek cur underflow"); UCX_TEST_ASSERT(b->pos == 0,