Branch Coverage

deps/libgit2/deps/zlib/deflate.c
Criterion Covered Total %
branch 225 646 34.8


line true false branch
212 0 0 *p = (Pos)(m >= wsize ? m - wsize : NIL);
213 0 0 } while (--n);
219 0 0 *p = (Pos)(m >= wsize ? m - wsize : NIL);
223 0 0 } while (--n);
260 191 0 if (version == Z_NULL || version[0] != my_version[0] ||
191 0 if (version == Z_NULL || version[0] != my_version[0] ||
0 191 if (version == Z_NULL || version[0] != my_version[0] ||
264 0 191 if (strm == Z_NULL) return Z_STREAM_ERROR;
267 191 0 if (strm->zalloc == (alloc_func)0) {
275 191 0 if (strm->zfree == (free_func)0)
285 14 177 if (level == Z_DEFAULT_COMPRESSION) level = 6;
288 0 191 if (windowBits < 0) { /* suppress zlib wrapper */
298 191 0 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
191 0 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
191 0 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
191 0 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
299 191 0 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
191 0 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
191 0 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
191 0 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
300 191 0 strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
0 191 strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
0 0 strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
303 0 191 if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
305 0 191 if (s == Z_NULL) return Z_MEM_ERROR;
334 191 0 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
191 0 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
191 0 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
0 191 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
358 651 0 if (strm == Z_NULL ||
651 0 if (strm == Z_NULL ||
359 0 651 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
362 651 0 if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
651 0 if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
219 432 if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
219 0 if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
366 219 0 s->status != EXTRA_STATE &&
367 219 0 s->status != NAME_STATE &&
368 219 0 s->status != COMMENT_STATE &&
369 219 0 s->status != HCRC_STATE &&
370 0 219 s->status != BUSY_STATE &&
388 0 0 if (deflateStateCheck(strm) || dictionary == Z_NULL)
0 0 if (deflateStateCheck(strm) || dictionary == Z_NULL)
392 0 0 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
0 0 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
0 0 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
0 0 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
396 0 0 if (wrap == 1)
401 0 0 if (dictLength >= s->w_size) {
402 0 0 if (wrap == 0) { /* already empty otherwise */
418 0 0 while (s->lookahead >= MIN_MATCH) {
428 0 0 } while (--n);
454 0 0 if (deflateStateCheck(strm))
458 0 0 if (len > s->w_size)
460 0 0 if (dictionary != Z_NULL && len)
0 0 if (dictionary != Z_NULL && len)
462 0 0 if (dictLength != Z_NULL)
473 0 241 if (deflateStateCheck(strm)) {
485 44 197 if (s->wrap < 0) {
492 241 0 s->wrap ? INIT_STATE : BUSY_STATE;
512 241 0 if (ret == Z_OK)
522 0 0 if (deflateStateCheck(strm) || strm->state->wrap != 2)
0 0 if (deflateStateCheck(strm) || strm->state->wrap != 2)
534 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
535 0 0 if (pending != Z_NULL)
537 0 0 if (bits != Z_NULL)
551 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
553 0 0 if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
557 0 0 if (put > bits)
564 0 0 } while (bits);
577 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
583 0 0 if (level == Z_DEFAULT_COMPRESSION) level = 6;
585 0 0 if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
0 0 if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
0 0 if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
0 0 if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
590 0 0 if ((strategy != s->strategy || func != configuration_table[level].func) &&
0 0 if ((strategy != s->strategy || func != configuration_table[level].func) &&
0 0 if ((strategy != s->strategy || func != configuration_table[level].func) &&
594 0 0 if (err == Z_STREAM_ERROR)
596 0 0 if (strm->avail_out == 0)
599 0 0 if (s->level != level) {
600 0 0 if (s->level == 0 && s->matches != 0) {
0 0 if (s->level == 0 && s->matches != 0) {
601 0 0 if (s->matches == 1)
627 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
665 0 0 if (deflateStateCheck(strm))
675 0 0 wraplen = 6 + (s->strstart ? 4 : 0);
704 0 0 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
0 0 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
739 3 642 if (len > strm->avail_out) len = strm->avail_out;
740 0 645 if (len == 0) return;
748 642 3 if (s->pending == 0) {
771 219 0 if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
219 0 if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
0 219 if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
776 219 0 if (strm->next_out == Z_NULL ||
212 7 if (strm->next_out == Z_NULL ||
777 212 0 (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
5 214 (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
778 0 5 (s->status == FINISH_STATE && flush != Z_FINISH)) {
781 0 219 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
787 3 216 if (s->pending != 0) {
789 0 3 if (strm->avail_out == 0) {
804 4 212 } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
0 4 } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
0 4 } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
0 4 } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
0 0 } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
810 5 214 if (s->status == FINISH_STATE && strm->avail_in != 0) {
0 5 if (s->status == FINISH_STATE && strm->avail_in != 0) {
815 214 5 if (s->status == INIT_STATE) {
820 214 0 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
157 57 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
822 0 57 else if (s->level < 6)
824 57 0 else if (s->level == 6)
829 0 214 if (s->strstart != 0) header |= PRESET_DICT;
835 0 214 if (s->strstart != 0) {
844 0 214 if (s->pending != 0) {
997 7 212 if (strm->avail_in != 0 || s->lookahead != 0 ||
7 0 if (strm->avail_in != 0 || s->lookahead != 0 ||
7 0 if (strm->avail_in != 0 || s->lookahead != 0 ||
998 2 5 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1001 0 214 bstate = s->level == 0 ? deflate_stored(s, flush) :
0 214 bstate = s->level == 0 ? deflate_stored(s, flush) :
0 214 bstate = s->level == 0 ? deflate_stored(s, flush) :
1006 210 4 if (bstate == finish_started || bstate == finish_done) {
210 0 if (bstate == finish_started || bstate == finish_done) {
1009 214 0 if (bstate == need_more || bstate == finish_started) {
4 210 if (bstate == need_more || bstate == finish_started) {
1010 4 0 if (strm->avail_out == 0) {
1022 0 210 if (bstate == block_done) {
1023 0 0 if (flush == Z_PARTIAL_FLUSH) {
1025 0 0 } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
1030 0 0 if (flush == Z_FULL_FLUSH) {
1032 0 0 if (s->lookahead == 0) {
1040 0 0 if (strm->avail_out == 0) {
1047 0 215 if (flush != Z_FINISH) return Z_OK;
1048 1 214 if (s->wrap <= 0) return Z_STREAM_END;
1072 214 0 if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1082 0 191 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
1087 191 0 TRY_FREE(strm, strm->state->pending_buf);
1088 191 0 TRY_FREE(strm, strm->state->head);
1089 191 0 TRY_FREE(strm, strm->state->prev);
1090 191 0 TRY_FREE(strm, strm->state->window);
1095 0 191 return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
1115 0 0 if (deflateStateCheck(source) || dest == Z_NULL) {
0 0 if (deflateStateCheck(source) || dest == Z_NULL) {
1124 0 0 if (ds == Z_NULL) return Z_MEM_ERROR;
1135 0 0 if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
0 0 if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
0 0 if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
0 0 if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
1172 0 212 if (len > size) len = size;
1173 0 212 if (len == 0) return 0;
1178 212 0 if (strm->state->wrap == 1) {
1248 0 748 s->strstart - (IPos)MAX_DIST(s) : NIL;
1274 10 738 if (s->prev_length >= s->good_match) {
1280 153 595 if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
1331 710 121 if (match[best_len] != scan_end ||
707 3 if (match[best_len] != scan_end ||
1332 637 70 match[best_len-1] != scan_end1 ||
1333 0 637 *match != *scan ||
1349 687 22 } while (*++scan == *++match && *++scan == *++match &&
654 33 } while (*++scan == *++match && *++scan == *++match &&
1350 614 40 *++scan == *++match && *++scan == *++match &&
516 98 *++scan == *++match && *++scan == *++match &&
1351 445 71 *++scan == *++match && *++scan == *++match &&
433 12 *++scan == *++match && *++scan == *++match &&
1352 422 11 *++scan == *++match && *++scan == *++match &&
422 0 *++scan == *++match && *++scan == *++match &&
1353 709 350 scan < strend);
1362 637 0 if (len > best_len) {
1365 119 518 if (len >= nice_match) break;
1374 84 628 && --chain_length != 0);
83 1 && --chain_length != 0);
1376 748 0 if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
1511 0 16690 if (s->strstart >= wsize+MAX_DIST(s)) {
1520 16478 212 if (s->strm->avail_in == 0) break;
1539 212 0 if (s->lookahead + s->insert >= MIN_MATCH) {
1546 0 212 while (s->insert) {
1554 0 0 if (s->lookahead + s->insert < MIN_MATCH)
1562 199 13 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
0 199 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
1571 16690 0 if (s->high_water < s->window_size) {
1575 168 16522 if (s->high_water < curr) {
1580 168 0 if (init > WIN_INIT)
1585 4 16518 else if (s->high_water < (ulg)curr + WIN_INIT) {
1591 0 4 if (init > s->window_size - s->high_water)
1667 0 0 if (s->strm->avail_out < have) /* need room for header */
1672 0 0 if (len > (ulg)left + s->strm->avail_in)
1674 0 0 if (len > have)
1682 0 0 if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
0 0 if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
0 0 if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
0 0 if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
1683 0 0 flush == Z_NO_FLUSH ||
1690 0 0 last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
0 0 last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
1709 0 0 if (left) {
1710 0 0 if (left > len)
1723 0 0 if (len) {
1729 0 0 } while (last == 0);
1738 0 0 if (used) {
1742 0 0 if (used >= s->w_size) { /* supplant the previous history */
1748 0 0 if (s->window_size - s->strstart <= used) {
1752 0 0 if (s->matches < 2)
1761 0 0 if (s->high_water < s->strstart)
1765 0 0 if (last)
1769 0 0 if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
0 0 if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
0 0 if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
1770 0 0 s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
1775 0 0 if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
0 0 if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
1780 0 0 if (s->matches < 2)
1784 0 0 if (have > s->strm->avail_in)
1786 0 0 if (have) {
1790 0 0 if (s->high_water < s->strstart)
1803 0 0 if (left >= min_block ||
0 0 if (left >= min_block ||
1804 0 0 ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
0 0 ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
0 0 ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
1805 0 0 s->strm->avail_in == 0 && left <= have)) {
1807 0 0 last = flush == Z_FINISH && s->strm->avail_in == 0 &&
1808 0 0 len == left ? 1 : 0;
0 0 len == left ? 1 : 0;
1815 0 0 return last ? finish_started : need_more;
1838 13540 427 if (s->lookahead < MIN_LOOKAHEAD) {
1840 13527 13 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
0 13527 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1843 157 13383 if (s->lookahead == 0) break; /* flush the current block */
1850 13548 262 if (s->lookahead >= MIN_MATCH) {
1857 597 13213 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
597 0 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
1865 520 13290 if (s->match_length >= MIN_MATCH) {
1868 518 2 _tr_tally_dist(s, s->strstart - s->match_start,
1877 271 249 if (s->match_length <= s->max_insert_length &&
265 6 if (s->match_length <= s->max_insert_length &&
1886 282 265 } while (--s->match_length != 0);
1909 0 13810 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
1912 157 0 if (flush == Z_FINISH) {
1913 157 0 FLUSH_BLOCK(s, 1);
0 157 FLUSH_BLOCK(s, 1);
1916 0 0 if (s->last_lit)
1917 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
1941 3150 0 if (s->lookahead < MIN_LOOKAHEAD) {
1943 3150 0 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
0 3150 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1946 57 3093 if (s->lookahead == 0) break; /* flush the current block */
1953 2995 98 if (s->lookahead >= MIN_MATCH) {
1962 166 2927 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
151 15 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
151 0 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
1971 74 77 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
74 0 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
1973 58 16 || (s->match_length == MIN_MATCH &&
0 58 || (s->match_length == MIN_MATCH &&
1987 104 2989 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
104 0 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
1993 104 0 _tr_tally_dist(s, s->strstart -1 - s->prev_match,
2004 844 12 if (++s->strstart <= max_insert) {
2007 752 104 } while (--s->prev_length != 0);
2012 0 104 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2014 2832 157 } else if (s->match_available) {
2021 0 2832 if (bflush) {
2022 0 0 FLUSH_BLOCK_ONLY(s, 0);
2026 0 2832 if (s->strm->avail_out == 0) return need_more;
2037 53 4 if (s->match_available) {
2043 57 0 if (flush == Z_FINISH) {
2044 57 0 FLUSH_BLOCK(s, 1);
4 53 FLUSH_BLOCK(s, 1);
2047 0 0 if (s->last_lit)
2048 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
2071 0 0 if (s->lookahead <= MAX_MATCH) {
2073 0 0 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
0 0 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
2076 0 0 if (s->lookahead == 0) break; /* flush the current block */
2081 0 0 if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
0 0 if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
2084 0 0 if (prev == *++scan && prev == *++scan && prev == *++scan) {
0 0 if (prev == *++scan && prev == *++scan && prev == *++scan) {
0 0 if (prev == *++scan && prev == *++scan && prev == *++scan) {
2087 0 0 } while (prev == *++scan && prev == *++scan &&
0 0 } while (prev == *++scan && prev == *++scan &&
2088 0 0 prev == *++scan && prev == *++scan &&
0 0 prev == *++scan && prev == *++scan &&
2089 0 0 prev == *++scan && prev == *++scan &&
0 0 prev == *++scan && prev == *++scan &&
2090 0 0 prev == *++scan && prev == *++scan &&
0 0 prev == *++scan && prev == *++scan &&
2091 0 0 scan < strend);
2093 0 0 if (s->match_length > s->lookahead)
2100 0 0 if (s->match_length >= MIN_MATCH) {
2103 0 0 _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
2115 0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2118 0 0 if (flush == Z_FINISH) {
2119 0 0 FLUSH_BLOCK(s, 1);
0 0 FLUSH_BLOCK(s, 1);
2122 0 0 if (s->last_lit)
2123 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
2139 0 0 if (s->lookahead == 0) {
2141 0 0 if (s->lookahead == 0) {
2142 0 0 if (flush == Z_NO_FLUSH)
2154 0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2157 0 0 if (flush == Z_FINISH) {
2158 0 0 FLUSH_BLOCK(s, 1);
0 0 FLUSH_BLOCK(s, 1);
2161 0 0 if (s->last_lit)
2162 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);