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

@ -29,7 +29,8 @@
extern "C" {
#endif
#include <spa/debug/debug-mem.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
#include <spa/buffer/type-info.h>
#ifndef spa_debug
@ -38,10 +39,9 @@ extern "C" {
static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
{
int i;
uint32_t i;
spa_debug("%*s" "struct spa_buffer %p:", indent, "", buffer);
spa_debug("%*s" " id: %08X", indent, "", buffer->id);
spa_debug("%*s" " n_metas: %u (at %p)", indent, "", buffer->n_metas, buffer->metas);
for (i = 0; i < buffer->n_metas; i++) {
struct spa_meta *m = &buffer->metas[i];
@ -54,7 +54,7 @@ static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
switch (m->type) {
case SPA_META_Header:
{
struct spa_meta_header *h = m->data;
struct spa_meta_header *h = (struct spa_meta_header*)m->data;
spa_debug("%*s" " struct spa_meta_header:", indent, "");
spa_debug("%*s" " flags: %08x", indent, "", h->flags);
spa_debug("%*s" " seq: %u", indent, "", h->seq);
@ -64,15 +64,30 @@ static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
}
case SPA_META_VideoCrop:
{
struct spa_meta_video_crop *h = m->data;
spa_debug("%*s" " struct spa_meta_video_crop:", indent, "");
spa_debug("%*s" " x: %d", indent, "", h->x);
spa_debug("%*s" " y: %d", indent, "", h->y);
spa_debug("%*s" " width: %d", indent, "", h->width);
spa_debug("%*s" " height: %d", indent, "", h->height);
struct spa_meta_region *h = (struct spa_meta_region*)m->data;
spa_debug("%*s" " struct spa_meta_region:", indent, "");
spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
break;
}
case SPA_META_VideoDamage:
{
struct spa_meta_region *h;
spa_meta_region_for_each(h, m) {
spa_debug("%*s" " struct spa_meta_region:", indent, "");
spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
}
break;
}
case SPA_META_Bitmap:
break;
case SPA_META_Cursor:
break;
default:
spa_debug("%*s" " Unknown:", indent, "");
spa_debug_mem(5, m->data, m->size);

View file

@ -74,13 +74,13 @@ spa_debug_format_value(const struct spa_type_info *info,
break;
case SPA_TYPE_Rectangle:
{
struct spa_rectangle *r = body;
struct spa_rectangle *r = (struct spa_rectangle *)body;
fprintf(stderr, "%" PRIu32 "x%" PRIu32, r->width, r->height);
break;
}
case SPA_TYPE_Fraction:
{
struct spa_fraction *f = body;
struct spa_fraction *f = (struct spa_fraction *)body;
fprintf(stderr, "%" PRIu32 "/%" PRIu32, f->num, f->denom);
break;
}
@ -93,7 +93,7 @@ spa_debug_format_value(const struct spa_type_info *info,
case SPA_TYPE_Array:
{
void *p;
struct spa_pod_array_body *b = body;
struct spa_pod_array_body *b = (struct spa_pod_array_body *)body;
int i = 0;
fprintf(stderr, "< ");
SPA_POD_ARRAY_BODY_FOREACH(b, size, p) {
@ -118,27 +118,6 @@ static inline int spa_debug_format(int indent,
const char *media_subtype;
struct spa_pod_prop *prop;
uint32_t mtype, mstype;
const char *pod_type_names[] = {
[SPA_TYPE_None] = "none",
[SPA_TYPE_Bool] = "bool",
[SPA_TYPE_Id] = "id",
[SPA_TYPE_Int] = "int",
[SPA_TYPE_Long] = "long",
[SPA_TYPE_Float] = "float",
[SPA_TYPE_Double] = "double",
[SPA_TYPE_String] = "string",
[SPA_TYPE_Bytes] = "bytes",
[SPA_TYPE_Rectangle] = "rectangle",
[SPA_TYPE_Fraction] = "fraction",
[SPA_TYPE_Bitmap] = "bitmap",
[SPA_TYPE_Array] = "array",
[SPA_TYPE_Struct] = "struct",
[SPA_TYPE_Object] = "object",
[SPA_TYPE_Pointer] = "pointer",
[SPA_TYPE_Fd] = "fd",
[SPA_TYPE_Choice] = "choice",
[SPA_TYPE_Pod] = "pod"
};
if (info == NULL)
info = spa_type_format;
@ -173,12 +152,15 @@ static inline int spa_debug_format(int indent,
size = val->size;
vals = SPA_POD_BODY(val);
if (type < SPA_TYPE_None || type >= SPA_TYPE_LAST)
continue;
ti = spa_debug_type_find(info, prop->key);
key = ti ? ti->name : NULL;
fprintf(stderr, "%*s %16s : (%s) ", indent, "",
key ? rindex(key, ':') + 1 : "unknown",
pod_type_names[type]);
rindex(spa_types[type].name, ':') + 1);
if (choice == SPA_CHOICE_None) {
spa_debug_format_value(ti->values, type, vals, size);

View file

@ -37,7 +37,7 @@ extern "C" {
static inline int spa_debug_mem(int indent, const void *data, size_t size)
{
const uint8_t *t = data;
const uint8_t *t = (const uint8_t*)data;
char buffer[512];
size_t i;
int pos = 0;

View file

@ -137,20 +137,20 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
break;
case SPA_TYPE_Pointer:
{
struct spa_pod_pointer_body *b = body;
struct spa_pod_pointer_body *b = (struct spa_pod_pointer_body *)body;
spa_debug("%*s" "Pointer %s %p", indent, "",
spa_debug_type_find_name(SPA_TYPE_ROOT, b->type), b->value);
break;
}
case SPA_TYPE_Rectangle:
{
struct spa_rectangle *r = body;
struct spa_rectangle *r = (struct spa_rectangle *)body;
spa_debug("%*s" "Rectangle %dx%d", indent, "", r->width, r->height);
break;
}
case SPA_TYPE_Fraction:
{
struct spa_fraction *f = body;
struct spa_fraction *f = (struct spa_fraction *)body;
spa_debug("%*s" "Fraction %d/%d", indent, "", f->num, f->denom);
break;
}
@ -159,7 +159,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
break;
case SPA_TYPE_Array:
{
struct spa_pod_array_body *b = body;
struct spa_pod_array_body *b = (struct spa_pod_array_body *)body;
void *p;
const struct spa_type_info *ti = spa_debug_type_find(SPA_TYPE_ROOT, b->child.type);
@ -172,7 +172,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Choice:
{
struct spa_pod_choice_body *b = body;
struct spa_pod_choice_body *b = (struct spa_pod_choice_body *)body;
void *p;
const struct spa_type_info *ti = spa_debug_type_find(spa_type_choice, b->type);
@ -185,7 +185,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Struct:
{
struct spa_pod *b = body, *p;
struct spa_pod *b = (struct spa_pod *)body, *p;
spa_debug("%*s" "Struct: size %d", indent, "", size);
SPA_POD_FOREACH(b, size, p)
spa_debug_pod_value(indent + 2, info, p->type, SPA_POD_BODY(p), p->size);
@ -193,7 +193,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Object:
{
struct spa_pod_object_body *b = body;
struct spa_pod_object_body *b = (struct spa_pod_object_body *)body;
struct spa_pod_prop *p;
const struct spa_type_info *ti, *ii;
@ -221,7 +221,7 @@ spa_debug_pod_value(int indent, const struct spa_type_info *info,
}
case SPA_TYPE_Sequence:
{
struct spa_pod_sequence_body *b = body;
struct spa_pod_sequence_body *b = (struct spa_pod_sequence_body *)body;
const struct spa_type_info *ti, *ii;
struct spa_pod_control *c;