这是indexloc提供的服务,不要输入任何密码
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/slide_hash_armv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize
}

Z_INTERNAL void slide_hash_armv6(deflate_state *s) {
Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
AssertHint(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
uint16_t wsize = (uint16_t)s->w_size;

slide_hash_chain(s->head, HASH_SIZE, wsize);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/slide_hash_neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize
}

Z_INTERNAL void slide_hash_neon(deflate_state *s) {
Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
AssertHint(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
uint16_t wsize = (uint16_t)s->w_size;

slide_hash_chain(s->head, HASH_SIZE, wsize);
Expand Down
2 changes: 1 addition & 1 deletion arch/generic/crc32_braid_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Z_INTERNAL uint32_t PREFIX(crc32_braid)(uint32_t crc, const uint8_t *buf, size_t
#endif
#endif
words += N;
Assert(comb <= UINT32_MAX, "comb should fit in uint32_t");
AssertHint(comb <= UINT32_MAX, "comb should fit in uint32_t");
c = (uint32_t)ZSWAPWORD(comb);

/* Update the pointer to the remaining bytes to process. */
Expand Down
2 changes: 1 addition & 1 deletion arch/power/slide_ppc_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize
}

void Z_INTERNAL SLIDE_PPC(deflate_state *s) {
Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
AssertHint(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
uint16_t wsize = (uint16_t)s->w_size;

slide_hash_chain(s->head, HASH_SIZE, wsize);
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/chunkset_rvv.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static inline void storechunk(uint8_t *out, chunk_t *chunk) {
* loadchunk and storechunk to ensure the result is correct.
*/
static inline uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len) {
Assert(len > 0, "chunkcopy should never have a length 0");
AssertHint(len > 0, "chunkcopy should never have a length 0");
int32_t align = ((len - 1) % sizeof(chunk_t)) + 1;
memcpy(out, from, sizeof(chunk_t));
out += align;
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/slide_hash_rvv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize
}

Z_INTERNAL void slide_hash_rvv(deflate_state *s) {
Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
AssertHint(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
uint16_t wsize = (uint16_t)s->w_size;

slide_hash_chain(s->head, HASH_SIZE, wsize);
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/dfltcc_deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ int Z_INTERNAL PREFIX(dfltcc_deflate)(PREFIX3(streamp) strm, int flush, block_st
/* DFLTCC-CMPR will write to next_out, so make sure that buffers with
* higher precedence are empty.
*/
Assert(state->pending == 0, "There must be no pending bytes");
Assert(state->bi_valid < 8, "There must be less than 8 pending bits");
AssertHint(state->pending == 0, "There must be no pending bytes");
AssertHint(state->bi_valid < 8, "There must be less than 8 pending bits");
param->sbb = (unsigned int)state->bi_valid;
if (param->sbb > 0)
*strm->next_out = (unsigned char)state->bi_buf;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/slide_hash_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static inline void slide_hash_chain(Pos *table, uint32_t entries, const __m256i
}

Z_INTERNAL void slide_hash_avx2(deflate_state *s) {
Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
AssertHint(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
uint16_t wsize = (uint16_t)s->w_size;
const __m256i ymm_wsize = _mm256_set1_epi16((short)wsize);

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/slide_hash_sse2.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}

Z_INTERNAL void slide_hash_sse2(deflate_state *s) {
Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
AssertHint(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");

Check warning on line 55 in arch/x86/slide_hash_sse2.c

View check run for this annotation

Codecov / codecov/patch

arch/x86/slide_hash_sse2.c#L55

Added line #L55 was not covered by tests
uint16_t wsize = (uint16_t)s->w_size;
const __m128i xmm_wsize = _mm_set1_epi16((short)wsize);

Expand Down
4 changes: 2 additions & 2 deletions chunkset_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Z_INTERNAL uint32_t CHUNKSIZE(void) {
reliable. */
#ifndef HAVE_CHUNKCOPY
static inline uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len) {
Assert(len > 0, "chunkcopy should never have a length 0");
AssertHint(len > 0, "chunkcopy should never have a length 0");
chunk_t chunk;
int32_t align = ((len - 1) % sizeof(chunk_t)) + 1;
loadchunk(from, &chunk);
Expand Down Expand Up @@ -112,7 +112,7 @@ static inline uint8_t* HALFCHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned
static inline uint8_t* CHUNKMEMSET(uint8_t *out, uint8_t *from, unsigned len) {
/* Debug performance related issues when len < sizeof(uint64_t):
Assert(len >= sizeof(uint64_t), "chunkmemset should be called on larger chunks"); */
Assert(from != out, "chunkmemset cannot have a distance 0");
AssertHint(from != out, "chunkmemset cannot have a distance 0");

chunk_t chunk_load;
uint32_t chunk_mod = 0;
Expand Down
6 changes: 3 additions & 3 deletions deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
if (s->wrap > 0)
s->wrap = -s->wrap; /* write the trailer only once! */
if (s->pending == 0) {
Assert(s->bi_valid == 0, "bi_buf not flushed");
AssertHint(s->bi_valid == 0, "bi_buf not flushed");
return Z_STREAM_END;
}
return Z_OK;
Expand Down Expand Up @@ -1274,7 +1274,7 @@ void Z_INTERNAL PREFIX(fill_window)(deflate_state *s) {
unsigned int more; /* Amount of free space at the end of the window. */
unsigned int wsize = s->w_size;

Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
AssertHint(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");

do {
more = s->window_size - s->lookahead - s->strstart;
Expand Down Expand Up @@ -1311,7 +1311,7 @@ void Z_INTERNAL PREFIX(fill_window)(deflate_state *s) {
* Otherwise, window_size == 2*WSIZE so more >= 2.
* If there was sliding, more >= WSIZE. So in all cases, more >= 2.
*/
Assert(more >= 2, "more < 2");
AssertHint(more >= 2, "more < 2");

n = PREFIX(read_buf)(s->strm, s->window + s->strstart + s->lookahead, more);
s->lookahead += n;
Expand Down
4 changes: 2 additions & 2 deletions deflate_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
}

if (match_len >= WANT_MIN_MATCH) {
Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
Assert(s->match_start <= UINT16_MAX, "match_start should fit in uint16_t");
AssertHint(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
AssertHint(s->match_start <= UINT16_MAX, "match_start should fit in uint16_t");

Check warning on line 62 in deflate_fast.c

View check run for this annotation

Codecov / codecov/patch

deflate_fast.c#L61-L62

Added lines #L61 - L62 were not covered by tests
check_match(s, (Pos)s->strstart, (Pos)s->match_start, match_len);

bflush = zng_tr_tally_dist(s, s->strstart - s->match_start, match_len - STD_MIN_MATCH);
Expand Down
7 changes: 3 additions & 4 deletions deflate_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@ static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) {
#endif
s->dyn_ltree[c].Freq++;
Tracevv((stderr, "%c", c));
Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal");
return (s->sym_next == s->sym_end);
}

static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) {
/* dist: distance of matched string */
/* len: match length-STD_MIN_MATCH */
#ifdef LIT_MEM
Assert(dist <= UINT16_MAX, "dist should fit in uint16_t");
Assert(len <= UINT8_MAX, "len should fit in uint8_t");
AssertHint(dist <= UINT16_MAX, "dist should fit in uint16_t");
AssertHint(len <= UINT8_MAX, "len should fit in uint8_t");
s->d_buf[s->sym_next] = (uint16_t)dist;
s->l_buf[s->sym_next++] = (uint8_t)len;
#else
Expand All @@ -89,7 +88,7 @@ static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t le
#endif
s->matches++;
dist--;
Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES,
AssertHint(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES,
"zng_tr_tally: bad match");

s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++;
Expand Down
2 changes: 1 addition & 1 deletion deflate_quick.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
if (UNLIKELY(match_len > STD_MAX_MATCH))
match_len = STD_MAX_MATCH;

Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
AssertHint(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
check_match(s, (Pos)s->strstart, hash_head, match_len);

zng_tr_emit_dist(s, static_ltree, static_dtree, match_len - STD_MIN_MATCH, (uint32_t)dist);
Expand Down
2 changes: 1 addition & 1 deletion deflate_rle.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Z_INTERNAL block_state deflate_rle(deflate_state *s, int flush) {

/* Emit match if have run of STD_MIN_MATCH or longer, else emit literal */
if (match_len >= STD_MIN_MATCH) {
Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
AssertHint(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
check_match(s, (Pos)s->strstart, (Pos)(s->strstart - 1), match_len);

bflush = zng_tr_tally_dist(s, 1, match_len - STD_MIN_MATCH);
Expand Down
2 changes: 1 addition & 1 deletion deflate_slow.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
unsigned int max_insert = s->strstart + s->lookahead - STD_MIN_MATCH;
/* Do not insert strings in hash table beyond this. */

Assert((s->strstart-1) <= UINT16_MAX, "strstart-1 should fit in uint16_t");
AssertHint((s->strstart-1) <= UINT16_MAX, "strstart-1 should fit in uint16_t");
check_match(s, (Pos)(s->strstart - 1), s->prev_match, s->prev_length);

bflush = zng_tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - STD_MIN_MATCH);
Expand Down
4 changes: 2 additions & 2 deletions fallback_builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Performance tzcnt/bsf is identical on Intel cpu, tzcnt is faster than bsf on AMD cpu.
*/
static __forceinline int __builtin_ctz(unsigned int value) {
Assert(value != 0, "Invalid input value: 0");
AssertHint(value != 0, "Invalid input value: 0");
# if defined(X86_FEATURES) && !(_MSC_VER < 1700)
return (int)_tzcnt_u32(value);
# else
Expand All @@ -29,7 +29,7 @@ static __forceinline int __builtin_ctz(unsigned int value) {
* Because of that assumption trailing_zero is not initialized and the return value is not checked.
*/
static __forceinline int __builtin_ctzll(unsigned long long value) {
Assert(value != 0, "Invalid input value: 0");
AssertHint(value != 0, "Invalid input value: 0");
# if defined(X86_FEATURES) && !(_MSC_VER < 1700)
return (int)_tzcnt_u64(value);
# else
Expand Down
11 changes: 9 additions & 2 deletions inffast_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ void Z_INTERNAL INFLATE_FAST(PREFIX3(stream) *strm, uint32_t start) {
unsigned dist; /* match distance */
unsigned extra_safe; /* copy chunks safely in all cases */

/* copy state to local variables */
state = (struct inflate_state *)strm->state;

Assume(state->mode == LEN);
Assume(state->bits < 8);
Assume(strm->avail_in >= INFLATE_FAST_MIN_HAVE);
Assume(strm->avail_out >= INFLATE_FAST_MIN_LEFT);
Assume(start >= strm->avail_out);

/* copy state to local variables */
in = strm->next_in;
last = in + (strm->avail_in - (INFLATE_FAST_MIN_HAVE - 1));
out = strm->next_out;
Expand Down Expand Up @@ -311,7 +318,7 @@ void Z_INTERNAL INFLATE_FAST(PREFIX3(stream) *strm, uint32_t start) {
strm->avail_out = (unsigned)(out < end ? (INFLATE_FAST_MIN_LEFT - 1) + (end - out)
: (INFLATE_FAST_MIN_LEFT - 1) - (out - end));

Assert(bits <= 32, "Remaining bits greater than 32");
AssertHint(bits <= 32, "Remaining bits greater than 32");
state->hold = (uint32_t)hold;
state->bits = bits;
return;
Expand Down
2 changes: 1 addition & 1 deletion match_tpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
#else
early_exit = s->level < EARLY_EXIT_TRIGGER_LEVEL;
#endif
Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
AssertHint((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
for (;;) {
if (cur_match >= strstart)
break;
Expand Down
Loading
Loading