Avoid ubsan failure with clang-20,
tcg.h:715:19: runtime error: applying non-zero offset 64 to null pointer
by not using pointers.
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
}
struct TCGContext {
- uint8_t *pool_cur, *pool_end;
+ uintptr_t pool_cur, pool_end;
TCGPool *pool_first, *pool_current, *pool_first_large;
int nb_labels;
int nb_globals;
static inline void *tcg_malloc(int size)
{
TCGContext *s = tcg_ctx;
- uint8_t *ptr, *ptr_end;
+ uintptr_t ptr, ptr_end;
/* ??? This is a weak placeholder for minimum malloc alignment. */
size = QEMU_ALIGN_UP(size, 8);
return tcg_malloc_internal(tcg_ctx, size);
} else {
s->pool_cur = ptr_end;
- return ptr;
+ return (void *)ptr;
}
}
p = s->pool_current;
if (!p) {
p = s->pool_first;
- if (!p)
+ if (!p) {
goto new_pool;
+ }
} else {
if (!p->next) {
new_pool:
}
}
s->pool_current = p;
- s->pool_cur = p->data + size;
- s->pool_end = p->data + p->size;
+ s->pool_cur = (uintptr_t)p->data + size;
+ s->pool_end = (uintptr_t)p->data + p->size;
return p->data;
}
g_free(p);
}
s->pool_first_large = NULL;
- s->pool_cur = s->pool_end = NULL;
+ s->pool_cur = s->pool_end = 0;
s->pool_current = NULL;
}