mirror of
https://github.com/intel/isa-l.git
synced 2024-12-12 09:23:50 +01:00
igzip: fix issues reported by static code analysis
compute_dist_code() and compute_dist_icf_code() in huffman.h: Correct `assert(msb >= 1)` to `assert(msb >= 2)`. `msb` cannot be lower than 2 as it would result in corrupt computations. get_dist_code() in huffman.h: Remove dead `if` statement at the beginning of the function. `dist` must be equal 1 or above in this function. Signed-off-by: Tomasz Kantecki <tomasz.kantecki@intel.com>
This commit is contained in:
parent
402bd4f773
commit
6ef2abe80e
@ -104,7 +104,7 @@ static void compute_dist_code(struct isal_hufftables *hufftables, uint16_t dist,
|
|||||||
uint32_t code;
|
uint32_t code;
|
||||||
|
|
||||||
msb = bsr(dist);
|
msb = bsr(dist);
|
||||||
assert(msb >= 1);
|
assert(msb >= 2);
|
||||||
num_extra_bits = msb - 2;
|
num_extra_bits = msb - 2;
|
||||||
extra_bits = dist & ((1 << num_extra_bits) - 1);
|
extra_bits = dist & ((1 << num_extra_bits) - 1);
|
||||||
dist >>= num_extra_bits;
|
dist >>= num_extra_bits;
|
||||||
@ -119,8 +119,6 @@ static void compute_dist_code(struct isal_hufftables *hufftables, uint16_t dist,
|
|||||||
static inline void get_dist_code(struct isal_hufftables *hufftables, uint32_t dist,
|
static inline void get_dist_code(struct isal_hufftables *hufftables, uint32_t dist,
|
||||||
uint64_t * code, uint64_t * len)
|
uint64_t * code, uint64_t * len)
|
||||||
{
|
{
|
||||||
if (dist < 1)
|
|
||||||
dist = 0;
|
|
||||||
assert(dist >= 1);
|
assert(dist >= 1);
|
||||||
assert(dist <= 32768);
|
assert(dist <= 32768);
|
||||||
if (dist <= IGZIP_DIST_TABLE_SIZE) {
|
if (dist <= IGZIP_DIST_TABLE_SIZE) {
|
||||||
@ -161,7 +159,7 @@ static void compute_dist_icf_code(uint32_t dist, uint32_t * code, uint32_t * ext
|
|||||||
|
|
||||||
dist -= 1;
|
dist -= 1;
|
||||||
msb = bsr(dist);
|
msb = bsr(dist);
|
||||||
assert(msb >= 1);
|
assert(msb >= 2);
|
||||||
num_extra_bits = msb - 2;
|
num_extra_bits = msb - 2;
|
||||||
*extra_bits = dist & ((1 << num_extra_bits) - 1);
|
*extra_bits = dist & ((1 << num_extra_bits) - 1);
|
||||||
dist >>= num_extra_bits;
|
dist >>= num_extra_bits;
|
||||||
|
Loading…
Reference in New Issue
Block a user