From 2f1158cecd37ca8f1c635d0f9d8e99f1980b0cea Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 9 Feb 2018 01:12:27 +0300 Subject: [PATCH] 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. --- tests/test_malloc.c | 6 +++--- tests/test_stack.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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"); -- 2.40.0