Move around some LCOV_EXCLs in src/common
Apparently, my compiler now generates coverage markers for label-only lines, so we need to exclude those too if they are meant to be unreachable.
This commit is contained in:
parent
9727a9248a
commit
a64d79ca4c
|
@ -907,8 +907,8 @@ tor_addr_is_loopback(const tor_addr_t *addr)
|
|||
return (tor_addr_to_ipv4h(addr) & 0xff000000) == 0x7f000000;
|
||||
case AF_UNSPEC:
|
||||
return 0;
|
||||
default:
|
||||
/* LCOV_EXCL_START */
|
||||
default:
|
||||
tor_fragile_assert();
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
@ -1031,8 +1031,10 @@ tor_addr_copy_tight(tor_addr_t *dest, const tor_addr_t *src)
|
|||
memcpy(dest->addr.in6_addr.s6_addr, src->addr.in6_addr.s6_addr, 16);
|
||||
case AF_UNSPEC:
|
||||
break;
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
tor_fragile_assert(); // LCOV_EXCL_LINE
|
||||
tor_fragile_assert();
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1138,8 +1140,8 @@ tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2,
|
|||
return 0;
|
||||
else
|
||||
return 1;
|
||||
default:
|
||||
/* LCOV_EXCL_START */
|
||||
default:
|
||||
tor_fragile_assert();
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
@ -1194,8 +1196,8 @@ tor_addr_hash(const tor_addr_t *addr)
|
|||
return 0x4e4d5342;
|
||||
case AF_INET6:
|
||||
return siphash24g(&addr->addr.in6_addr.s6_addr, 16);
|
||||
default:
|
||||
/* LCOV_EXCL_START */
|
||||
default:
|
||||
tor_fragile_assert();
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
@ -3350,8 +3350,8 @@ get_total_system_memory_impl(void)
|
|||
tor_free(s);
|
||||
return result * 1024;
|
||||
|
||||
err:
|
||||
/* LCOV_EXCL_START Can't reach this unless proc is broken. */
|
||||
err:
|
||||
tor_free(s);
|
||||
close(fd);
|
||||
return 0;
|
||||
|
|
|
@ -188,8 +188,9 @@ tor_compress_impl(int compress,
|
|||
"Error while %scompresing data: bad input?",
|
||||
compress?"":"un");
|
||||
goto err; // bad data.
|
||||
default:
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
tor_assert_nonfatal_unreached();
|
||||
goto err;
|
||||
// LCOV_EXCL_STOP
|
||||
|
|
|
@ -158,8 +158,10 @@ tor_lzma_state_size_precalc(int compress, compression_level_t level)
|
|||
|
||||
return (size_t)memory_usage;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
err:
|
||||
return 0; // LCOV_EXCL_LINE
|
||||
return 0;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
#endif /* defined(HAVE_LZMA) */
|
||||
|
||||
|
@ -212,9 +214,11 @@ tor_lzma_compress_new(int compress,
|
|||
atomic_counter_add(&total_lzma_allocation, result->allocation);
|
||||
return result;
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
err:
|
||||
tor_free(result); // LCOV_EXCL_LINE
|
||||
tor_free(result);
|
||||
return NULL;
|
||||
/* LCOV_EXCL_STOP */
|
||||
#else /* !(defined(HAVE_LZMA)) */
|
||||
(void)compress;
|
||||
(void)method;
|
||||
|
|
|
@ -1798,8 +1798,8 @@ crypto_digest_algorithm_get_name(digest_algorithm_t alg)
|
|||
return "sha3-256";
|
||||
case DIGEST_SHA3_512:
|
||||
return "sha3-512";
|
||||
default:
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
tor_fragile_assert();
|
||||
return "??unknown_digest??";
|
||||
// LCOV_EXCL_STOP
|
||||
|
@ -2447,9 +2447,10 @@ crypto_dh_new(int dh_type)
|
|||
#endif /* defined(OPENSSL_1_1_API) */
|
||||
|
||||
return res;
|
||||
err:
|
||||
|
||||
/* LCOV_EXCL_START
|
||||
* This error condition is only reached when an allocation fails */
|
||||
err:
|
||||
crypto_log_errors(LOG_WARN, "creating DH object");
|
||||
if (res->dh) DH_free(res->dh); /* frees p and g too */
|
||||
tor_free(res);
|
||||
|
|
|
@ -318,8 +318,11 @@ curve25519_basepoint_spot_check(void)
|
|||
}
|
||||
|
||||
goto end;
|
||||
// LCOV_EXCL_START -- we can only hit this code if there is a bug in our
|
||||
// curve25519-basepoint implementation.
|
||||
fail:
|
||||
r = -1;
|
||||
// LCOV_EXCL_STOP
|
||||
end:
|
||||
curve25519_use_ed = save_use_ed;
|
||||
return r;
|
||||
|
|
|
@ -293,9 +293,12 @@ ed25519_sign_prefixed,(ed25519_signature_t *signature_out,
|
|||
|
||||
prefixed_msg = get_prefixed_msg(msg, msg_len, prefix_str,
|
||||
&prefixed_msg_len);
|
||||
if (!prefixed_msg) {
|
||||
if (BUG(!prefixed_msg)) {
|
||||
/* LCOV_EXCL_START -- only possible when the message and prefix are
|
||||
* ridiculously huge */
|
||||
log_warn(LD_GENERAL, "Failed to get prefixed msg.");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
retval = ed25519_sign(signature_out,
|
||||
|
@ -338,9 +341,12 @@ ed25519_checksig_prefixed(const ed25519_signature_t *signature,
|
|||
|
||||
prefixed_msg = get_prefixed_msg(msg, msg_len, prefix_str,
|
||||
&prefixed_msg_len);
|
||||
if (!prefixed_msg) {
|
||||
if (BUG(!prefixed_msg)) {
|
||||
/* LCOV_EXCL_START -- only possible when the message and prefix are
|
||||
* ridiculously huge */
|
||||
log_warn(LD_GENERAL, "Failed to get prefixed msg.");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
retval = ed25519_checksig(signature,
|
||||
|
@ -718,8 +724,11 @@ ed25519_impl_spot_check,(void))
|
|||
*/
|
||||
goto end;
|
||||
|
||||
// LCOV_EXCL_START -- We can only reach this if our ed25519 implementation is
|
||||
// broken.
|
||||
fail:
|
||||
r = -1;
|
||||
// LCOV_EXCL_STOP
|
||||
end:
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ crypto_pwbox(uint8_t **out, size_t *outlen_out,
|
|||
rv = 0;
|
||||
goto out;
|
||||
|
||||
err:
|
||||
/* LCOV_EXCL_START
|
||||
|
||||
This error case is often unreachable if we're correctly coded, unless
|
||||
|
@ -123,6 +122,7 @@ crypto_pwbox(uint8_t **out, size_t *outlen_out,
|
|||
- pwbox_encoded_encode can't fail unless we're using trunnel wrong,
|
||||
or it's buggy.
|
||||
*/
|
||||
err:
|
||||
tor_free(result);
|
||||
rv = -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
@ -86,9 +86,11 @@ secret_to_key_key_len(uint8_t type)
|
|||
return DIGEST_LEN;
|
||||
case S2K_TYPE_SCRYPT:
|
||||
return DIGEST256_LEN;
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
tor_fragile_assert(); // LCOV_EXCL_LINE
|
||||
return -1; // LCOV_EXCL_LINE
|
||||
tor_fragile_assert();
|
||||
return -1;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,9 +171,11 @@ make_specifier(uint8_t *spec_out, uint8_t type, unsigned flags)
|
|||
/* r = 8; p = 2. */
|
||||
spec_out[SCRYPT_SPEC_LEN-1] = (3u << 4) | (1u << 0);
|
||||
break;
|
||||
// LCOV_EXCL_START - we should have returned above.
|
||||
default:
|
||||
tor_fragile_assert(); // LCOV_EXCL_LINE - we should have returned above.
|
||||
tor_fragile_assert();
|
||||
return S2K_BAD_ALGORITHM;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
return speclen;
|
||||
|
|
|
@ -444,8 +444,9 @@ tor_x509_name_new(const char *cname)
|
|||
goto error;
|
||||
/* LCOV_EXCL_BR_STOP */
|
||||
return name;
|
||||
error:
|
||||
|
||||
/* LCOV_EXCL_START : these lines will only execute on out of memory errors*/
|
||||
error:
|
||||
X509_NAME_free(name);
|
||||
return NULL;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
@ -2980,8 +2980,9 @@ unescape_string(const char *s, char **result, size_t *size_out)
|
|||
*out = '\0';
|
||||
if (size_out) *size_out = out - *result;
|
||||
return cp+1;
|
||||
case '\0':
|
||||
|
||||
/* LCOV_EXCL_START -- we caught this in parse_config_from_line. */
|
||||
case '\0':
|
||||
tor_fragile_assert();
|
||||
tor_free(*result);
|
||||
return NULL;
|
||||
|
@ -3029,8 +3030,9 @@ unescape_string(const char *s, char **result, size_t *size_out)
|
|||
*out++ = cp[1];
|
||||
cp += 2;
|
||||
break;
|
||||
default:
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
default:
|
||||
/* we caught this above in the initial loop. */
|
||||
tor_assert_nonfatal_unreached();
|
||||
tor_free(*result); return NULL;
|
||||
|
|
|
@ -266,10 +266,13 @@ base64_encode(char *dest, size_t destlen, const char *src, size_t srclen,
|
|||
ENCODE_N(3);
|
||||
ENCODE_PAD();
|
||||
break;
|
||||
// LCOV_EXCL_START -- we can't reach this point, because we enforce
|
||||
// 0 <= ncov_idx < 3 in the loop above.
|
||||
default:
|
||||
/* Something went catastrophically wrong. */
|
||||
tor_fragile_assert(); // LCOV_EXCL_LINE
|
||||
tor_fragile_assert();
|
||||
return -1;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
#undef ENCODE_N
|
||||
|
|
Loading…
Reference in New Issue