laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/28121 )

Change subject: coding: use switch statement in gsm0503_tch_a[fh]s_decode_dtx()
......................................................................

coding: use switch statement in gsm0503_tch_a[fh]s_decode_dtx()

Change-Id: Ib63b6f582b305746c3618563f2f85128fffd8e90
Related: SYS#5853
---
M src/coding/gsm0503_coding.c
1 file changed, 20 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve



diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 329a076..6f19ed9 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -2187,12 +2187,15 @@
                osmo_sbit2ubit(cBd, cB, 456);
                *dtx = gsm0503_detect_afs_dtx_frame(n_errors, n_bits_total, 
cBd);

-               if (dtx_prev == AFS_SID_UPDATE && *dtx == AMR_OTHER) {
+               switch (*dtx) {
+               case AMR_OTHER:
                        /* NOTE: The AFS_SID_UPDATE frame is splitted into
                         * two half rate frames. If the id marker frame
                         * (AFS_SID_UPDATE) is detected the following frame
                         * contains the actual comfort noised data part of
                         * (AFS_SID_UPDATE_CN). */
+                       if (dtx_prev != AFS_SID_UPDATE)
+                               break;
                        *dtx = AFS_SID_UPDATE_CN;
 
                        extract_afs_sid_update(sid_update_enc, cB);
@@ -2212,16 +2215,18 @@
                        tch_amr_reassemble(tch_data, conv, 39);
                        len = 5;
                        goto out;
-               } else if (*dtx == AFS_SID_FIRST) {
+               case AFS_SID_FIRST:
                        tch_amr_sid_update_append(sid_first_dummy, 0,
                                                  (codec_mode_req) ? codec[*ft]
                                                  : codec[id]);
                        tch_amr_reassemble(tch_data, conv, 39);
                        len = 5;
                        goto out;
-               } else if (*dtx == AFS_ONSET) {
+               case AFS_ONSET:
                        len = 0;
                        goto out;
+               default:
+                       break;
                }
        }

@@ -2662,12 +2667,15 @@
                osmo_sbit2ubit(cBd, cB, 456);
                *dtx = gsm0503_detect_ahs_dtx_frame(n_errors, n_bits_total, 
cBd);

-               if (dtx_prev == AHS_SID_UPDATE && *dtx == AMR_OTHER) {
+               switch (*dtx) {
+               case AMR_OTHER:
                        /* NOTE: The AHS_SID_UPDATE frame is splitted into
                         * two half rate frames. If the id marker frame
                         * (AHS_SID_UPDATE) is detected the following frame
                         * contains the actual comfort noised data part of
                         * (AHS_SID_UPDATE_CN). */
+                       if (dtx_prev != AHS_SID_UPDATE)
+                               break;
                        *dtx = AHS_SID_UPDATE_CN;

                        osmo_conv_decode_ber(&gsm0503_tch_axs_sid_update,
@@ -2686,19 +2694,22 @@
                        tch_amr_reassemble(tch_data, conv, 39);
                        len = 5;
                        goto out;
-               } else if (*dtx == AHS_SID_FIRST_P2) {
+               case AHS_SID_FIRST_P2:
                        tch_amr_sid_update_append(sid_first_dummy, 0,
                                                  (codec_mode_req) ? codec[*ft]
                                                  : codec[id]);
                        tch_amr_reassemble(tch_data, sid_first_dummy, 39);
                        len = 5;
                        goto out;
-               } else if (*dtx == AHS_SID_UPDATE || *dtx == AHS_ONSET
-                          || *dtx == AHS_SID_FIRST_INH
-                          || *dtx == AHS_SID_UPDATE_INH
-                          || *dtx == AHS_SID_FIRST_P1) {
+               case AHS_SID_UPDATE:
+               case AHS_ONSET:
+               case AHS_SID_FIRST_INH:
+               case AHS_SID_UPDATE_INH:
+               case AHS_SID_FIRST_P1:
                        len = 0;
                        goto out;
+               default:
+                       break;
                }
        }


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/28121
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib63b6f582b305746c3618563f2f85128fffd8e90
Gerrit-Change-Number: 28121
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to