Exclude a few lines from lcov coverage stats:
- "fail" branches in selftests
- "should never happen" errors in SSL
- cipher_xxx() failures in SSL
- some things that fail only if malloc() fails
- some things that fail only if fread/fwrite()/ftell() fails
(after fopen() succeeded)
- some things that fail only if a parameter is invalid, but the parameter was
actually validated earlier
- generated code in library/error.c
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index c82e2e7..2451eb3 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -1641,10 +1641,10 @@
curve_info = mbedtls_ecp_curve_info_from_grp_id( ssl->handshake->ecdh_ctx.grp.id );
if( curve_info == NULL )
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) );
@@ -2037,10 +2037,10 @@
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED ||
MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED ||
MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
@@ -2089,10 +2089,10 @@
}
else
#endif
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
/*
* Read signature
@@ -2186,10 +2186,10 @@
else
#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \
MBEDTLS_SSL_PROTO_TLS1_2 */
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen :
(unsigned int) ( mbedtls_md_get_size( mbedtls_md_info_from_type( md_alg ) ) ) );
@@ -2248,8 +2248,10 @@
return( 0 );
}
+ // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
+ // LCOV_EXCL_STOP
}
#else
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
@@ -2623,10 +2625,10 @@
}
else
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl,
ciphersuite_info->key_exchange ) ) != 0 )
@@ -2646,11 +2648,11 @@
}
else
#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */
- {
+ { // LCOV_EXCL_START
((void) ciphersuite_info);
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
ssl->out_msglen = i + n;
ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE;
@@ -2696,8 +2698,10 @@
return( 0 );
}
+ // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
+ // LCOV_EXCL_STOP
}
#else
static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
@@ -2815,10 +2819,10 @@
}
else
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), md_alg, hash_start, hashlen,
ssl->out_msg + 6 + offset, &n,
@@ -2924,10 +2928,10 @@
ssl->session_negotiate->ticket_len = 0;
if( ( ticket = mbedtls_calloc( 1, ticket_len ) ) == NULL )
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "ticket alloc failed" ) );
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
- }
+ } // LCOV_EXCL_STOP
memcpy( ticket, msg + 6, ticket_len );