[MERGED] osmo-mgw[master]: mgcp_conn: do not touch u.rtp in mgcp_conn_alloc()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Mar 19 20:33:19 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: mgcp_conn: do not touch u.rtp in mgcp_conn_alloc()
......................................................................


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.
---
M src/libosmo-mgcp/mgcp_conn.c
1 file changed, 8 insertions(+), 6 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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

-- 
To view, visit https://gerrit.osmocom.org/7393
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6f806f9bfa71b446c15bdc34ae59d2bc1cd10d7e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list