osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/41042?usp=email )


Change subject: gsm48_cc_tx_setup: remove extra bearer_cap var
......................................................................

gsm48_cc_tx_setup: remove extra bearer_cap var

Store the bearer capabilities directly in the transaction, instead of
storing them in a separate variable first, then copying it to the
transaction, then using both the separate variable and the copy in the
transaction later on. The extra variable is not needed and only makes it
more compilicated.

Add an explicit '.transfer = GSM48_BCAP_ITCAP_SPEECH,' while at it in
the speech case. This was already set implicitly because
GSM48_BCAP_ITCAP_SPEECH is 0.

Change-Id: I247ef10923c2875ca75e73046f4b8ed14190d4d2
---
M src/libmsc/gsm_04_08_cc.c
1 file changed, 11 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/42/41042/1

diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c
index a429bc4..63a9018 100644
--- a/src/libmsc/gsm_04_08_cc.c
+++ b/src/libmsc/gsm_04_08_cc.c
@@ -915,18 +915,18 @@
  * Versions) / CSD bearer services remaining after intersecting MS, BSS and
  * remote call leg restrictions. To store in trans for later use, and to
  * include in the outgoing CC Setup message. */
-static int gsm48_cc_tx_setup_set_bearer_cap(struct gsm_trans *trans, const 
struct gsm_mncc *setup,
-                                           struct gsm_mncc_bearer_cap 
*bearer_cap)
+static int gsm48_cc_tx_setup_set_bearer_cap(struct gsm_trans *trans, const 
struct gsm_mncc *setup)
 {
        int rc;

        switch (trans->bearer_cap.transfer) {
        case GSM48_BCAP_ITCAP_SPEECH:
-               *bearer_cap = (struct gsm_mncc_bearer_cap){
+               trans->bearer_cap = (struct gsm_mncc_bearer_cap){
+                       .transfer = GSM48_BCAP_ITCAP_SPEECH,
                        .speech_ver = { -1 },
                };
-               sdp_audio_codecs_to_bearer_cap(bearer_cap, 
&trans->cc.local.audio_codecs);
-               rc = bearer_cap_set_radio(bearer_cap);
+               sdp_audio_codecs_to_bearer_cap(&trans->bearer_cap, 
&trans->cc.local.audio_codecs);
+               rc = bearer_cap_set_radio(&trans->bearer_cap);
                if (rc) {
                        LOG_TRANS(trans, LOGL_ERROR, "Error composing Bearer 
Capability for CC Setup\n");
                        return -1;
@@ -936,7 +936,7 @@
                 * transcode, we could use non-identical codecs on each conn of
                 * the MGW endpoint, but we are aiming for finding a matching
                 * codec. */
-               if (bearer_cap->speech_ver[0] == -1) {
+               if (trans->bearer_cap.speech_ver[0] == -1) {
                        LOG_TRANS(trans, LOGL_ERROR, "%s: no codec match 
possible: %s\n",
                                  get_mncc_name(setup->msg_type),
                                  codec_filter_to_str(&trans->cc.codecs, 
&trans->cc.local, &trans->cc.remote));
@@ -948,7 +948,7 @@
                        trans->callref = 0;
                        return -1;
                }
-               rc = bearer_cap_filter_rev_lev(bearer_cap, 
trans->vsub->classmark.classmark1.rev_lev);
+               rc = bearer_cap_filter_rev_lev(&trans->bearer_cap, 
trans->vsub->classmark.classmark1.rev_lev);
                if (rc) {
                        LOG_TRANS(trans, LOGL_ERROR, "No codec offered is 
supported by phase 1 mobile.\n");
                        return -1;
@@ -957,14 +957,14 @@
        case GSM48_BCAP_ITCAP_3k1_AUDIO:
        case GSM48_BCAP_ITCAP_FAX_G3:
        case GSM48_BCAP_ITCAP_UNR_DIG_INF:
-               *bearer_cap = (struct gsm_mncc_bearer_cap){
+               trans->bearer_cap = (struct gsm_mncc_bearer_cap){
                        .transfer = trans->bearer_cap.transfer,
                        .mode = GSM48_BCAP_TMOD_CIRCUIT,
                        .coding = GSM48_BCAP_CODING_GSM_STD,
                        .radio = GSM48_BCAP_RRQ_FR_ONLY,
                };

-               if (csd_bs_list_to_bearer_cap(bearer_cap, 
&trans->cc.local.bearer_services) == 0) {
+               if (csd_bs_list_to_bearer_cap(&trans->bearer_cap, 
&trans->cc.local.bearer_services) == 0) {
                        LOG_TRANS(trans, LOGL_ERROR, "Error composing Bearer 
Capability for CC Setup\n");

                        /* incompatible codecs */
@@ -977,10 +977,6 @@
                break;
        }

-       /* Create a copy of the bearer capability in the transaction struct, so
-        * we can use this information later */
-       trans->bearer_cap = *bearer_cap;
-
        return 0;
 }

@@ -1030,7 +1026,6 @@
        struct msgb *msg;
        struct gsm_mncc *setup = arg;
        int rc;
-       struct gsm_mncc_bearer_cap bearer_cap;

        rc = gsm48_cc_tx_setup_set_transaction_id(trans);
        if (rc < 0)
@@ -1045,11 +1040,11 @@
        if (rc < 0)
                goto error;

-       rc = gsm48_cc_tx_setup_set_bearer_cap(trans, setup, &bearer_cap);
+       rc = gsm48_cc_tx_setup_set_bearer_cap(trans, setup);
        if (rc < 0)
                goto error;

-       msg = gsm48_cc_tx_setup_encode_msg(setup, &bearer_cap);
+       msg = gsm48_cc_tx_setup_encode_msg(setup, &trans->bearer_cap);

        new_cc_state(trans, GSM_CSTATE_CALL_PRESENT);


--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/41042?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I247ef10923c2875ca75e73046f4b8ed14190d4d2
Gerrit-Change-Number: 41042
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osm...@sysmocom.de>

Reply via email to