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
pull/1776/head
Richard Fuchs 2 years ago
parent c9c6117c66
commit 949c5a9d8e

@ -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, /* first add those mentioned in the order list,
* but only, if they were previously generated/added to the sdes_out */ * 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; str * cs_name = l->data;
struct crypto_params_sdes * cps_order; 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 */ 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; str * cs_name = l->data;
__auto_type elem = t_queue_find_custom(&offered_cpq_orig_list, cs_name, crypto_params_sdes_cmp); __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); __call_monologue_init_from_flags(dst_ml, flags);
g_auto(GQueue) mls = G_QUEUE_INIT; /* to avoid duplications */ 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 media_subscription *ms = sl->data;
struct call_monologue *src_ml = ms->monologue; struct call_monologue *src_ml = ms->monologue;

@ -2299,7 +2299,7 @@ static void ng_stats_media(bencode_item_t *list, const struct call_media *m,
BF_M("generator/sink", GENERATOR); BF_M("generator/sink", GENERATOR);
stats: 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; ps = l->data;
ng_stats_stream(streams, ps, totals); ng_stats_stream(streams, ps, totals);
} }

@ -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) // 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) { 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 *src_pt = l->data;
const rtp_payload_type *dst_pt = t_hash_table_lookup(dst->codecs, const rtp_payload_type *dst_pt = t_hash_table_lookup(dst->codecs,
GINT_TO_POINTER(src_pt->payload_type)); GINT_TO_POINTER(src_pt->payload_type));

@ -1748,7 +1748,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
unsigned int num = 0; unsigned int num = 0;
struct sdp_attribute *attr; 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; session = l->data;
for (__auto_type k = session->media_streams.head; k; k = k->next) { for (__auto_type k = session->media_streams.head; k; k = k->next) {

@ -218,7 +218,7 @@ INLINE void crypto_params_sdes_queue_clear(sdes_q *q) {
t_queue_clear_full(q, crypto_params_sdes_free); t_queue_clear_full(q, crypto_params_sdes_free);
} }
INLINE void crypto_params_sdes_queue_copy(sdes_q *dst, const sdes_q *src) { 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 *cps = l->data;
struct crypto_params_sdes *cpy = g_slice_alloc(sizeof(*cpy)); struct crypto_params_sdes *cpy = g_slice_alloc(sizeof(*cpy));
*cpy = *cps; *cpy = *cps;

@ -81,6 +81,7 @@ int num_cpu_cores(int);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(char, g_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(char, g_free)
typedef char *char_p; typedef char *char_p;
G_DEFINE_AUTOPTR_CLEANUP_FUNC(char_p, g_strfreev) 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 ***/ /*** STRING HELPERS ***/

Loading…
Cancel
Save