diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2019-03-20 18:54:11 +0200 |
---|---|---|
committer | rl1987 <rl1987@sdf.lonestar.org> | 2019-03-20 18:54:11 +0200 |
commit | 0bc9ed9d38cb29783d000b6e22677ae16727976b (patch) | |
tree | 2866abc10a0910d10f071506e14297e40609d8c4 /src/test/test_ptr_slow.c | |
parent | e52653e01a2ce6655975c2f893a1d1ff7bef2af7 (diff) | |
download | tor-0bc9ed9d38cb29783d000b6e22677ae16727976b.tar.gz tor-0bc9ed9d38cb29783d000b6e22677ae16727976b.zip |
Move casts to separate C file to prevent compiler from optimising them away
Diffstat (limited to 'src/test/test_ptr_slow.c')
-rw-r--r-- | src/test/test_ptr_slow.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/test/test_ptr_slow.c b/src/test/test_ptr_slow.c index f064a3e7c2..07481fb1ec 100644 --- a/src/test/test_ptr_slow.c +++ b/src/test/test_ptr_slow.c @@ -6,6 +6,7 @@ #include "orconfig.h" #include "core/or/or.h" #include "test/test.h" +#include "test/ptr_helpers.h" #include <stdint.h> #include <limits.h> @@ -15,9 +16,9 @@ static void assert_int_voidptr_roundtrip(int a) { intptr_t ap = (intptr_t)a; - void *b = (void *)ap; - intptr_t c = (intptr_t)b; - void *d = (void *)c; + void *b = cast_intptr_to_voidstar(ap); + intptr_t c = cast_voidstar_to_intptr(b); + void *d = cast_intptr_to_voidstar(c); tt_assert(ap == c); tt_assert(b == d); @@ -45,9 +46,9 @@ static void assert_uint_voidptr_roundtrip(unsigned int a) { uintptr_t ap = (uintptr_t)a; - void *b = (void *)ap; - uintptr_t c = (uintptr_t)b; - void *d = (void *)c; + void *b = cast_uintptr_to_voidstar(ap); + uintptr_t c = cast_voidstar_to_uintptr(b); + void *d = cast_uintptr_to_voidstar(c); tt_assert(ap == c); tt_assert(b == d); |