From 949c5a9d8e11a2d7489db83c9607981c3ed3515f Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 14 Dec 2023 11:53:24 -0500 Subject: [PATCH] MT#55283 work around gcc <12 being stupid gcc <12 propagates the const-ness of the given value to the newly declared variable with __auto_type, leading to silly "can't assign to const variable" errors. Work around this with an ugly macro. Change-Id: Ic952c094c24bd802379fc10ad19d559613b2c1d0 --- daemon/call.c | 6 +++--- daemon/call_interfaces.c | 2 +- daemon/codec.c | 2 +- daemon/sdp.c | 2 +- include/crypto.h | 2 +- lib/auxlib.h | 1 + 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index e0cecaf62..9379c7f91 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1664,7 +1664,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this /* first add those mentioned in the order list, * but only, if they were previously generated/added to the sdes_out */ - for (__auto_type l = cpq_order->head; l; l = l->next) + for (auto_iter(l, cpq_order->head); l; l = l->next) { str * cs_name = l->data; struct crypto_params_sdes * cps_order; @@ -1702,7 +1702,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this t_queue_init(offered_cpq); /* re-initialize offered crypto suites */ - for (__auto_type l = offered_order->head; l; l = l->next) + for (auto_iter(l, offered_order->head); l; l = l->next) { str * cs_name = l->data; __auto_type elem = t_queue_find_custom(&offered_cpq_orig_list, cs_name, crypto_params_sdes_cmp); @@ -3326,7 +3326,7 @@ int monologue_subscribe_request(const subscription_q *srms, struct call_monologu __call_monologue_init_from_flags(dst_ml, flags); g_auto(GQueue) mls = G_QUEUE_INIT; /* to avoid duplications */ - for (__auto_type sl = srms->head; sl; sl = sl->next) + for (auto_iter(sl, srms->head); sl; sl = sl->next) { struct media_subscription *ms = sl->data; struct call_monologue *src_ml = ms->monologue; diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 60da364d6..9b816f2f3 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -2299,7 +2299,7 @@ static void ng_stats_media(bencode_item_t *list, const struct call_media *m, BF_M("generator/sink", GENERATOR); stats: - for (__auto_type l = m->streams.head; l; l = l->next) { + for (auto_iter(l, m->streams.head); l; l = l->next) { ps = l->data; ng_stats_stream(streams, ps, totals); } diff --git a/daemon/codec.c b/daemon/codec.c index aa8a6c2b6..14048d37d 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -5616,7 +5616,7 @@ void codec_store_synthesise(struct codec_store *dst, struct codec_store *opposit // check all codecs listed in the source are also be present in the answer (dst) bool codec_store_is_full_answer(const struct codec_store *src, const struct codec_store *dst) { - for (__auto_type l = src->codec_prefs.head; l; l = l->next) { + for (auto_iter(l, src->codec_prefs.head); l; l = l->next) { const rtp_payload_type *src_pt = l->data; const rtp_payload_type *dst_pt = t_hash_table_lookup(dst->codecs, GINT_TO_POINTER(src_pt->payload_type)); diff --git a/daemon/sdp.c b/daemon/sdp.c index 781df3d6f..5eca391da 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1748,7 +1748,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f unsigned int num = 0; struct sdp_attribute *attr; - for (__auto_type l = sessions->head; l; l = l->next) { + for (auto_iter(l, sessions->head); l; l = l->next) { session = l->data; for (__auto_type k = session->media_streams.head; k; k = k->next) { diff --git a/include/crypto.h b/include/crypto.h index 1662f5d16..f74a9ed9e 100644 --- a/include/crypto.h +++ b/include/crypto.h @@ -218,7 +218,7 @@ INLINE void crypto_params_sdes_queue_clear(sdes_q *q) { t_queue_clear_full(q, crypto_params_sdes_free); } INLINE void crypto_params_sdes_queue_copy(sdes_q *dst, const sdes_q *src) { - for (__auto_type l = src->head; l; l = l->next) { + for (auto_iter(l, src->head); l; l = l->next) { struct crypto_params_sdes *cps = l->data; struct crypto_params_sdes *cpy = g_slice_alloc(sizeof(*cpy)); *cpy = *cps; diff --git a/lib/auxlib.h b/lib/auxlib.h index 78130f2a7..6e4a477a5 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -81,6 +81,7 @@ int num_cpu_cores(int); G_DEFINE_AUTOPTR_CLEANUP_FUNC(char, g_free) typedef char *char_p; G_DEFINE_AUTOPTR_CLEANUP_FUNC(char_p, g_strfreev) +#define auto_iter(v, l) __typeof__ ( ({ __typeof__ (*l) __t; &__t; }) ) v = (l) /* for gcc <12 */ /*** STRING HELPERS ***/