[MERGED] osmo-sip-connector[master]: mncc: use 'const' to denote read-only input buffer/message

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
Tue Mar 27 06:13:01 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: mncc: use 'const' to denote read-only input buffer/message
......................................................................


mncc: use 'const' to denote read-only input buffer/message

We normally use the 'const' modifier whenever using read-only input
data, let's do so in the mncc parser/handler, too.

Change-Id: Ide24feb536c04fe7ef08c62b4498fdd95605b58c
---
M src/mncc.c
1 file changed, 37 insertions(+), 37 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/mncc.c b/src/mncc.c
index 66c73a3..c0c082b 100644
--- a/src/mncc.c
+++ b/src/mncc.c
@@ -319,9 +319,9 @@
 	return continue_mt_call(leg);
 }
 
-static void check_rtp_connect(struct mncc_connection *conn, char *buf, int rc)
+static void check_rtp_connect(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc_rtp *rtp;
+	const struct gsm_mncc_rtp *rtp;
 	struct mncc_call_leg *leg;
 	struct call_leg *other_leg;
 
@@ -331,7 +331,7 @@
 		return close_connection(conn);
 	}
 
-	rtp = (struct gsm_mncc_rtp *) buf;
+	rtp = (const struct gsm_mncc_rtp *) buf;
 	leg = mncc_find_leg(rtp->callref);
 	if (!leg) {
 		LOGP(DMNCC, LOGL_ERROR, "leg(%u) can not be found\n", rtp->callref);
@@ -350,9 +350,9 @@
 	leg->base.release_call(&leg->base);
 }
 
-static void check_rtp_create(struct mncc_connection *conn, char *buf, int rc)
+static void check_rtp_create(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc_rtp *rtp;
+	const struct gsm_mncc_rtp *rtp;
 	struct mncc_call_leg *leg;
 
 	if (rc < sizeof(*rtp)) {
@@ -361,7 +361,7 @@
 		return close_connection(conn);
 	}
 
-	rtp = (struct gsm_mncc_rtp *) buf;
+	rtp = (const struct gsm_mncc_rtp *) buf;
 	leg = mncc_find_leg(rtp->callref);
 	if (!leg) {
 		LOGP(DMNCC, LOGL_ERROR, "call(%u) can not be found\n", rtp->callref);
@@ -383,7 +383,7 @@
 	continue_call(leg);
 }
 
-static int continue_setup(struct mncc_connection *conn, struct gsm_mncc *mncc)
+static int continue_setup(struct mncc_connection *conn, const struct gsm_mncc *mncc)
 {
 	if (mncc->called.plan != GSM340_PLAN_ISDN) {
 		LOGP(DMNCC, LOGL_ERROR,
@@ -396,9 +396,9 @@
 }
 
 /* Check + Process MNCC_SETUP_IND (MO call) */
-static void check_setup(struct mncc_connection *conn, char *buf, int rc)
+static void check_setup(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct call *call;
 	struct mncc_call_leg *leg;
 
@@ -408,7 +408,7 @@
 		return close_connection(conn);
 	}
 
-	data = (struct gsm_mncc *) buf;
+	data = (const struct gsm_mncc *) buf;
 
 	/* screen arguments */
 	if ((data->fields & MNCC_F_CALLED) == 0) {
@@ -466,7 +466,7 @@
  *  \param[out] mncc return pointer to MNCC message
  *  \returns call leg (if found) or NULL */
 static struct mncc_call_leg *find_leg(struct mncc_connection *conn,
-					char *buf, int rc, struct gsm_mncc **mncc)
+					const char *buf, int rc, const struct gsm_mncc **mncc)
 {
 	struct mncc_call_leg *leg;
 
@@ -477,7 +477,7 @@
 		return NULL;
 	}
 
-	*mncc = (struct gsm_mncc *) buf;
+	*mncc = (const struct gsm_mncc *) buf;
 	leg = mncc_find_leg((*mncc)->callref);
 	if (!leg) {
 		LOGP(DMNCC, LOGL_ERROR, "call(%u) can not be found\n", (*mncc)->callref);
@@ -487,9 +487,9 @@
 	return leg;
 }
 
-static void check_disc_ind(struct mncc_connection *conn, char *buf, int rc)
+static void check_disc_ind(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 	struct call_leg *other_leg;
 
@@ -508,9 +508,9 @@
 		other_leg->release_call(other_leg);
 }
 
-static void check_rel_ind(struct mncc_connection *conn, char *buf, int rc)
+static void check_rel_ind(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 
 	leg = find_leg(conn, buf, rc, &data);
@@ -529,9 +529,9 @@
 	mncc_leg_release(leg);
 }
 
-static void check_rel_cnf(struct mncc_connection *conn, char *buf, int rc)
+static void check_rel_cnf(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 
 	leg = find_leg(conn, buf, rc, &data);
@@ -543,9 +543,9 @@
 	mncc_leg_release(leg);
 }
 
-static void check_stp_cmpl_ind(struct mncc_connection *conn, char *buf, int rc)
+static void check_stp_cmpl_ind(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 
 	leg = find_leg(conn, buf, rc, &data);
@@ -557,9 +557,9 @@
 	leg->state = MNCC_CC_CONNECTED;
 }
 
-static void check_rej_ind(struct mncc_connection *conn, char *buf, int rc)
+static void check_rej_ind(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 	struct call_leg *other_leg;
 
@@ -574,9 +574,9 @@
 	mncc_leg_release(leg);
 }
 
-static void check_cnf_ind(struct mncc_connection *conn, char *buf, int rc)
+static void check_cnf_ind(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 
 	leg = find_leg(conn, buf, rc, &data);
@@ -591,9 +591,9 @@
 	mncc_rtp_send(conn, MNCC_RTP_CREATE, data->callref);
 }
 
-static void check_alrt_ind(struct mncc_connection *conn, char *buf, int rc)
+static void check_alrt_ind(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 	struct call_leg *other_leg;
 
@@ -615,9 +615,9 @@
 	other_leg->ring_call(other_leg);
 }
 
-static void check_hold_ind(struct mncc_connection *conn, char *buf, int rc)
+static void check_hold_ind(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 
 	leg = find_leg(conn, buf, rc, &data);
@@ -629,9 +629,9 @@
 	mncc_send(leg->conn, MNCC_HOLD_REJ, leg->callref);
 }
 
-static void check_stp_cnf(struct mncc_connection *conn, char *buf, int rc)
+static void check_stp_cnf(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 	struct call_leg *other_leg;
 
@@ -657,10 +657,10 @@
 	other_leg->connect_call(other_leg);
 }
 
-static void check_dtmf_start(struct mncc_connection *conn, char *buf, int rc)
+static void check_dtmf_start(struct mncc_connection *conn, const char *buf, int rc)
 {
 	struct gsm_mncc out_mncc = { 0, };
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 	struct call_leg *other_leg;
 
@@ -680,10 +680,10 @@
 	mncc_write(conn, &out_mncc, leg->callref);
 }
 
-static void check_dtmf_stop(struct mncc_connection *conn, char *buf, int rc)
+static void check_dtmf_stop(struct mncc_connection *conn, const char *buf, int rc)
 {
 	struct gsm_mncc out_mncc = { 0, };
-	struct gsm_mncc *data;
+	const struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
 
 	leg = find_leg(conn, buf, rc, &data);
@@ -698,9 +698,9 @@
 	mncc_write(conn, &out_mncc, leg->callref);
 }
 
-static void check_hello(struct mncc_connection *conn, char *buf, int rc)
+static void check_hello(struct mncc_connection *conn, const char *buf, int rc)
 {
-	struct gsm_mncc_hello *hello;
+	const struct gsm_mncc_hello *hello;
 
 	if (rc != sizeof(*hello)) {
 		LOGP(DMNCC, LOGL_ERROR, "Hello shorter than expected %d vs. %zu\n",
@@ -708,7 +708,7 @@
 		return close_connection(conn);
 	}
 
-	hello = (struct gsm_mncc_hello *) buf;
+	hello = (const struct gsm_mncc_hello *) buf;
 	LOGP(DMNCC, LOGL_NOTICE, "Got hello message version %d\n", hello->version);
 
 	if (hello->version != MNCC_SOCK_VERSION) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ide24feb536c04fe7ef08c62b4498fdd95605b58c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list