diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2020-09-29 05:37:20 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-09-30 00:20:52 (GMT) |
commit | ad2d2764c71a3d993f8da415186dd4d6345ceea3 (patch) | |
tree | 99fdf5377f2a76d9c3a0c996c3ddd33c39459a0c /lib/lz4.c | |
parent | 78f4fdbb89e71325cedc751e1f7c2403bb43c3f4 (diff) | |
download | lz4-ad2d2764c71a3d993f8da415186dd4d6345ceea3.zip lz4-ad2d2764c71a3d993f8da415186dd4d6345ceea3.tar.gz lz4-ad2d2764c71a3d993f8da415186dd4d6345ceea3.tar.bz2 |
fix minor static analyzer warnings
detected by scan-build, cppcheck and advanved compilation flags
fix #786
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 36 |
1 files changed, 19 insertions, 17 deletions
@@ -1683,25 +1683,27 @@ typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive; */ typedef enum { loop_error = -2, initial_error = -1, ok = 0 } variable_length_error; LZ4_FORCE_INLINE unsigned -read_variable_length(const BYTE**ip, const BYTE* lencheck, int loop_check, int initial_check, variable_length_error* error) -{ - U32 length = 0; - U32 s; - if (initial_check && unlikely((*ip) >= lencheck)) { /* overflow detection */ - *error = initial_error; - return length; - } - do { - s = **ip; - (*ip)++; - length += s; - if (loop_check && unlikely((*ip) >= lencheck)) { /* overflow detection */ - *error = loop_error; - return length; +read_variable_length(const BYTE**ip, const BYTE* lencheck, + endCondition_directive loop_check, endCondition_directive initial_check, + variable_length_error* error) +{ + U32 length = 0; + U32 s; + if (initial_check && unlikely((*ip) >= lencheck)) { /* overflow detection */ + *error = initial_error; + return length; } - } while (s==255); + do { + s = **ip; + (*ip)++; + length += s; + if (loop_check && unlikely((*ip) >= lencheck)) { /* overflow detection */ + *error = loop_error; + return length; + } + } while (s==255); - return length; + return length; } /*! LZ4_decompress_generic() : |