OSDN Git Service

sbc: Fix SBC to compile cleanly with -Wsign-compare
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 29 Jan 2009 23:02:58 +0000 (00:02 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 30 Jul 2012 02:48:28 +0000 (19:48 -0700)
sbc/sbc.c

index 29f1d14..29258d0 100644 (file)
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -362,7 +362,7 @@ static void sbc_calculate_bits(const struct sbc_frame *frame, int (*bits)[8])
 static int sbc_unpack_frame(const uint8_t *data, struct sbc_frame *frame,
                                size_t len)
 {
-       int consumed;
+       unsigned int consumed;
        /* Will copy the parts of the header that are relevant to crc
         * calculation here */
        uint8_t crc_header[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -794,7 +794,7 @@ static SBC_ALWAYS_INLINE int sbc_pack_frame_internal(
                /* like frame->sb_sample but joint stereo */
                int32_t sb_sample_j[16][2];
                /* scalefactor and scale_factor in joint case */
-               u_int32_t scalefactor_j[2];
+               uint32_t scalefactor_j[2];
                uint8_t scale_factor_j[2];
 
                uint8_t joint = 0;
@@ -807,6 +807,7 @@ static SBC_ALWAYS_INLINE int sbc_pack_frame_internal(
                        scalefactor_j[1] = 2 << SCALE_OUT_BITS;
 
                        for (blk = 0; blk < frame->blocks; blk++) {
+                               uint32_t tmp;
                                /* Calculate joint stereo signal */
                                sb_sample_j[blk][0] =
                                        ASR(frame->sb_sample_f[blk][0][sb], 1) +
@@ -816,11 +817,13 @@ static SBC_ALWAYS_INLINE int sbc_pack_frame_internal(
                                        ASR(frame->sb_sample_f[blk][1][sb], 1);
 
                                /* calculate scale_factor_j and scalefactor_j for joint case */
-                               while (scalefactor_j[0] < fabs(sb_sample_j[blk][0])) {
+                               tmp = fabs(sb_sample_j[blk][0]);
+                               while (scalefactor_j[0] < tmp) {
                                        scale_factor_j[0]++;
                                        scalefactor_j[0] *= 2;
                                }
-                               while (scalefactor_j[1] < fabs(sb_sample_j[blk][1])) {
+                               tmp = fabs(sb_sample_j[blk][1]);
+                               while (scalefactor_j[1] < tmp) {
                                        scale_factor_j[1]++;
                                        scalefactor_j[1] *= 2;
                                }