Fix coverity warning.

- False positive about a shift with -1 when code_num overflows.
This commit is contained in:
Ari Koivula 2015-05-05 11:10:08 +03:00
parent cf2a406aba
commit 62285c405c

View file

@ -61,16 +61,16 @@ void printf_bitstream(char *msg, ...)
const bit_table_t *g_exp_table;
//From wikipedia
//http://en.wikipedia.org/wiki/Binary_logarithm#Algorithm
static int floor_log2(unsigned int n) {
assert(n != 0);
int pos = 0;
if (n >= 1<<16) { n >>= 16; pos += 16; }
if (n >= 1<< 8) { n >>= 8; pos += 8; }
if (n >= 1<< 4) { n >>= 4; pos += 4; }
if (n >= 1<< 2) { n >>= 2; pos += 2; }
if (n >= 1<< 1) { pos += 1; }
return ((n == 0) ? (-1) : pos);
return pos;
}
/**