Branch Coverage

deps/libgit2/src/delta.c
Criterion Covered Total %
branch 115 218 52.7


line true false branch
127 0 12 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry));
0 12 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry));
128 0 12 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *));
0 12 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *));
130 0 12 GIT_ERROR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len);
0 12 GIT_ERROR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len);
131 0 12 GIT_ERROR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len);
0 12 GIT_ERROR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len);
133 0 12 if (!git__is_ulong(index_len)) {
139 0 12 GIT_ERROR_CHECK_ALLOC(*out);
157 12 0 if (!buf || !bufsize)
0 12 if (!buf || !bufsize)
164 0 12 if (bufsize >= 0xffffffffUL) {
172 12 0 for (i = 4; i < 31 && (1u << i) < hsize; i++);
0 12 for (i = 4; i < 31 && (1u << i) < hsize; i++);
176 0 12 if (lookup_index_alloc(&mem, &memsize, entries, hsize) < 0)
193 0 12 if (!hash_count) {
200 120 12 for (data = buffer + entries * RABIN_WINDOW - RABIN_WINDOW;
204 1920 120 for (i = 1; i <= RABIN_WINDOW; i++)
206 0 120 if (val == prev_val) {
232 192 12 for (i = 0; i < hsize; i++) {
233 192 0 if (hash_count[i] < HASH_LIMIT)
242 0 0 } while(--skip && entry);
0 0 } while(--skip && entry);
244 0 0 } while (entry);
259 0 12 assert(index);
286 20 0 if (!trg_buf || !trg_size)
0 20 if (!trg_buf || !trg_size)
289 20 0 if (index->src_size > UINT_MAX ||
20 0 if (index->src_size > UINT_MAX ||
290 0 20 trg_size > UINT_MAX ||
298 20 0 if (max_size && bufsize >= max_size)
20 0 if (max_size && bufsize >= max_size)
301 0 20 GIT_ERROR_CHECK_ALLOC(buf);
305 13 20 while (i >= 0x80) {
313 13 20 while (i >= 0x80) {
326 320 20 for (i = 0; i < RABIN_WINDOW && data < top; i++, data++) {
320 0 for (i = 0; i < RABIN_WINDOW && data < top; i++, data++) {
334 936 3 while (data < top) {
335 936 0 if (msize < 4096) {
340 898 936 for (entry = index->hash[i]; entry; entry = entry->next) {
344 889 9 if (entry->val != val)
346 6 3 if (ref_size > (unsigned int)(top - src))
348 0 9 if (ref_size <= msize)
350 382 2 while (ref_size-- && *src++ == *ref)
375 7 while (ref_size-- && *src++ == *ref)
352 9 0 if (msize < (unsigned int)(ref - entry->ptr)) {
356 0 9 if (msize >= 4096) /* good enough */
362 927 9 if (msize < 4) {
363 7 920 if (!inscnt)
367 0 927 if (inscnt == 0x7f) {
376 9 0 if (inscnt) {
377 168 0 while (moff && ref_data[moff-1] == data[-1]) {
162 6 while (moff && ref_data[moff-1] == data[-1]) {
383 159 3 if (--inscnt)
394 0 9 left = (msize < 0x10000) ? 0 : (msize - 0x10000);
400 6 3 if (moff & 0x000000ff)
402 0 9 if (moff & 0x0000ff00)
404 0 9 if (moff & 0x00ff0000)
406 0 9 if (moff & 0xff000000)
409 9 0 if (msize & 0x00ff)
411 0 9 if (msize & 0xff00)
420 9 0 if (msize < 4096) {
423 144 9 for (j = -RABIN_WINDOW; j < 0; j++)
429 17 919 if (bufpos >= bufsize - MAX_OP_SIZE) {
432 17 0 if (max_size && bufsize >= max_size)
17 0 if (max_size && bufsize >= max_size)
434 17 0 if (max_size && bufpos > max_size)
17 0 if (max_size && bufpos > max_size)
437 0 0 if (!buf) {
444 18 2 if (inscnt)
447 20 0 if (max_size && bufpos > max_size) {
17 3 if (max_size && bufpos > max_size) {
475 0 4 if (d == end) {
483 0 4 } while (c & 0x80);
513 0 0 while (len < buffer_len) {
516 0 0 if (read == 0)
519 0 0 if (read == GIT_EBUFS)
554 2 0 if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) {
0 2 if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) {
559 0 2 if (hdr_sz(&res_sz, &delta, delta_end) < 0) {
564 0 2 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1);
0 2 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1);
566 0 2 GIT_ERROR_CHECK_ALLOC(res_dp);
572 2 2 while (delta < delta_end) {
574 2 0 if (cmd & 0x80) {
579 0 2 if (cmd & 0x01) ADD_DELTA(off, 0UL);
0 0 if (cmd & 0x01) ADD_DELTA(off, 0UL);
580 0 2 if (cmd & 0x02) ADD_DELTA(off, 8UL);
0 0 if (cmd & 0x02) ADD_DELTA(off, 8UL);
581 0 2 if (cmd & 0x04) ADD_DELTA(off, 16UL);
0 0 if (cmd & 0x04) ADD_DELTA(off, 16UL);
582 0 2 if (cmd & 0x08) ADD_DELTA(off, 24UL);
0 0 if (cmd & 0x08) ADD_DELTA(off, 24UL);
584 2 0 if (cmd & 0x10) ADD_DELTA(len, 0UL);
2 0 if (cmd & 0x10) ADD_DELTA(len, 0UL);
585 0 2 if (cmd & 0x20) ADD_DELTA(len, 8UL);
0 0 if (cmd & 0x20) ADD_DELTA(len, 8UL);
586 0 2 if (cmd & 0x40) ADD_DELTA(len, 16UL);
0 0 if (cmd & 0x40) ADD_DELTA(len, 16UL);
587 0 2 if (!len) len = 0x10000;
590 0 2 if (GIT_ADD_SIZET_OVERFLOW(&end, off, len) ||
2 0 if (GIT_ADD_SIZET_OVERFLOW(&end, off, len) ||
591 2 0 base_len < end || res_sz < len)
598 0 0 } else if (cmd) {
603 0 0 if (delta_end - delta < cmd || res_sz < cmd)
0 0 if (delta_end - delta < cmd || res_sz < cmd)
616 2 0 if (delta != delta_end || res_sz)
2 0 if (delta != delta_end || res_sz)