]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
some proper casts after bit shifts to force to the right data type.
authorMichael Jerris <mike@jerris.com>
Wed, 18 Oct 2006 21:09:35 +0000 (21:09 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 18 Oct 2006 21:09:35 +0000 (21:09 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3081 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/codec/gsm/src/add.c
libs/codec/gsm/src/gsm_encode.c

index cc1b4b3624a549569b16696cce559b1d2af00760..28f57f30be69318026fb3aea392987b5a4e331b9 100644 (file)
@@ -161,9 +161,9 @@ longword gsm_L_asl P2((a,n), longword a, int n)
 word gsm_asl P2((a,n), word a, int n)
 {
        if (n >= 16) return 0;
-       if (n <= -16) return -(a < 0);
+       if (n <= -16) return -(word)(a < 0);
        if (n < 0) return gsm_asr(a, -n);
-       return a << n;
+       return (word)(a << n);
 }
 
 longword gsm_L_asr P2((a,n), longword a, int n)
@@ -182,12 +182,12 @@ longword gsm_L_asr P2((a,n), longword a, int n)
 
 word gsm_asr P2((a,n), word a, int n)
 {
-       if (n >= 16) return -(a < 0);
+       if (n >= 16) return -(word)(a < 0);
        if (n <= -16) return 0;
-       if (n < 0) return a << -n;
+       if (n < 0) return (word)(a << -n);
 
 #      ifdef   SASR
-               return a >> n;
+               return (word)(a >> n);
 #      else
                if (a >= 0) return a >> n;
                else return -(word)( -(uword)a >> n );
index 6876e13c5be8979d971517ae288bd4532dac37b2..99344ddce2b2471b144352ec1ab18d22e99668c2 100644 (file)
@@ -347,106 +347,106 @@ void gsm_encode P3((s, source, c), gsm s, gsm_signal * source, gsm_byte * c)
 #endif /* WAV49 */
        {
 
-               *c++ =   ((GSM_MAGIC & 0xF) << 4)               /* 1 */
-                      | ((LARc[0] >> 2) & 0xF);
-               *c++ =   ((LARc[0] & 0x3) << 6)
-                      | (LARc[1] & 0x3F);
-               *c++ =   ((LARc[2] & 0x1F) << 3)
-                      | ((LARc[3] >> 2) & 0x7);
-               *c++ =   ((LARc[3] & 0x3) << 6)
+               *c++ =   (gsm_byte)(((GSM_MAGIC & 0xF) << 4)            /* 1 */
+                      | ((LARc[0] >> 2) & 0xF));
+               *c++ =   (gsm_byte)(((LARc[0] & 0x3) << 6)
+                      | (LARc[1] & 0x3F));
+               *c++ =   (gsm_byte)(((LARc[2] & 0x1F) << 3)
+                      | ((LARc[3] >> 2) & 0x7));
+               *c++ =   (gsm_byte)(((LARc[3] & 0x3) << 6)
                       | ((LARc[4] & 0xF) << 2)
-                      | ((LARc[5] >> 2) & 0x3);
-               *c++ =   ((LARc[5] & 0x3) << 6)
+                      | ((LARc[5] >> 2) & 0x3));
+               *c++ =   (gsm_byte)(((LARc[5] & 0x3) << 6)
                       | ((LARc[6] & 0x7) << 3)
-                      | (LARc[7] & 0x7);
-               *c++ =   ((Nc[0] & 0x7F) << 1)
-                      | ((bc[0] >> 1) & 0x1);
-               *c++ =   ((bc[0] & 0x1) << 7)
+                      | (LARc[7] & 0x7));
+               *c++ =   (gsm_byte)(((Nc[0] & 0x7F) << 1)
+                      | ((bc[0] >> 1) & 0x1));
+               *c++ =   (gsm_byte)(((bc[0] & 0x1) << 7)
                       | ((Mc[0] & 0x3) << 5)
-                      | ((xmaxc[0] >> 1) & 0x1F);
-               *c++ =   ((xmaxc[0] & 0x1) << 7)
+                      | ((xmaxc[0] >> 1) & 0x1F));
+               *c++ =   (gsm_byte)(((xmaxc[0] & 0x1) << 7)
                       | ((xmc[0] & 0x7) << 4)
                       | ((xmc[1] & 0x7) << 1)
-                      | ((xmc[2] >> 2) & 0x1);
-               *c++ =   ((xmc[2] & 0x3) << 6)
+                      | ((xmc[2] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[2] & 0x3) << 6)
                       | ((xmc[3] & 0x7) << 3)
-                      | (xmc[4] & 0x7);
-               *c++ =   ((xmc[5] & 0x7) << 5)                  /* 10 */
+                      | (xmc[4] & 0x7));
+               *c++ =   (gsm_byte)(((xmc[5] & 0x7) << 5)                       /* 10 */
                       | ((xmc[6] & 0x7) << 2)
-                      | ((xmc[7] >> 1) & 0x3);
-               *c++ =   ((xmc[7] & 0x1) << 7)
+                      | ((xmc[7] >> 1) & 0x3));
+               *c++ =   (gsm_byte)(((xmc[7] & 0x1) << 7)
                       | ((xmc[8] & 0x7) << 4)
                       | ((xmc[9] & 0x7) << 1)
-                      | ((xmc[10] >> 2) & 0x1);
-               *c++ =   ((xmc[10] & 0x3) << 6)
+                      | ((xmc[10] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[10] & 0x3) << 6)
                       | ((xmc[11] & 0x7) << 3)
-                      | (xmc[12] & 0x7);
-               *c++ =   ((Nc[1] & 0x7F) << 1)
-                      | ((bc[1] >> 1) & 0x1);
-               *c++ =   ((bc[1] & 0x1) << 7)
+                      | (xmc[12] & 0x7));
+               *c++ =   (gsm_byte)(((Nc[1] & 0x7F) << 1)
+                      | ((bc[1] >> 1) & 0x1));
+               *c++ =   (gsm_byte)(((bc[1] & 0x1) << 7)
                       | ((Mc[1] & 0x3) << 5)
-                      | ((xmaxc[1] >> 1) & 0x1F);
-               *c++ =   ((xmaxc[1] & 0x1) << 7)
+                      | ((xmaxc[1] >> 1) & 0x1F));
+               *c++ =   (gsm_byte)(((xmaxc[1] & 0x1) << 7)
                       | ((xmc[13] & 0x7) << 4)
                       | ((xmc[14] & 0x7) << 1)
-                      | ((xmc[15] >> 2) & 0x1);
-               *c++ =   ((xmc[15] & 0x3) << 6)
+                      | ((xmc[15] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[15] & 0x3) << 6)
                       | ((xmc[16] & 0x7) << 3)
-                      | (xmc[17] & 0x7);
-               *c++ =   ((xmc[18] & 0x7) << 5)
+                      | (xmc[17] & 0x7));
+               *c++ =   (gsm_byte)(((xmc[18] & 0x7) << 5)
                       | ((xmc[19] & 0x7) << 2)
-                      | ((xmc[20] >> 1) & 0x3);
-               *c++ =   ((xmc[20] & 0x1) << 7)
+                      | ((xmc[20] >> 1) & 0x3));
+               *c++ =   (gsm_byte)(((xmc[20] & 0x1) << 7)
                       | ((xmc[21] & 0x7) << 4)
                       | ((xmc[22] & 0x7) << 1)
-                      | ((xmc[23] >> 2) & 0x1);
-               *c++ =   ((xmc[23] & 0x3) << 6)
+                      | ((xmc[23] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[23] & 0x3) << 6)
                       | ((xmc[24] & 0x7) << 3)
-                      | (xmc[25] & 0x7);
-               *c++ =   ((Nc[2] & 0x7F) << 1)                  /* 20 */
-                      | ((bc[2] >> 1) & 0x1);
-               *c++ =   ((bc[2] & 0x1) << 7)
+                      | (xmc[25] & 0x7));
+               *c++ =   (gsm_byte)(((Nc[2] & 0x7F) << 1)                       /* 20 */
+                      | ((bc[2] >> 1) & 0x1));
+               *c++ =   (gsm_byte)(((bc[2] & 0x1) << 7)
                       | ((Mc[2] & 0x3) << 5)
-                      | ((xmaxc[2] >> 1) & 0x1F);
-               *c++ =   ((xmaxc[2] & 0x1) << 7)
+                      | ((xmaxc[2] >> 1) & 0x1F));
+               *c++ =   (gsm_byte)(((xmaxc[2] & 0x1) << 7)
                       | ((xmc[26] & 0x7) << 4)
                       | ((xmc[27] & 0x7) << 1)
-                      | ((xmc[28] >> 2) & 0x1);
-               *c++ =   ((xmc[28] & 0x3) << 6)
+                      | ((xmc[28] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[28] & 0x3) << 6)
                       | ((xmc[29] & 0x7) << 3)
-                      | (xmc[30] & 0x7);
-               *c++ =   ((xmc[31] & 0x7) << 5)
+                      | (xmc[30] & 0x7));
+               *c++ =   (gsm_byte)(((xmc[31] & 0x7) << 5)
                       | ((xmc[32] & 0x7) << 2)
-                      | ((xmc[33] >> 1) & 0x3);
-               *c++ =   ((xmc[33] & 0x1) << 7)
+                      | ((xmc[33] >> 1) & 0x3));
+               *c++ =   (gsm_byte)(((xmc[33] & 0x1) << 7)
                       | ((xmc[34] & 0x7) << 4)
                       | ((xmc[35] & 0x7) << 1)
-                      | ((xmc[36] >> 2) & 0x1);
-               *c++ =   ((xmc[36] & 0x3) << 6)
+                      | ((xmc[36] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[36] & 0x3) << 6)
                       | ((xmc[37] & 0x7) << 3)
-                      | (xmc[38] & 0x7);
-               *c++ =   ((Nc[3] & 0x7F) << 1)
-                      | ((bc[3] >> 1) & 0x1);
-               *c++ =   ((bc[3] & 0x1) << 7)
+                      | (xmc[38] & 0x7));
+               *c++ =   (gsm_byte)(((Nc[3] & 0x7F) << 1)
+                      | ((bc[3] >> 1) & 0x1));
+               *c++ =   (gsm_byte)(((bc[3] & 0x1) << 7)
                       | ((Mc[3] & 0x3) << 5)
-                      | ((xmaxc[3] >> 1) & 0x1F);
-               *c++ =   ((xmaxc[3] & 0x1) << 7)
+                      | ((xmaxc[3] >> 1) & 0x1F));
+               *c++ =   (gsm_byte)(((xmaxc[3] & 0x1) << 7)
                       | ((xmc[39] & 0x7) << 4)
                       | ((xmc[40] & 0x7) << 1)
-                      | ((xmc[41] >> 2) & 0x1);
-               *c++ =   ((xmc[41] & 0x3) << 6)                 /* 30 */
+                      | ((xmc[41] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[41] & 0x3) << 6)                      /* 30 */
                       | ((xmc[42] & 0x7) << 3)
-                      | (xmc[43] & 0x7);
-               *c++ =   ((xmc[44] & 0x7) << 5)
+                      | (xmc[43] & 0x7));
+               *c++ =   (gsm_byte)(((xmc[44] & 0x7) << 5)
                       | ((xmc[45] & 0x7) << 2)
-                      | ((xmc[46] >> 1) & 0x3);
-               *c++ =   ((xmc[46] & 0x1) << 7)
+                      | ((xmc[46] >> 1) & 0x3));
+               *c++ =   (gsm_byte)(((xmc[46] & 0x1) << 7)
                       | ((xmc[47] & 0x7) << 4)
                       | ((xmc[48] & 0x7) << 1)
-                      | ((xmc[49] >> 2) & 0x1);
-               *c++ =   ((xmc[49] & 0x3) << 6)
+                      | ((xmc[49] >> 2) & 0x1));
+               *c++ =   (gsm_byte)(((xmc[49] & 0x3) << 6)
                       | ((xmc[50] & 0x7) << 3)
-                      | (xmc[51] & 0x7);
+                      | (xmc[51] & 0x7));
 
        }
 }