]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_amrwb] Fix scan-build 14 2449/head
authorJakub Karolczyk <jakub.karolczyk@signalwire.com>
Fri, 26 Apr 2024 13:11:54 +0000 (13:11 +0000)
committerJakub Karolczyk <jakub.karolczyk@signalwire.com>
Fri, 26 Apr 2024 13:11:54 +0000 (13:11 +0000)
src/mod/codecs/mod_amrwb/amrwb_be.c
src/mod/codecs/mod_amrwb/mod_amrwb.c

index 7b43b2b5837910eed9ba01fdd702707303632a2d..e8f45cf7d749545d06b759c030a27ee0f68f3066 100644 (file)
@@ -95,23 +95,23 @@ extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n)
 
 extern switch_bool_t switch_amrwb_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len)
 {
-       int framesz, index, ft;
+       int framesz, index;
        uint8_t shift_tocs[2] = {0x00, 0x00};
        uint8_t *shift_buf;
 
        memcpy(shift_tocs, encoded_buf, 2);
        /* shift for BE */
        switch_amr_array_lshift(4, shift_tocs, 2);
-       ft = shift_tocs[0] >> 3;
-       ft &= ~(1 << 5); /* Frame Type*/
        shift_buf = encoded_buf + 1; /* skip CMR */
        /* shift for BE */
        switch_amr_array_lshift(2, shift_buf, encoded_len - 1);
        /* get frame size */
        index = ((shift_tocs[0] >> 3) & 0x0f);
        if (index > 10 && index != 0xe && index != 0xf) {
+
                return SWITCH_FALSE;
        }
+
        framesz = switch_amrwb_frame_sizes[index];
        tmp[0] = shift_tocs[0]; /* save TOC */
        memcpy(&tmp[1], shift_buf, framesz);
index 4ac3f25f37a8e12523912a19998fe61851032b89..d89ec5d62bbe0d9c72e3cc09c316658cb512654d 100644 (file)
@@ -191,6 +191,7 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
        if (codec->fmtp_in) {
                codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
        }
+
        return SWITCH_STATUS_SUCCESS;
 #else
        struct amrwb_context *context = NULL;
@@ -204,6 +205,7 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
        decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
 
        if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct amrwb_context))))) {
+
                return SWITCH_STATUS_FALSE;
        } else {
 
@@ -296,6 +298,7 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
 
                        /* re-create mode-set */
                        fmtptmp_pos = switch_snprintf(fmtptmp, sizeof(fmtptmp), "mode-set=");
+
                        for (i = 0; SWITCH_AMRWB_MODES-1 > i; ++i) {
                                if (context->enc_modes & (1 << i)) {
                                        fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, fmtptmp_pos > strlen("mode-set=") ? ",%d" : "%d", i);
@@ -312,12 +315,13 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
                }
 
                if (!globals.volte) {
-                       fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d",
+                       switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d",
                                        switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0);
                } else {
-                       fmtptmp_pos += switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d;max-red=0;mode-change-capability=2",
+                       switch_snprintf(fmtptmp + fmtptmp_pos, sizeof(fmtptmp) - fmtptmp_pos, ";octet-align=%d;max-red=0;mode-change-capability=2",
                                        switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0);
                }
+
                codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
 
                context->encoder_state = NULL;