Skip to content
Myr

stb_vorbis: fix signed/unsigned comparison

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ronny Chevalier · committed by Sean Barrett · parent 893ef01 · Browse files · 1 file+10 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−10 removed

  • other:+10 added−10 removed

1 file+10 added−10 removed

modified:stb_vorbis.c+10 added-10 removed
928 unmodified lines
929 int i,j;930 uint32 s;931 for(i=0; i < 256; i++) {932 for (s=i<<24, j=0; j < 8; ++j)933 s = (s << 1) ^ (s >= (1<<31) ? CRC32_POLY : 0);933 s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0);934 crc_table[i] = s;935 }936}937
25 unmodified lines
963{964 static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 };965966 // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29)967 if (n < (1U << 14))968 if (n < (1U << 4)) return 0 + log2_4[n ];969 else if (n < (1U << 9)) return 5 + log2_4[n >> 5];967 if (n < (1 << 14))968 if (n < (1 << 4)) return 0 + log2_4[n ];969 else if (n < (1 << 9)) return 5 + log2_4[n >> 5];970 else return 10 + log2_4[n >> 10];971 else if (n < (1U << 24))972 if (n < (1U << 19)) return 15 + log2_4[n >> 15];971 else if (n < (1 << 24))972 if (n < (1 << 19)) return 15 + log2_4[n >> 15];973 else return 20 + log2_4[n >> 20];974 else if (n < (1U << 29)) return 25 + log2_4[n >> 25];975 else if (n < (1U << 31)) return 30 + log2_4[n >> 30];974 else if (n < (1 << 29)) return 25 + log2_4[n >> 25];975 else if (n < (1 << 31)) return 30 + log2_4[n >> 30];976 else return 0; // signed n returns 0977}978979#ifndef M_PI
415 unmodified lines
1395 if (!getn(f, f->segments, f->segment_count))1396 return error(f, VORBIS_unexpected_eof);1397 // assume we _don't_ know any the sample position of any segments1398 f->end_seg_with_known_loc = -2;1399 if (loc0 != ~0 || loc1 != ~0) {1399 if (loc0 != ~0U || loc1 != ~0U) {1400 int i;1401 // determine which packet is the last one that will complete1402 for (i=f->segment_count-1; i >= 0; --i)1403 if (f->segments[i] < 255)
2923 unmodified lines
4327 f->previous_length = 0; // decode-but-don't-output one frame4328 f->next_seg = -1; // start a new page4329 f->current_loc = f->scan[i].sample_loc; // set the current sample location4330 // to the amount we'd have decoded had we decoded this page4331 f->current_loc_valid = f->current_loc != ~0;4331 f->current_loc_valid = f->current_loc != ~0U;4332 return data_len;4333 }4334 // delete entry4335 f->scan[i] = f->scan[--f->page_crc_tests];
1120 unmodified lines