Branch Coverage

deps/libgit2/deps/zlib/deflate.c
Criterion Covered Total %
branch 227 660 34.3


line true false branch
220 0 0 *p = (Pos)(m >= wsize ? m - wsize : NIL);
221 0 0 } while (--n);
227 0 0 *p = (Pos)(m >= wsize ? m - wsize : NIL);
231 0 0 } while (--n);
263 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] ||
267 0 191 if (strm == Z_NULL) return Z_STREAM_ERROR;
270 191 0 if (strm->zalloc == (alloc_func)0) {
278 191 0 if (strm->zfree == (free_func)0)
288 14 177 if (level == Z_DEFAULT_COMPRESSION) level = 6;
291 0 191 if (windowBits < 0) { /* suppress zlib wrapper */
301 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 ||
302 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 ||
303 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)) {
306 0 191 if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
308 0 191 if (s == Z_NULL) return Z_MEM_ERROR;
374 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 ||
402 651 0 if (strm == Z_NULL ||
651 0 if (strm == Z_NULL ||
403 0 651 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
406 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 &&
410 219 0 s->status != EXTRA_STATE &&
411 219 0 s->status != NAME_STATE &&
412 219 0 s->status != COMMENT_STATE &&
413 219 0 s->status != HCRC_STATE &&
414 0 219 s->status != BUSY_STATE &&
432 0 0 if (deflateStateCheck(strm) || dictionary == Z_NULL)
0 0 if (deflateStateCheck(strm) || dictionary == Z_NULL)
436 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)
440 0 0 if (wrap == 1)
445 0 0 if (dictLength >= s->w_size) {
446 0 0 if (wrap == 0) { /* already empty otherwise */
462 0 0 while (s->lookahead >= MIN_MATCH) {
472 0 0 } while (--n);
498 0 0 if (deflateStateCheck(strm))
502 0 0 if (len > s->w_size)
504 0 0 if (dictionary != Z_NULL && len)
0 0 if (dictionary != Z_NULL && len)
506 0 0 if (dictLength != Z_NULL)
517 0 241 if (deflateStateCheck(strm)) {
529 44 197 if (s->wrap < 0) {
556 241 0 if (ret == Z_OK)
566 0 0 if (deflateStateCheck(strm) || strm->state->wrap != 2)
0 0 if (deflateStateCheck(strm) || strm->state->wrap != 2)
578 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
579 0 0 if (pending != Z_NULL)
581 0 0 if (bits != Z_NULL)
595 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
597 0 0 if (bits < 0 || bits > 16 ||
0 0 if (bits < 0 || bits > 16 ||
0 0 if (bits < 0 || bits > 16 ||
602 0 0 if (put > bits)
609 0 0 } while (bits);
622 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
628 0 0 if (level == Z_DEFAULT_COMPRESSION) level = 6;
630 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) {
635 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) &&
639 0 0 if (err == Z_STREAM_ERROR)
641 0 0 if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
0 0 if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
644 0 0 if (s->level != level) {
645 0 0 if (s->level == 0 && s->matches != 0) {
0 0 if (s->level == 0 && s->matches != 0) {
646 0 0 if (s->matches == 1)
672 0 0 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
710 0 0 if (deflateStateCheck(strm))
720 0 0 wraplen = 6 + (s->strstart ? 4 : 0);
749 0 0 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
0 0 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
784 3 642 if (len > strm->avail_out) len = strm->avail_out;
785 0 645 if (len == 0) return;
793 642 3 if (s->pending == 0) {
816 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) {
821 219 0 if (strm->next_out == Z_NULL ||
212 7 if (strm->next_out == Z_NULL ||
822 212 0 (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
5 214 (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
823 0 5 (s->status == FINISH_STATE && flush != Z_FINISH)) {
826 0 219 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
832 3 216 if (s->pending != 0) {
834 0 3 if (strm->avail_out == 0) {
849 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) &&
855 5 214 if (s->status == FINISH_STATE && strm->avail_in != 0) {
0 5 if (s->status == FINISH_STATE && strm->avail_in != 0) {
860 214 5 if (s->status == INIT_STATE && s->wrap == 0)
0 214 if (s->status == INIT_STATE && s->wrap == 0)
862 214 5 if (s->status == INIT_STATE) {
867 214 0 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
157 57 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
869 0 57 else if (s->level < 6)
871 57 0 else if (s->level == 6)
876 0 214 if (s->strstart != 0) header |= PRESET_DICT;
882 0 214 if (s->strstart != 0) {
891 0 214 if (s->pending != 0) {
1044 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 ||
1045 2 5 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1048 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) :
1053 210 4 if (bstate == finish_started || bstate == finish_done) {
210 0 if (bstate == finish_started || bstate == finish_done) {
1056 214 0 if (bstate == need_more || bstate == finish_started) {
4 210 if (bstate == need_more || bstate == finish_started) {
1057 4 0 if (strm->avail_out == 0) {
1069 0 210 if (bstate == block_done) {
1070 0 0 if (flush == Z_PARTIAL_FLUSH) {
1072 0 0 } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
1077 0 0 if (flush == Z_FULL_FLUSH) {
1079 0 0 if (s->lookahead == 0) {
1087 0 0 if (strm->avail_out == 0) {
1094 0 215 if (flush != Z_FINISH) return Z_OK;
1095 1 214 if (s->wrap <= 0) return Z_STREAM_END;
1119 214 0 if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1129 0 191 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
1134 191 0 TRY_FREE(strm, strm->state->pending_buf);
1135 191 0 TRY_FREE(strm, strm->state->head);
1136 191 0 TRY_FREE(strm, strm->state->prev);
1137 191 0 TRY_FREE(strm, strm->state->window);
1142 0 191 return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
1161 0 0 if (deflateStateCheck(source) || dest == Z_NULL) {
0 0 if (deflateStateCheck(source) || dest == Z_NULL) {
1170 0 0 if (ds == Z_NULL) return Z_MEM_ERROR;
1180 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 ||
1216 0 212 if (len > size) len = size;
1217 0 212 if (len == 0) return 0;
1222 212 0 if (strm->state->wrap == 1) {
1292 0 746 s->strstart - (IPos)MAX_DIST(s) : NIL;
1318 10 736 if (s->prev_length >= s->good_match) {
1324 155 591 if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
1375 704 125 if (match[best_len] != scan_end ||
700 4 if (match[best_len] != scan_end ||
1376 630 70 match[best_len-1] != scan_end1 ||
1377 0 630 *match != *scan ||
1393 687 21 } while (*++scan == *++match && *++scan == *++match &&
654 33 } while (*++scan == *++match && *++scan == *++match &&
1394 614 40 *++scan == *++match && *++scan == *++match &&
516 98 *++scan == *++match && *++scan == *++match &&
1395 443 73 *++scan == *++match && *++scan == *++match &&
433 10 *++scan == *++match && *++scan == *++match &&
1396 422 11 *++scan == *++match && *++scan == *++match &&
422 0 *++scan == *++match && *++scan == *++match &&
1397 708 344 scan < strend);
1406 630 0 if (len > best_len) {
1409 119 511 if (len >= nice_match) break;
1418 84 626 && --chain_length != 0);
83 1 && --chain_length != 0);
1420 746 0 if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
1555 0 16702 if (s->strstart >= wsize+MAX_DIST(s)) {
1561 0 0 if (s->insert > s->strstart)
1566 16490 212 if (s->strm->avail_in == 0) break;
1585 212 0 if (s->lookahead + s->insert >= MIN_MATCH) {
1592 0 212 while (s->insert) {
1600 0 0 if (s->lookahead + s->insert < MIN_MATCH)
1608 199 13 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
0 199 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
1617 16702 0 if (s->high_water < s->window_size) {
1621 168 16534 if (s->high_water < curr) {
1626 168 0 if (init > WIN_INIT)
1631 4 16530 else if (s->high_water < (ulg)curr + WIN_INIT) {
1637 0 4 if (init > s->window_size - s->high_water)
1713 0 0 if (s->strm->avail_out < have) /* need room for header */
1718 0 0 if (len > (ulg)left + s->strm->avail_in)
1720 0 0 if (len > have)
1728 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) ||
1729 0 0 flush == Z_NO_FLUSH ||
1736 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;
1755 0 0 if (left) {
1756 0 0 if (left > len)
1769 0 0 if (len) {
1775 0 0 } while (last == 0);
1784 0 0 if (used) {
1788 0 0 if (used >= s->w_size) { /* supplant the previous history */
1795 0 0 if (s->window_size - s->strstart <= used) {
1799 0 0 if (s->matches < 2)
1801 0 0 if (s->insert > s->strstart)
1810 0 0 if (s->high_water < s->strstart)
1814 0 0 if (last)
1818 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 &&
1819 0 0 s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
1824 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) {
1829 0 0 if (s->matches < 2)
1832 0 0 if (s->insert > s->strstart)
1835 0 0 if (have > s->strm->avail_in)
1837 0 0 if (have) {
1842 0 0 if (s->high_water < s->strstart)
1855 0 0 if (left >= min_block ||
0 0 if (left >= min_block ||
1856 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 &&
1857 0 0 s->strm->avail_in == 0 && left <= have)) {
1859 0 0 last = flush == Z_FINISH && s->strm->avail_in == 0 &&
1860 0 0 len == left ? 1 : 0;
0 0 len == left ? 1 : 0;
1867 0 0 return last ? finish_started : need_more;
1890 13550 410 if (s->lookahead < MIN_LOOKAHEAD) {
1892 13537 13 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
0 13537 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1895 157 13393 if (s->lookahead == 0) break; /* flush the current block */
1902 13541 262 if (s->lookahead >= MIN_MATCH) {
1909 597 13206 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
597 0 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
1917 515 13288 if (s->match_length >= MIN_MATCH) {
1920 513 2 _tr_tally_dist(s, s->strstart - s->match_start,
1929 266 249 if (s->match_length <= s->max_insert_length &&
260 6 if (s->match_length <= s->max_insert_length &&
1938 276 260 } while (--s->match_length != 0);
1961 0 13803 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
1964 157 0 if (flush == Z_FINISH) {
1965 157 0 FLUSH_BLOCK(s, 1);
0 157 FLUSH_BLOCK(s, 1);
1968 0 0 if (s->sym_next)
1969 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
1993 3152 0 if (s->lookahead < MIN_LOOKAHEAD) {
1995 3152 0 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
0 3152 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1998 57 3095 if (s->lookahead == 0) break; /* flush the current block */
2005 2997 98 if (s->lookahead >= MIN_MATCH) {
2014 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 &&
2023 72 77 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
72 0 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
2025 56 16 || (s->match_length == MIN_MATCH &&
0 56 || (s->match_length == MIN_MATCH &&
2039 102 2993 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
102 0 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
2045 102 0 _tr_tally_dist(s, s->strstart -1 - s->prev_match,
2056 842 12 if (++s->strstart <= max_insert) {
2059 752 102 } while (--s->prev_length != 0);
2064 0 102 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2066 2838 155 } else if (s->match_available) {
2073 0 2838 if (bflush) {
2074 0 0 FLUSH_BLOCK_ONLY(s, 0);
2078 0 2838 if (s->strm->avail_out == 0) return need_more;
2089 53 4 if (s->match_available) {
2095 57 0 if (flush == Z_FINISH) {
2096 57 0 FLUSH_BLOCK(s, 1);
4 53 FLUSH_BLOCK(s, 1);
2099 0 0 if (s->sym_next)
2100 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
2123 0 0 if (s->lookahead <= MAX_MATCH) {
2125 0 0 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
0 0 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
2128 0 0 if (s->lookahead == 0) break; /* flush the current block */
2133 0 0 if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
0 0 if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
2136 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) {
2139 0 0 } while (prev == *++scan && prev == *++scan &&
0 0 } while (prev == *++scan && prev == *++scan &&
2140 0 0 prev == *++scan && prev == *++scan &&
0 0 prev == *++scan && prev == *++scan &&
2141 0 0 prev == *++scan && prev == *++scan &&
0 0 prev == *++scan && prev == *++scan &&
2142 0 0 prev == *++scan && prev == *++scan &&
0 0 prev == *++scan && prev == *++scan &&
2143 0 0 scan < strend);
2145 0 0 if (s->match_length > s->lookahead)
2152 0 0 if (s->match_length >= MIN_MATCH) {
2155 0 0 _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
2167 0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2170 0 0 if (flush == Z_FINISH) {
2171 0 0 FLUSH_BLOCK(s, 1);
0 0 FLUSH_BLOCK(s, 1);
2174 0 0 if (s->sym_next)
2175 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);
2191 0 0 if (s->lookahead == 0) {
2193 0 0 if (s->lookahead == 0) {
2194 0 0 if (flush == Z_NO_FLUSH)
2206 0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
0 0 if (bflush) FLUSH_BLOCK(s, 0);
2209 0 0 if (flush == Z_FINISH) {
2210 0 0 FLUSH_BLOCK(s, 1);
0 0 FLUSH_BLOCK(s, 1);
2213 0 0 if (s->sym_next)
2214 0 0 FLUSH_BLOCK(s, 0);
0 0 FLUSH_BLOCK(s, 0);