Branch Coverage

_rhash.c
Criterion Covered Total %
branch 115 192 59.9


line true false branch
78 0 6 if (hash_id == 0) {
84 0 6 assert(tail_bit_index < RHASH_HASH_COUNT);
88 2 4 if (hash_id == id) {
95 64 4 for (bit_index = tail_bit_index; id <= hash_id; bit_index++, id = id << 1) {
96 0 64 assert(id != 0);
97 0 64 assert(bit_index < RHASH_HASH_COUNT);
99 62 2 if (hash_id & id) {
106 0 4 assert(num > 1);
111 0 6 assert(aligned_size >= sizeof(rhash_context_ext));
115 0 6 if (rctx == NULL) return NULL;
126 0 6 assert(phash_ctx >= (char*)&rctx->vector[num]);
129 66 6 for (bit_index = tail_bit_index, id = 1 << tail_bit_index, i = 0;
133 64 2 if ((hash_id & id) != 0) {
135 0 64 assert(info->context_size > 0);
136 0 64 assert(((phash_ctx - (char*)0) & 7) == 0); /* hash context is aligned */
137 0 64 assert(info->init != NULL);
143 2 62 if ((id & RHASH_BTIH) != 0) rctx->bt_ctx = phash_ctx;
160 0 4 if (ctx == 0) return;
161 0 4 assert(ectx->hash_vector_size <= RHASH_HASH_COUNT);
165 33 4 for (i = 0; i < ectx->hash_vector_size; i++) {
167 2 31 if (info->cleanup != 0) {
180 0 3 assert(ectx->hash_vector_size > 0);
181 0 3 assert(ectx->hash_vector_size <= RHASH_HASH_COUNT);
185 4 3 for (i = 0; i < ectx->hash_vector_size; i++) {
187 0 4 if (info->cleanup != 0) {
191 0 4 assert(info->init != NULL);
202 0 8 assert(ectx->hash_vector_size <= RHASH_HASH_COUNT);
203 0 8 if (ectx->state != STATE_ACTIVE) return 0; /* do nothing if canceled */
208 66 8 for (i = 0; i < ectx->hash_vector_size; i++) {
210 0 66 assert(info->update != 0);
220 8 1 unsigned char* out = (first_result ? first_result : buffer);
222 0 9 assert(ectx->hash_vector_size <= RHASH_HASH_COUNT);
225 0 9 if ((ectx->flags & RCTX_FINALIZED_MASK) ==
229 68 9 for (i = 0; i < ectx->hash_vector_size; i++) {
231 0 68 assert(info->final != 0);
232 0 68 assert(info->info->digest_size < sizeof(buffer));
257 0 47 assert(ectx);
258 47 0 assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT);
0 47 assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT);
261 5 42 if ((ectx->flags & RCTX_FINALIZED_MASK) == RCTX_AUTO_FINAL) {
265 0 47 if (hash_id == 0) {
270 0 481 if (i >= ectx->hash_vector_size) {
275 47 434 if (info->info->hash_id == hash_id) break;
279 9 38 if (info->info->flags & F_SWAP32) {
280 0 9 assert((info->info->digest_size & 3) == 0);
283 3 35 } else if (info->info->flags & F_SWAP64) {
303 0 1 if (ctx == NULL) return -1;
317 0 0 if (ectx->state != STATE_ACTIVE) return 0; /* do nothing if canceled */
319 0 0 if (ctx == NULL) {
325 0 0 if (!pmem) return -1; /* errno is set to ENOMEM according to UNIX 98 */
330 0 0 while (!feof(fd)) {
332 0 0 if (ectx->state != STATE_ACTIVE) break;
336 0 0 if (ferror(fd)) {
339 0 0 } else if (length) {
342 0 0 if (ectx->callback) {
359 0 0 if (hash_id == 0) {
364 0 0 if ((fd = fopen(filepath, "rb")) == NULL) return -1;
366 0 0 if ((ctx = rhash_init(hash_id)) == NULL) {
421 2 0 if (hash_id == 0 || (hash_id & (hash_id - 1)) != 0) return -1;
0 2 if (hash_id == 0 || (hash_id & (hash_id - 1)) != 0) return -1;
428 1 0 return (int)(info ? (info->flags & F_BS32 ?
0 1 return (int)(info ? (info->flags & F_BS32 ?
435 1 0 return (info ? info->name : 0);
441 14 0 return (info ? info->magnet_name : 0);
451 3 0 if ((flags & RHPR_NO_MAGNET) == 0) {
455 3 0 if ((flags & RHPR_FILESIZE) != 0) {
459 0 3 if (num == 0) size++;
461 3 3 for (; num; num /= 10, size++);
465 1 2 if (filepath) {
470 8 3 for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) {
472 1 7 if ((bit & hash) == 0) continue;
473 0 7 if ((name = rhash_get_magnet_name(bit)) == 0) continue;
476 1 6 size += rhash_print(NULL, context, bit,
489 3 3 if (output == NULL) return rhash_get_magnet_url_size(
493 3 0 if ((flags & RHPR_NO_MAGNET) == 0) {
498 3 0 if ((flags & RHPR_FILESIZE) != 0) {
505 1 2 if (filepath) {
513 6 3 for (i = 0; i < 2; i++) {
517 3 3 : hash & ~(RHASH_ED2K | RHASH_AICH));
518 2 4 if (!hash) continue;
521 7 4 for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) {
523 0 7 if ((bit & hash) == 0) continue;
524 0 7 if (!(name = rhash_get_magnet_name(bit))) continue;
531 1 6 output += rhash_print(output, context, bit,
578 49 5 info = (hash_id != 0 ? rhash_info_by_id(hash_id) :
581 0 54 if (info == NULL) return 0;
583 0 54 assert(digest_size <= 64);
586 47 7 if ((flags & RHPR_FORMAT) == 0) {
588 7 40 flags |= (info->flags & RHASH_INFO_BASE32 ? RHPR_BASE32 : RHPR_HEX);
591 7 47 if (output == NULL) {
607 1 46 if ((flags & ~RHPR_UPPERCASE) == (RHPR_REVERSE | RHPR_HEX)) {
611 8 1 for (; p < r; p++, r--) {
653 0 0 if (bt == NULL) return RHASH_ERROR;
694 0 0 for (i = 0; i < ctx->hash_vector_size; i++) {
696 0 0 if (info->info->hash_id == (unsigned)ldata)
714 0 0 if (ldata) ctx->flags |= RCTX_AUTO_FINAL;