Branch Coverage

_rhash.c
Criterion Covered Total %
branch 120 202 59.4


line true false branch
89 0 6 if (count < 1) {
93 68 6 for (i = 0; i < count; i++) {
95 68 0 if (!IS_VALID_HASH_ID(hash_ids[i])) {
68 0 if (!IS_VALID_HASH_ID(hash_ids[i])) {
0 68 if (!IS_VALID_HASH_ID(hash_ids[i])) {
101 0 68 assert(hash_index < RHASH_HASH_COUNT); /* correct until extended hash_ids are supported */
110 0 6 if (rctx == NULL)
122 0 6 assert(phash_ctx >= (char*)&rctx->vector[count]);
123 0 6 assert(phash_ctx < ((char*)&rctx->vector[count] + DEFAULT_ALIGNMENT));
125 68 6 for (i = 0; i < count; i++) {
128 0 68 assert(info->context_size > 0);
129 0 68 assert(info->init != NULL);
130 0 68 assert(IS_PTR_ALIGNED_BY(phash_ctx, DEFAULT_ALIGNMENT)); /* hash context is aligned */
136 2 66 if ((hash_ids[i] & RHASH_BTIH) != 0)
149 6 0 if (!IS_VALID_HASH_MASK(hash_id)) {
0 6 if (!IS_VALID_HASH_MASK(hash_id)) {
153 2 4 if (HAS_ZERO_OR_ONE_BIT(hash_id)) {
160 68 4 for (count = 0; id <= hash_id; id = id << 1) {
161 0 68 assert(id != 0);
162 66 2 if (hash_id & id)
165 0 4 assert(count > 1);
175 0 4 if (ctx == 0) return;
179 35 4 for (i = 0; i < ectx->hash_vector_size; i++) {
181 2 33 if (info->cleanup != 0) {
193 0 3 assert(ectx->hash_vector_size > 0);
194 0 3 assert(ectx->hash_vector_size <= RHASH_HASH_COUNT);
198 4 3 for (i = 0; i < ectx->hash_vector_size; i++) {
200 0 4 if (info->cleanup != 0) {
204 0 4 assert(info->init != NULL);
215 0 8 assert(ectx->hash_vector_size <= RHASH_HASH_COUNT);
216 0 8 if (ectx->state != STATE_ACTIVE) return 0; /* do nothing if canceled */
221 70 8 for (i = 0; i < ectx->hash_vector_size; i++) {
223 0 70 assert(info->update != 0);
233 8 1 unsigned char* out = (first_result ? first_result : buffer);
235 0 9 assert(ectx->hash_vector_size <= RHASH_HASH_COUNT);
238 0 9 if ((ectx->flags & RCTX_FINALIZED_MASK) ==
242 72 9 for (i = 0; i < ectx->hash_vector_size; i++) {
244 0 72 assert(info->final != 0);
245 0 72 assert(info->info->digest_size < sizeof(buffer));
270 0 49 assert(ectx);
271 49 0 assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT);
0 49 assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT);
274 5 44 if ((ectx->flags & RCTX_FINALIZED_MASK) == RCTX_AUTO_FINAL) {
278 0 49 if (hash_id == 0) {
283 0 542 if (i >= ectx->hash_vector_size) {
288 49 493 if (info->info->hash_id == hash_id) break;
292 9 40 if (info->info->flags & F_SWAP32) {
293 0 9 assert((info->info->digest_size & 3) == 0);
296 3 37 } else if (info->info->flags & F_SWAP64) {
316 0 1 if (ctx == NULL) return -1;
330 0 0 if (ectx->state != STATE_ACTIVE)
332 0 0 if (ctx == NULL) {
337 0 0 if (!buffer)
340 0 0 while (!feof(fd)) {
341 0 0 if (ectx->state != STATE_ACTIVE)
345 0 0 if (ferror(fd)) {
348 0 0 } else if (length) {
351 0 0 if (ectx->callback) {
367 0 0 if (hash_id == 0) {
371 0 0 if ((fd = fopen(filepath, "rb")) == NULL)
373 0 0 if ((ctx = rhash_init(hash_id)) == NULL) {
379 0 0 if (res >= 0)
427 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;
434 1 0 return (int)(info ? (info->flags & F_BS32 ?
0 1 return (int)(info ? (info->flags & F_BS32 ?
441 1 0 return (info ? info->name : 0);
447 14 0 return (info ? info->magnet_name : 0);
457 3 0 if ((flags & RHPR_NO_MAGNET) == 0) {
461 3 0 if ((flags & RHPR_FILESIZE) != 0) {
465 0 3 if (num == 0) size++;
467 3 3 for (; num; num /= 10, size++);
471 1 2 if (filepath) {
476 8 3 for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) {
478 1 7 if ((bit & hash) == 0) continue;
479 0 7 if ((name = rhash_get_magnet_name(bit)) == 0) continue;
482 1 6 size += rhash_print(NULL, context, bit,
495 3 3 if (output == NULL)
499 3 0 if ((flags & RHPR_NO_MAGNET) == 0) {
504 3 0 if ((flags & RHPR_FILESIZE) != 0) {
512 1 2 if (filepath) {
519 6 3 for (i = 0; i < 2; i++) {
523 3 3 : hash & ~(RHASH_ED2K | RHASH_AICH));
524 2 4 if (!hash) continue;
527 7 4 for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) {
529 0 7 if ((bit & hash) == 0) continue;
530 0 7 if (!(name = rhash_get_magnet_name(bit))) continue;
537 1 6 output += rhash_print(output, context, bit,
569 0 1 if (flags & RHPR_URLENCODE) {
586 51 5 info = (hash_id != 0 ? rhash_info_by_id(hash_id) :
589 0 56 if (info == NULL) return 0;
591 0 56 assert(digest_size <= 64);
594 49 7 if ((flags & RHPR_FORMAT) == 0) {
596 7 42 flags |= (info->flags & RHASH_INFO_BASE32 ? RHPR_BASE32 : RHPR_HEX);
599 7 49 if (output == NULL) {
600 0 7 size_t multiplier = (flags & RHPR_URLENCODE ? 3 : 1);
616 1 48 if ((flags & ~RHPR_UPPERCASE) == (RHPR_REVERSE | RHPR_HEX)) {
621 8 1 for (; p < r; p++, r--) {
664 0 0 for (i = 0; i < ctx->hash_vector_size; i++) {
666 0 0 if (info->info->hash_id == (unsigned)ldata)
684 0 0 if (ldata) ctx->flags |= RCTX_AUTO_FINAL;