From 62285c405c16349e63e61d434a08edd929d7789d Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Tue, 5 May 2015 11:10:08 +0300 Subject: [PATCH] Fix coverity warning. - False positive about a shift with -1 when code_num overflows. --- src/bitstream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bitstream.c b/src/bitstream.c index ca44347e..be53f088 100644 --- a/src/bitstream.c +++ b/src/bitstream.c @@ -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; } /**