laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve laforge: Looks good to me, approved
osmux_output: Refactor init code to avoid calling deprecated APIs internally

Current internal use of APIs marked as deprecated seems to be causing
issues when building on debian unstable.

Simply rearrange the init code to an internal helper function to avoid
code duplication while still keeping the old deprecated APIs working as
they used to, without getting deprecation warnings at buildtime.

Related: OS#5677
Change-Id: Ie8e168740c0421edd96013620256aab0306dc6c5
---
M src/osmux_output.c
1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/osmux_output.c b/src/osmux_output.c
index 33d977b..c240578 100644
--- a/src/osmux_output.c
+++ b/src/osmux_output.c
@@ -294,6 +294,18 @@
return 0;
}

+/* Placeholder to avoid init code duplication while keeping backward
+ * compatilbility with deprecated osmux_xfrm_output_init{2}() APIs. */
+static void _osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc, uint8_t rtp_payload_type)
+{
+ h->rtp_seq = (uint16_t)random();
+ h->rtp_timestamp = (uint32_t)random();
+ h->rtp_ssrc = rtp_ssrc;
+ h->rtp_payload_type = rtp_payload_type;
+ INIT_LLIST_HEAD(&h->list);
+ osmo_timer_setup(&h->timer, osmux_xfrm_output_trigger, h);
+}
+
/*! \brief Allocate a new osmux out handle
* \param[in] ctx talloc context to use when allocating the returned struct
* \return Allocated osmux out handle
@@ -310,12 +322,7 @@
h = talloc_zero(ctx, struct osmux_out_handle);
OSMO_ASSERT(h);

- h->rtp_seq = (uint16_t)random();
- h->rtp_timestamp = (uint32_t)random();
- h->rtp_ssrc = (uint32_t)random();
- h->rtp_payload_type = 98;
- INIT_LLIST_HEAD(&h->list);
- osmo_timer_setup(&h->timer, osmux_xfrm_output_trigger, h);
+ _osmux_xfrm_output_init(h, (uint32_t)random(), 98);

talloc_set_destructor(h, osmux_xfrm_output_talloc_destructor);
return h;
@@ -325,19 +332,15 @@
void osmux_xfrm_output_init2(struct osmux_out_handle *h, uint32_t rtp_ssrc, uint8_t rtp_payload_type)
{
memset(h, 0, sizeof(*h));
- h->rtp_seq = (uint16_t)random();
- h->rtp_timestamp = (uint32_t)random();
- h->rtp_ssrc = rtp_ssrc;
- h->rtp_payload_type = rtp_payload_type;
- INIT_LLIST_HEAD(&h->list);
- osmo_timer_setup(&h->timer, osmux_xfrm_output_trigger, h);
+ _osmux_xfrm_output_init(h, rtp_ssrc, rtp_payload_type);
}

/* DEPRECATED: Use osmux_xfrm_output_alloc() and osmux_xfrm_output_set_rtp_*() instead */
void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc)
{
/* backward compatibility with old users, where 98 was harcoded in osmux_rebuild_rtp() */
- osmux_xfrm_output_init2(h, rtp_ssrc, 98);
+ memset(h, 0, sizeof(*h));
+ _osmux_xfrm_output_init(h, rtp_ssrc, 98);
}

/*! \brief Set transmission callback to call when a generated RTP packet is to be transmitted

To view, visit change 30292. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ie8e168740c0421edd96013620256aab0306dc6c5
Gerrit-Change-Number: 30292
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-MessageType: merged