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;
333 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 ||
357 651 0 if (strm == Z_NULL ||
651 0 if (strm == Z_NULL ||
358 0 651 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
361 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 &&
365 219 0 s->status != EXTRA_STATE &&
366 219 0 s->status != NAME_STATE &&
367 219 0 s->status != COMMENT_STATE &&
368 219 0 s->status != HCRC_STATE &&
369 0 219 s->status != BUSY_STATE &&
387 0 0 if (deflateStateCheck(strm) || dictionary == Z_NULL)
0 0 if (deflateStateCheck(strm) || dictionary == Z_NULL)
391 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)
395 0 0 if (wrap == 1)
400 0 0 if (dictLength >= s->w_size) {
401 0 0 if (wrap == 0) { /* already empty otherwise */
417 0 0 while (s->lookahead >= MIN_MATCH) {
427 0 0 } while (--n);
453 0 0 if (deflateStateCheck(strm))
457 0 0 if (len > s->w_size)
459 0 0 if (dictionary != Z_NULL && len)
0 0 if (dictionary != Z_NULL && len)
461 0 0 if (dictLength != Z_NULL)
472 0 241 if (deflateStateCheck(strm)) {
484 44 197 if (s->wrap < 0) {
491 241 0 s->wrap ? INIT_STATE : BUSY_STATE;
511 241 0 if (ret == Z_OK)
521 0 0 if (deflateStateCheck(strm) || strm->state->wrap != 2)
0 0 if (deflateStateCheck(strm) || strm->state->wrap != 2)
533 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
534 0 0 if (pending != Z_NULL)
536 0 0 if (bits != Z_NULL)
550 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
552 0 0 if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
556 0 0 if (put > bits)
563 0 0 } while (bits);
576 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
582 0 0 if (level == Z_DEFAULT_COMPRESSION) level = 6;
584 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) {
589 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) &&
593 0 0 if (err == Z_STREAM_ERROR)
595 0 0 if (strm->avail_out == 0)
598 0 0 if (s->level != level) {
599 0 0 if (s->level == 0 && s->matches != 0) {
0 0 if (s->level == 0 && s->matches != 0) {
600 0 0 if (s->matches == 1)
626 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
664 0 0 if (deflateStateCheck(strm))
674 0 0 wraplen = 6 + (s->strstart ? 4 : 0);
703 0 0 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
0 0 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
738 3 642 if (len > strm->avail_out) len = strm->avail_out;
739 0 645 if (len == 0) return;
747 642 3 if (s->pending == 0) {
770 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) {
775 219 0 if (strm->next_out == Z_NULL ||
212 7 if (strm->next_out == Z_NULL ||
776 212 0 (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
5 214 (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
777 0 5 (s->status == FINISH_STATE && flush != Z_FINISH)) {
780 0 219 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
786 3 216 if (s->pending != 0) {
788 0 3 if (strm->avail_out == 0) {
803 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) &&
809 5 214 if (s->status == FINISH_STATE && strm->avail_in != 0) {
0 5 if (s->status == FINISH_STATE && strm->avail_in != 0) {
814 214 5 if (s->status == INIT_STATE) {
819 214 0 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
157 57 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
821 0 57 else if (s->level < 6)
823 57 0 else if (s->level == 6)
828 0 214 if (s->strstart != 0) header |= PRESET_DICT;
834 0 214 if (s->strstart != 0) {
843 0 214 if (s->pending != 0) {
996 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 ||
997 2 5 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1000 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) :
1005 210 4 if (bstate == finish_started || bstate == finish_done) {
210 0 if (bstate == finish_started || bstate == finish_done) {
1008 214 0 if (bstate == need_more || bstate == finish_started) {
4 210 if (bstate == need_more || bstate == finish_started) {
1009 4 0 if (strm->avail_out == 0) {
1021 0 210 if (bstate == block_done) {
1022 0 0 if (flush == Z_PARTIAL_FLUSH) {
1024 0 0 } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
1029 0 0 if (flush == Z_FULL_FLUSH) {
1031 0 0 if (s->lookahead == 0) {
1039 0 0 if (strm->avail_out == 0) {
1046 0 215 if (flush != Z_FINISH) return Z_OK;
1047 1 214 if (s->wrap <= 0) return Z_STREAM_END;
1071 214 0 if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1081 0 191 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
1086 191 0 TRY_FREE(strm, strm->state->pending_buf);
1087 191 0 TRY_FREE(strm, strm->state->head);
1088 191 0 TRY_FREE(strm, strm->state->prev);
1089 191 0 TRY_FREE(strm, strm->state->window);
1094 0 191 return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
1114 0 0 if (deflateStateCheck(source) || dest == Z_NULL) {
0 0 if (deflateStateCheck(source) || dest == Z_NULL) {
1123 0 0 if (ds == Z_NULL) return Z_MEM_ERROR;
1134 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 ||
1171 0 212 if (len > size) len = size;
1172 0 212 if (len == 0) return 0;
1177 212 0 if (strm->state->wrap == 1) {
1247 0 755 s->strstart - (IPos)MAX_DIST(s) : NIL;
1273 10 745 if (s->prev_length >= s->good_match) {
1279 153 602 if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
1330 714 123 if (match[best_len] != scan_end ||
710 4 if (match[best_len] != scan_end ||
1331 640 70 match[best_len-1] != scan_end1 ||
1332 0 640 *match != *scan ||
1348 687 25 } while (*++scan == *++match && *++scan == *++match &&
654 33 } while (*++scan == *++match && *++scan == *++match &&
1349 614 40 *++scan == *++match && *++scan == *++match &&
516 98 *++scan == *++match && *++scan == *++match &&
1350 444 72 *++scan == *++match && *++scan == *++match &&
433 11 *++scan == *++match && *++scan == *++match &&
1351 422 11 *++scan == *++match && *++scan == *++match &&
422 0 *++scan == *++match && *++scan == *++match &&
1352 712 350 scan < strend);
1361 640 0 if (len > best_len) {
1364 119 521 if (len >= nice_match) break;
1373 83 635 && --chain_length != 0);
82 1 && --chain_length != 0);
1375 755 0 if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
1510 0 16678 if (s->strstart >= wsize+MAX_DIST(s)) {
1519 16466 212 if (s->strm->avail_in == 0) break;
1538 212 0 if (s->lookahead + s->insert >= MIN_MATCH) {
1545 0 212 while (s->insert) {
1553 0 0 if (s->lookahead + s->insert < MIN_MATCH)
1561 199 13 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
0 199 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
1570 16678 0 if (s->high_water < s->window_size) {
1574 168 16510 if (s->high_water < curr) {
1579 168 0 if (init > WIN_INIT)
1584 4 16506 else if (s->high_water < (ulg)curr + WIN_INIT) {
1590 0 4 if (init > s->window_size - s->high_water)
1666 0 0 if (s->strm->avail_out < have) /* need room for header */
1671 0 0 if (len > (ulg)left + s->strm->avail_in)
1673 0 0 if (len > have)
1681 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) ||
1682 0 0 flush == Z_NO_FLUSH ||
1689 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;
1708 0 0 if (left) {
1709 0 0 if (left > len)
1722 0 0 if (len) {
1728 0 0 } while (last == 0);
1737 0 0 if (used) {
1741 0 0 if (used >= s->w_size) { /* supplant the previous history */
1747 0 0 if (s->window_size - s->strstart <= used) {
1751 0 0 if (s->matches < 2)
1760 0 0 if (s->high_water < s->strstart)
1764 0 0 if (last)
1768 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 &&
1769 0 0 s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
1774 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) {
1779 0 0 if (s->matches < 2)
1783 0 0 if (have > s->strm->avail_in)
1785 0 0 if (have) {
1789 0 0 if (s->high_water < s->strstart)
1802 0 0 if (left >= min_block ||
0 0 if (left >= min_block ||
1803 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 &&
1804 0 0 s->strm->avail_in == 0 && left <= have)) {
1806 0 0 last = flush == Z_FINISH && s->strm->avail_in == 0 &&
1807 0 0 len == left ? 1 : 0;
0 0 len == left ? 1 : 0;
1814 0 0 return last ? finish_started : need_more;
1837 13526 427 if (s->lookahead < MIN_LOOKAHEAD) {
1839 13513 13 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
0 13513 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1842 157 13369 if (s->lookahead == 0) break; /* flush the current block */
1849 13534 262 if (s->lookahead >= MIN_MATCH) {
1856 606 13190 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
606 0 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
1864 527 13269 if (s->match_length >= MIN_MATCH) {
1867 525 2 _tr_tally_dist(s, s->strstart - s->match_start,
1876 278 249 if (s->match_length <= s->max_insert_length &&
272 6 if (s->match_length <= s->max_insert_length &&
1885 290 272 } while (--s->match_length != 0);
1908 0 13796 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
1911 157 0 if (flush == Z_FINISH) {
1912 157 0 FLUSH_BLOCK(s, 1);
0 157 FLUSH_BLOCK(s, 1);
1915 0 0 if (s->last_lit)
1916 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
1940 3152 0 if (s->lookahead < MIN_LOOKAHEAD) {
1942 3152 0 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
0 3152 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1945 57 3095 if (s->lookahead == 0) break; /* flush the current block */
1952 2997 98 if (s->lookahead >= MIN_MATCH) {
1961 164 2931 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
149 15 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
149 0 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
1970 72 77 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
72 0 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
1972 52 20 || (s->match_length == MIN_MATCH &&
0 52 || (s->match_length == MIN_MATCH &&
1986 100 2995 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
100 0 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
1992 100 0 _tr_tally_dist(s, s->strstart -1 - s->prev_match,
2003 842 12 if (++s->strstart <= max_insert) {
2006 754 100 } while (--s->prev_length != 0);
2011 0 100 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2013 2842 153 } else if (s->match_available) {
2020 0 2842 if (bflush) {
2021 0 0 FLUSH_BLOCK_ONLY(s, 0);
2025 0 2842 if (s->strm->avail_out == 0) return need_more;
2036 53 4 if (s->match_available) {
2042 57 0 if (flush == Z_FINISH) {
2043 57 0 FLUSH_BLOCK(s, 1);
4 53 FLUSH_BLOCK(s, 1);
2046 0 0 if (s->last_lit)
2047 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
2070 0 0 if (s->lookahead <= MAX_MATCH) {
2072 0 0 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
0 0 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
2075 0 0 if (s->lookahead == 0) break; /* flush the current block */
2080 0 0 if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
0 0 if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
2083 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) {
2086 0 0 } while (prev == *++scan && prev == *++scan &&
0 0 } while (prev == *++scan && prev == *++scan &&
2087 0 0 prev == *++scan && prev == *++scan &&
0 0 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 scan < strend);
2092 0 0 if (s->match_length > s->lookahead)
2099 0 0 if (s->match_length >= MIN_MATCH) {
2102 0 0 _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
2114 0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2117 0 0 if (flush == Z_FINISH) {
2118 0 0 FLUSH_BLOCK(s, 1);
0 0 FLUSH_BLOCK(s, 1);
2121 0 0 if (s->last_lit)
2122 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
2138 0 0 if (s->lookahead == 0) {
2140 0 0 if (s->lookahead == 0) {
2141 0 0 if (flush == Z_NO_FLUSH)
2153 0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2156 0 0 if (flush == Z_FINISH) {
2157 0 0 FLUSH_BLOCK(s, 1);
0 0 FLUSH_BLOCK(s, 1);
2160 0 0 if (s->last_lit)
2161 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);