mgcp_conn: do not touch u.rtp in mgcp_conn_alloc()
The function mgcp_conn_alloc() calls mgcp_rtp_conn_init() to initalize
the RTP specific members (union u.rtp) but also touches u.rtp directly.
This should not be the case, only mgcp_rtp_conn_init() may touch the
union depending on which type of RTP connection is initialized
(currently there is only MGCP_CONN_TYPE_RTP).
- let mgcp_rtp_conn_init() set the backpointer to the generic
conn part.
Change-Id: I6f806f9bfa71b446c15bdc34ae59d2bc1cd10d7e
Note: This is merely a cosmetic change.
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index cfd8170..9491213 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -84,12 +84,15 @@
}
/* Initialize rtp connection struct with default values */
-static void mgcp_rtp_conn_init(struct mgcp_conn_rtp *conn)
+static void mgcp_rtp_conn_init(struct mgcp_conn_rtp *conn_rtp, struct mgcp_conn *conn)
{
- struct mgcp_rtp_end *end = &conn->end;
+ struct mgcp_rtp_end *end = &conn_rtp->end;
- conn->type = MGCP_RTP_DEFAULT;
- conn->osmux.allocated_cid = -1;
+ conn_rtp->type = MGCP_RTP_DEFAULT;
+ conn_rtp->osmux.allocated_cid = -1;
+
+ /* backpointer to the generic part of the connection */
+ conn->u.rtp.conn = conn;
end->rtp.fd = -1;
end->rtcp.fd = -1;
@@ -131,7 +134,6 @@
conn->type = type;
conn->mode = MGCP_CONN_NONE;
conn->mode_orig = MGCP_CONN_NONE;
- conn->u.rtp.conn = conn;
osmo_strlcpy(conn->name, name, sizeof(conn->name));
rc = mgcp_alloc_id(endp, conn->id);
if (rc < 0) {
@@ -141,7 +143,7 @@
switch (type) {
case MGCP_CONN_TYPE_RTP:
- mgcp_rtp_conn_init(&conn->u.rtp);
+ mgcp_rtp_conn_init(&conn->u.rtp, conn);
break;
default:
/* NOTE: This should never be called with an