From f9461b0b7d3071347390feee534638555ff76c7d Mon Sep 17 00:00:00 2001 From: Rudolchr <72916442+Rudolchr@users.noreply.github.com> Date: Tue, 26 Sep 2023 23:23:02 +0200 Subject: [PATCH] build: Fix build when using clang (#100) * Add -Wno-address-of-temporary to allow taking an address of temporary like -fpermissive does for gcc * Make some implicit casts explicit * Implement the wl_array_for_each macro inline as clang does not like to handle it's implicit typecast * Removed unecessary include that was automatically added by the ide * Replaced reinterpret_cast's with c-style casts --- meson.build | 5 +++-- src/core/PortalManager.cpp | 3 ++- src/portals/Screencopy.cpp | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 77c1a80..2fff319 100644 --- a/meson.build +++ b/meson.build @@ -25,10 +25,11 @@ endif add_project_arguments(cpp_compiler.get_supported_arguments([ '-Wno-missing-field-initializers', '-Wno-narrowing', - '-Wno-pointer-arith', + '-Wno-pointer-arith', '-Wno-unused-parameter', '-Wno-unused-value', - '-fpermissive' + '-fpermissive', + '-Wno-address-of-temporary' ]), language: 'cpp') conf_data = configuration_data() diff --git a/src/core/PortalManager.cpp b/src/core/PortalManager.cpp index d56ebe0..a03da31 100644 --- a/src/core/PortalManager.cpp +++ b/src/core/PortalManager.cpp @@ -169,7 +169,8 @@ static void dmabufFeedbackTrancheFormats(void* data, zwp_linux_dmabuf_feedback_v uint32_t n_modifiers = g_pPortalManager->m_sWaylandConnection.dma.formatTableSize / sizeof(struct fm_entry); fm_entry* fm_entry = (struct fm_entry*)g_pPortalManager->m_sWaylandConnection.dma.formatTable; uint16_t* idx; - wl_array_for_each(idx, indices) { + + for (idx = (uint16_t*)indices->data; (const char*)idx < (const char*)indices->data + indices->size; idx++) { if (*idx >= n_modifiers) continue; diff --git a/src/portals/Screencopy.cpp b/src/portals/Screencopy.cpp index c5b234c..d69d353 100644 --- a/src/portals/Screencopy.cpp +++ b/src/portals/Screencopy.cpp @@ -781,7 +781,7 @@ static void pwStreamParamChanged(void* data, uint32_t id, const spa_pod* param) const spa_pod* pod_modifier = &prop_modifier->value; uint32_t n_modifiers = SPA_POD_CHOICE_N_VALUES(pod_modifier) - 1; - uint64_t* modifiers = SPA_POD_CHOICE_VALUES(pod_modifier); + uint64_t* modifiers = (uint64_t*)SPA_POD_CHOICE_VALUES(pod_modifier); modifiers++; uint32_t flags = GBM_BO_USE_RENDERING; uint64_t modifier; @@ -853,14 +853,15 @@ static void pwStreamParamChanged(void* data, uint32_t id, const spa_pod* param) params[0] = build_buffer(&dynBuilder[0].b, blocks, PSTREAM->pSession->sharingData.frameInfoSHM.size, PSTREAM->pSession->sharingData.frameInfoSHM.stride, data_type); - params[1] = spa_pod_builder_add_object(&dynBuilder[1].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header), SPA_PARAM_META_size, - SPA_POD_Int(sizeof(struct spa_meta_header))); + params[1] = (const spa_pod*)spa_pod_builder_add_object(&dynBuilder[1].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header), + SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header))); - params[2] = spa_pod_builder_add_object(&dynBuilder[1].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoTransform), - SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_videotransform))); + params[2] = (const spa_pod*)spa_pod_builder_add_object(&dynBuilder[1].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoTransform), + SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_videotransform))); - params[3] = spa_pod_builder_add_object(&dynBuilder[2].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoDamage), SPA_PARAM_META_size, - SPA_POD_CHOICE_RANGE_Int(sizeof(struct spa_meta_region) * 4, sizeof(struct spa_meta_region) * 1, sizeof(struct spa_meta_region) * 4)); + params[3] = (const spa_pod*)spa_pod_builder_add_object( + &dynBuilder[2].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoDamage), SPA_PARAM_META_size, + SPA_POD_CHOICE_RANGE_Int(sizeof(struct spa_meta_region) * 4, sizeof(struct spa_meta_region) * 1, sizeof(struct spa_meta_region) * 4)); pw_stream_update_params(PSTREAM->stream, params, 4); spa_pod_dynamic_builder_clean(&dynBuilder[0]); @@ -1061,7 +1062,7 @@ uint32_t CPipewireConnection::buildFormatsFor(spa_pod_builder* b[2], const spa_p paramCount = 2; params[0] = build_format(b[0], pwFromDrmFourcc(stream->pSession->sharingData.frameInfoDMA.fmt), stream->pSession->sharingData.frameInfoDMA.w, - stream->pSession->sharingData.frameInfoDMA.h, stream->pSession->sharingData.framerate, modifiers, modCount); + stream->pSession->sharingData.frameInfoDMA.h, stream->pSession->sharingData.framerate, modifiers, modCount); assert(params[0] != NULL); params[1] = build_format(b[1], pwFromDrmFourcc(stream->pSession->sharingData.frameInfoSHM.fmt), stream->pSession->sharingData.frameInfoSHM.w, stream->pSession->sharingData.frameInfoSHM.h, stream->pSession->sharingData.framerate, NULL, 0); @@ -1071,7 +1072,7 @@ uint32_t CPipewireConnection::buildFormatsFor(spa_pod_builder* b[2], const spa_p paramCount = 1; params[0] = build_format(b[0], pwFromDrmFourcc(stream->pSession->sharingData.frameInfoSHM.fmt), stream->pSession->sharingData.frameInfoSHM.w, - stream->pSession->sharingData.frameInfoSHM.h, stream->pSession->sharingData.framerate, NULL, 0); + stream->pSession->sharingData.frameInfoSHM.h, stream->pSession->sharingData.framerate, NULL, 0); } return paramCount;