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_srv.c b/library/ssl_srv.c
index b48a609..6919b1f 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -263,7 +263,7 @@
our_size = MBEDTLS_ECP_DP_MAX;
if( ( curves = mbedtls_calloc( our_size, sizeof( *curves ) ) ) == NULL )
- return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); // LCOV_EXCL_LINE
ssl->handshake->curves = curves;
@@ -2340,8 +2340,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_request( mbedtls_ssl_context *ssl )
@@ -2715,10 +2717,10 @@
md_alg = mbedtls_ssl_md_alg_from_hash( ssl->handshake->sig_alg );
if( md_alg == MBEDTLS_MD_NONE )
- {
+ { // LCOV_EXCL_START
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
- }
+ } // LCOV_EXCL_STOP
}
else
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
@@ -2813,10 +2815,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 ) ) ) );
@@ -3326,10 +3328,10 @@
}
else
#endif /* MBEDTLS_KEY_EXCHANGE_RSA_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_derive_keys( ssl ) ) != 0 )
{
@@ -3364,8 +3366,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_verify( mbedtls_ssl_context *ssl )
@@ -3489,10 +3493,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( i + 2 > ssl->in_hslen )
{