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/entropy.c b/library/entropy.c
index cdbd35c..b6fff7e 100644
--- a/library/entropy.c
+++ b/library/entropy.c
@@ -360,10 +360,10 @@
goto exit;
if( fwrite( buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f ) != MBEDTLS_ENTROPY_BLOCK_SIZE )
- {
+ { // LCOV_EXCL_START
ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR;
goto exit;
- }
+ } // LCOV_EXCL_STOP
ret = 0;
@@ -389,10 +389,10 @@
n = MBEDTLS_ENTROPY_MAX_SEED_SIZE;
if( fread( buf, 1, n, f ) != n )
- {
+ { // LCOV_EXCL_START
fclose( f );
return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR );
- }
+ } // LCOV_EXCL_STOP
fclose( f );
@@ -437,15 +437,15 @@
/* First do a gather to make sure we have default sources */
if( ( ret = mbedtls_entropy_gather( &ctx ) ) != 0 )
- goto cleanup;
+ goto cleanup; // LCOV_EXCL_LINE
ret = mbedtls_entropy_add_source( &ctx, entropy_dummy_source, NULL, 16,
MBEDTLS_ENTROPY_SOURCE_WEAK );
if( ret != 0 )
- goto cleanup;
+ goto cleanup; // LCOV_EXCL_LINE
if( ( ret = mbedtls_entropy_update_manual( &ctx, buf, sizeof buf ) ) != 0 )
- goto cleanup;
+ goto cleanup; // LCOV_EXCL_LINE
/*
* To test that mbedtls_entropy_func writes correct number of bytes:
@@ -458,7 +458,7 @@
for( i = 0; i < 8; i++ )
{
if( ( ret = mbedtls_entropy_func( &ctx, buf, sizeof( buf ) ) ) != 0 )
- goto cleanup;
+ goto cleanup; // LCOV_EXCL_LINE
for( j = 0; j < sizeof( buf ); j++ )
acc[j] |= buf[j];
@@ -467,10 +467,10 @@
for( j = 0; j < sizeof( buf ); j++ )
{
if( acc[j] == 0 )
- {
+ { // LCOV_EXCL_START
ret = 1;
goto cleanup;
- }
+ } // LCOV_EXCL_STOP
}
cleanup:
@@ -479,7 +479,7 @@
if( verbose != 0 )
{
if( ret != 0 )
- mbedtls_printf( "failed\n" );
+ mbedtls_printf( "failed\n" ); // LCOV_EXCL_LINE
else
mbedtls_printf( "passed\n" );