From 5caaeab8a7448390eb857006f9b3704de60cf115 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 22 Mar 2011 12:20:49 +1030 Subject: [PATCH] antithread: avoid arithmetic on void pointers --- ccan/antithread/antithread.c | 2 +- ccan/failtest/failtest.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ccan/antithread/antithread.c b/ccan/antithread/antithread.c index 61b288a3..da607c1e 100644 --- a/ccan/antithread/antithread.c +++ b/ccan/antithread/antithread.c @@ -193,7 +193,7 @@ struct at_pool *at_pool(unsigned long size) /* Then we remap into the middle of it. */ munmap(p->pool, size+PADDING); - p->pool = mmap(p->pool + PADDING/2, size, PROT_READ|PROT_WRITE, + p->pool = mmap((char *)p->pool + PADDING/2, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (p->pool == MAP_FAILED) goto fail_free; diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index 334295ad..0f2ab0c7 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -84,8 +84,9 @@ static struct failtest_call *add_history_(enum failtest_call_type type, #define add_history(type, file, line, elem) \ add_history_((type), (file), (line), (elem), sizeof(*(elem))) +/* We do a fake call inside a sizeof(), to check types. */ #define set_cleanup(call, clean, type) \ - (call)->cleanup = (void *)((void)sizeof(clean((type *)NULL)), (clean)) + (call)->cleanup = (void *)((void)sizeof(clean((type *)NULL),1), (clean)) static bool read_write_info(int fd) { -- 2.39.2