From f049d3dc7f8cdc26c73b7f8bb56e5cc9c4f3eb9e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 8 Feb 2018 10:49:08 +0100 Subject: [PATCH] Fix compiler issues with c++ --- spa/include/spa/pod/builder.h | 8 ++++---- spa/include/spa/support/log.h | 2 +- src/pipewire/array.h | 6 +++--- src/pipewire/log.h | 2 +- src/pipewire/map.h | 8 ++++---- src/pipewire/pipewire.h | 1 + src/pipewire/properties.h | 2 +- src/pipewire/utils.h | 4 +++- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/spa/include/spa/pod/builder.h b/spa/include/spa/pod/builder.h index 9992f5276..6876d8d52 100644 --- a/spa/include/spa/pod/builder.h +++ b/spa/include/spa/pod/builder.h @@ -84,7 +84,7 @@ spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t ref) else if (ref + 8 <= builder->size) { struct spa_pod *pod = SPA_MEMBER(builder->data, ref, struct spa_pod); if (SPA_POD_SIZE(pod) <= builder->size) - return pod; + return (void *) pod; } return NULL; } @@ -115,7 +115,7 @@ spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t if (ref + size > builder->size) ref = -1; else - memcpy(builder->data + ref, data, size); + memcpy(SPA_MEMBER(builder->data, ref, void), data, size); } builder->state.offset += size; @@ -148,7 +148,7 @@ static inline void *spa_pod_builder_pop(struct spa_pod_builder *builder) struct spa_pod *pod; frame = &builder->frame[--builder->state.depth]; - if ((pod = spa_pod_builder_deref(builder, frame->ref)) != NULL) + if ((pod = (struct spa_pod *) spa_pod_builder_deref(builder, frame->ref)) != NULL) *pod = frame->pod; top = builder->state.depth > 0 ? &builder->frame[builder->state.depth-1] : NULL; @@ -328,7 +328,7 @@ spa_pod_builder_array(struct spa_pod_builder *builder, uint32_t child_size, uint32_t child_type, uint32_t n_elems, const void *elems) { const struct spa_pod_array p = { - {sizeof(struct spa_pod_array_body) + n_elems * child_size, SPA_POD_TYPE_ARRAY}, + {(uint32_t)(sizeof(struct spa_pod_array_body) + n_elems * child_size), SPA_POD_TYPE_ARRAY}, {{child_size, child_type}} }; uint32_t ref = spa_pod_builder_raw(builder, &p, sizeof(p)); diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h index 260f6339a..dfce08c02 100644 --- a/spa/include/spa/support/log.h +++ b/spa/include/spa/support/log.h @@ -113,7 +113,7 @@ struct spa_log { #else #define SPA_LOG_FUNC(name,lev) \ -static inline void spa_log_##name (struct spa_log *l, const char *format, ...) \ +static inline void spa_log_##name (struct spa_log *l, const char *format, ...) \ { \ if (SPA_UNLIKELY (spa_log_level_enabled (l, lev))) { \ va_list varargs; \ diff --git a/src/pipewire/array.h b/src/pipewire/array.h index 6ecf39be9..18804c75f 100644 --- a/src/pipewire/array.h +++ b/src/pipewire/array.h @@ -54,7 +54,7 @@ struct pw_array { #define pw_array_check_index(a,idx,t) pw_array_check_index_s(a,idx,sizeof(t)) #define pw_array_for_each(pos, array) \ - for (pos = (array)->data; \ + for (pos = (__typeof__(pos)) (array)->data; \ (const uint8_t *) pos < ((const uint8_t *) (array)->data + (array)->size); \ (pos)++) @@ -102,7 +102,7 @@ static inline void *pw_array_add(struct pw_array *arr, size_t size) if (!pw_array_ensure_size(arr, size)) return NULL; - p = arr->data + arr->size; + p = SPA_MEMBER(arr->data, arr->size, void); arr->size += size; return p; @@ -117,7 +117,7 @@ static inline void *pw_array_add_fixed(struct pw_array *arr, size_t size) if (SPA_UNLIKELY(arr->alloc < arr->size + size)) return NULL; - p = arr->data + arr->size; + p = SPA_MEMBER(arr->data, arr->size, void); arr->size += size; return p; diff --git a/src/pipewire/log.h b/src/pipewire/log.h index ba741ddcd..03c875154 100644 --- a/src/pipewire/log.h +++ b/src/pipewire/log.h @@ -78,7 +78,7 @@ pw_log_logv(enum spa_log_level level, #include #define PW_LOG_FUNC(name,lev) \ -static inline void pw_log_##name (const char *format, ...) SPA_PRINTF_FUNC(1, 0); \ +static inline void pw_log_##name (const char *format, ...) \ { \ if (SPA_UNLIKELY(pw_log_level_enabled(lev))) { \ va_list varargs; \ diff --git a/src/pipewire/map.h b/src/pipewire/map.h index 2e77cdb4a..127add0ee 100644 --- a/src/pipewire/map.h +++ b/src/pipewire/map.h @@ -95,14 +95,14 @@ static inline uint32_t pw_map_insert_new(struct pw_map *map, void *data) uint32_t id; if (map->free_list) { - start = map->items.data; + start = (union pw_map_item *) map->items.data; item = &start[map->free_list >> 1]; map->free_list = item->next; } else { - item = pw_array_add(&map->items, sizeof(union pw_map_item)); + item = (union pw_map_item *) pw_array_add(&map->items, sizeof(union pw_map_item)); if (!item) return SPA_ID_INVALID; - start = map->items.data; + start = (union pw_map_item *) map->items.data; } item->data = data; id = (item - start); @@ -124,7 +124,7 @@ static inline bool pw_map_insert_at(struct pw_map *map, uint32_t id, void *data) if (id > size) return false; else if (id == size) - item = pw_array_add(&map->items, sizeof(union pw_map_item)); + item = (union pw_map_item *) pw_array_add(&map->items, sizeof(union pw_map_item)); else item = pw_map_get_item(map, id); diff --git a/src/pipewire/pipewire.h b/src/pipewire/pipewire.h index 7df740486..870f97462 100644 --- a/src/pipewire/pipewire.h +++ b/src/pipewire/pipewire.h @@ -143,4 +143,5 @@ pw_get_support(uint32_t *n_support); #ifdef __cplusplus } #endif + #endif /* __PIPEWIRE_H__ */ diff --git a/src/pipewire/properties.h b/src/pipewire/properties.h index 40b9a502f..693542dee 100644 --- a/src/pipewire/properties.h +++ b/src/pipewire/properties.h @@ -21,7 +21,7 @@ #define __PIPEWIRE_PROPERTIES_H__ #ifdef __cplusplus -//extern "C" { +extern "C" { #endif #include diff --git a/src/pipewire/utils.h b/src/pipewire/utils.h index a9ce87763..22871b9a2 100644 --- a/src/pipewire/utils.h +++ b/src/pipewire/utils.h @@ -51,7 +51,9 @@ pw_strip(char *str, const char *whitespace); static inline struct spa_pod * pw_spa_pod_copy(const struct spa_pod *pod) { - return pod ? memcpy(malloc(SPA_POD_SIZE(pod)), pod, SPA_POD_SIZE(pod)) : NULL; + return pod ? + (struct spa_pod *) memcpy(malloc(SPA_POD_SIZE(pod)), pod, SPA_POD_SIZE(pod)) + : NULL; } #ifdef __cplusplus