From 422e29017c00a74cd74970c4d0c326bb1c102250 Mon Sep 17 00:00:00 2001 From: Ronny Chevalier Date: Thu, 17 Jul 2014 14:43:29 +0200 Subject: [PATCH] stb_vorbis: fix signed/unsigned comparison --- stb_vorbis.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/stb_vorbis.c b/stb_vorbis.c index 915d3d2..9d02e7c 100644 --- a/stb_vorbis.c +++ b/stb_vorbis.c @@ -930,7 +930,7 @@ static void crc32_init(void) uint32 s; for(i=0; i < 256; i++) { for (s=i<<24, j=0; j < 8; ++j) - s = (s << 1) ^ (s >= (1<<31) ? CRC32_POLY : 0); + s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0); crc_table[i] = s; } } @@ -964,15 +964,15 @@ static int ilog(int32 n) static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) - if (n < (1U << 14)) - if (n < (1U << 4)) return 0 + log2_4[n ]; - else if (n < (1U << 9)) return 5 + log2_4[n >> 5]; + if (n < (1 << 14)) + if (n < (1 << 4)) return 0 + log2_4[n ]; + else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; else return 10 + log2_4[n >> 10]; - else if (n < (1U << 24)) - if (n < (1U << 19)) return 15 + log2_4[n >> 15]; + else if (n < (1 << 24)) + if (n < (1 << 19)) return 15 + log2_4[n >> 15]; else return 20 + log2_4[n >> 20]; - else if (n < (1U << 29)) return 25 + log2_4[n >> 25]; - else if (n < (1U << 31)) return 30 + log2_4[n >> 30]; + else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; + else if (n < (1 << 31)) return 30 + log2_4[n >> 30]; else return 0; // signed n returns 0 } @@ -1396,7 +1396,7 @@ static int start_page_no_capturepattern(vorb *f) return error(f, VORBIS_unexpected_eof); // assume we _don't_ know any the sample position of any segments f->end_seg_with_known_loc = -2; - if (loc0 != ~0 || loc1 != ~0) { + if (loc0 != ~0U || loc1 != ~0U) { int i; // determine which packet is the last one that will complete for (i=f->segment_count-1; i >= 0; --i) @@ -4328,7 +4328,7 @@ static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) f->next_seg = -1; // start a new page f->current_loc = f->scan[i].sample_loc; // set the current sample location // to the amount we'd have decoded had we decoded this page - f->current_loc_valid = f->current_loc != ~0; + f->current_loc_valid = f->current_loc != ~0U; return data_len; } // delete entry