From: Ivan Maidanski Date: Thu, 8 Feb 2018 22:12:27 +0000 (+0300) Subject: Convert tests to valid C++ code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b9d74b6649d2ab092f6c3694f9262da232ccdd6;p=libatomic_ops Convert tests to valid C++ code * tests/test_malloc.c (cons, dummy_test, run_one_test): Add explicit cast of void* pointer (returned by malloc) to the type of the variable the pointer is assigned to. * tests/test_stack.c (add_elements): Likewise. --- diff --git a/tests/test_malloc.c b/tests/test_malloc.c index a7b36bd..fd95a8f 100644 --- a/tests/test_malloc.c +++ b/tests/test_malloc.c @@ -81,7 +81,7 @@ ln *cons(int d, ln *tail) int * extras; unsigned i; - result = AO_malloc(sizeof(ln) + sizeof(int)*my_extra); + result = (ln *)AO_malloc(sizeof(ln) + sizeof(int)*my_extra); if (result == 0) { fprintf(stderr, "Out of memory\n"); @@ -170,7 +170,7 @@ int dummy_test(void) { return 1; } void * run_one_test(void * arg) { ln * x = make_list(1, LIST_LENGTH); int i; - char *p = AO_malloc(LARGE_OBJ_SIZE); + char *p = (char *)AO_malloc(LARGE_OBJ_SIZE); char *q; char a = 'a' + ((int)((AO_PTRDIFF_T)arg) * 2) % ('z' - 'a' + 1); char b = a + 1; @@ -185,7 +185,7 @@ void * run_one_test(void * arg) { # endif } else { p[0] = p[LARGE_OBJ_SIZE/2] = p[LARGE_OBJ_SIZE-1] = a; - q = AO_malloc(LARGE_OBJ_SIZE); + q = (char *)AO_malloc(LARGE_OBJ_SIZE); if (q == 0) { fprintf(stderr, "Out of memory\n"); diff --git a/tests/test_stack.c b/tests/test_stack.c index 5507b54..4edc88b 100644 --- a/tests/test_stack.c +++ b/tests/test_stack.c @@ -91,7 +91,7 @@ void add_elements(int n) list_element * le; if (n == 0) return; add_elements(n-1); - le = malloc(sizeof(list_element)); + le = (list_element *)malloc(sizeof(list_element)); if (le == 0) { fprintf(stderr, "Out of memory\n");