fix more compile errors

Avoid void * arithmetic
Do explicit casts to target type to make c++ happy
This commit is contained in:
Wim Taymans 2019-01-08 11:53:36 +01:00
parent 3fa2ad33e4
commit b0f4be5fbc
26 changed files with 175 additions and 159 deletions

View file

@ -48,9 +48,9 @@ struct spa_buffer_alloc_info {
};
static inline int spa_buffer_alloc_fill_info(struct spa_buffer_alloc_info *info,
uint32_t n_metas, struct spa_meta metas[n_metas],
uint32_t n_datas, struct spa_data datas[n_datas],
uint32_t data_aligns[n_datas])
uint32_t n_metas, struct spa_meta metas[],
uint32_t n_datas, struct spa_data datas[],
uint32_t data_aligns[])
{
size_t size;
uint32_t i;
@ -91,7 +91,7 @@ static inline struct spa_buffer *
spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
void *skel_mem, void *data_mem)
{
struct spa_buffer *b = skel_mem;
struct spa_buffer *b = (struct spa_buffer*)skel_mem;
size_t size;
uint32_t i;
void **dp, *skel, *data;
@ -114,17 +114,17 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
struct spa_meta *m = &b->metas[i];
*m = info->metas[i];
m->data = *dp;
*dp += m->size;
*dp = SPA_MEMBER(*dp, m->size, void);
}
size = info->n_datas * sizeof(struct spa_chunk);
if (SPA_FLAG_CHECK(info->flags, SPA_BUFFER_ALLOC_FLAG_INLINE_CHUNK)) {
cp = skel;
skel += size;
cp = (struct spa_chunk*)skel;
skel = SPA_MEMBER(skel, size, void);
}
else {
cp = data;
data += size;
cp = (struct spa_chunk*)data;
data = SPA_MEMBER(data, size, void);
}
if (SPA_FLAG_CHECK(info->flags, SPA_BUFFER_ALLOC_FLAG_INLINE_DATA))
@ -139,7 +139,7 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
d->chunk = &cp[i];
if (!SPA_FLAG_CHECK(info->flags, SPA_BUFFER_ALLOC_FLAG_NO_DATA)) {
d->data = *dp;
*dp += d->maxsize;
*dp = SPA_MEMBER(*dp, d->maxsize, void);
}
}
return b;
@ -147,7 +147,7 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
static inline int
spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info,
uint32_t n_buffers, struct spa_buffer *buffers[n_buffers],
uint32_t n_buffers, struct spa_buffer *buffers[],
void *skel_mem, void *data_mem)
{
uint32_t i;
@ -162,9 +162,9 @@ spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info,
static inline struct spa_buffer **
spa_buffer_alloc_array(uint32_t n_buffers, uint32_t flags,
uint32_t n_metas, struct spa_meta metas[n_metas],
uint32_t n_datas, struct spa_data datas[n_datas],
uint32_t data_aligns[n_datas])
uint32_t n_metas, struct spa_meta metas[],
uint32_t n_datas, struct spa_data datas[],
uint32_t data_aligns[])
{
struct spa_buffer **buffers;
@ -175,7 +175,7 @@ spa_buffer_alloc_array(uint32_t n_buffers, uint32_t flags,
info.skel_size = SPA_ROUND_UP_N(info.skel_size, 16);
buffers = calloc(n_buffers, sizeof(struct spa_buffer *) + info.skel_size);
buffers = (struct spa_buffer **)calloc(n_buffers, sizeof(struct spa_buffer *) + info.skel_size);
skel = SPA_MEMBER(buffers, sizeof(struct spa_buffer *) * n_buffers, void);

View file

@ -60,8 +60,8 @@ struct spa_meta {
};
#define spa_meta_first(m) ((m)->data)
#define spa_meta_end(m) ((m)->data + (m)->size)
#define spa_meta_check(p,m) ((void*)(p) + sizeof(*p) <= spa_meta_end(m))
#define spa_meta_end(m) SPA_MEMBER((m)->data,(m)->size,void)
#define spa_meta_check(p,m) (SPA_MEMBER(p,sizeof(*p),void) <= spa_meta_end(m))
/**
* Describes essential buffer header metadata such as flags and
@ -89,7 +89,7 @@ struct spa_meta_region {
#define spa_meta_region_is_valid(m) ((m)->region.size.width != 0 && (m)->region.size.height != 0)
#define spa_meta_region_for_each(pos,meta) \
for (pos = spa_meta_first(meta); \
for (pos = (__typeof(pos))spa_meta_first(meta); \
spa_meta_check(pos, meta); \
(pos)++)

View file

@ -31,7 +31,7 @@ extern "C" {
#include <spa/buffer/buffer.h>
#include <spa/buffer/meta.h>
#include <spa/utils/type-info.h>
#include <spa/utils/type.h>
#define SPA_TYPE__Buffer SPA_TYPE_POINTER_BASE "Buffer"
#define SPA_TYPE_BUFFER_BASE SPA_TYPE__Buffer ":"