Fix unreachable code warnings with armc5

Some TLS-only code paths were not protected by an #ifdef and while some
compiler are happy to just silently remove them, armc5 complains:

Warning:  #111-D: statement is unreachable

Let's make armc5 happy.
This commit is contained in:
Manuel Pégourié-Gonnard 2019-06-18 10:56:09 +02:00
parent 19e8132e1e
commit 889bbc70b6
2 changed files with 36 additions and 16 deletions

View file

@ -969,8 +969,11 @@ static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl )
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)
if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) ) if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) )
return( 12 ); return( 12 );
MBEDTLS_SSL_TRANSPORT_ELSE
#endif #endif
#if defined(MBEDTLS_SSL_PROTO_TLS)
return( 4 ); return( 4 );
#endif
} }
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)

View file

@ -68,8 +68,11 @@ static inline size_t ssl_ep_len( const mbedtls_ssl_context *ssl )
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)
if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) ) if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) )
return( 2 ); return( 2 );
MBEDTLS_SSL_TRANSPORT_ELSE
#endif #endif
#if defined(MBEDTLS_SSL_PROTO_TLS)
return( 0 ); return( 0 );
#endif
} }
/* /*
@ -8598,8 +8601,10 @@ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl )
return( "unknown (DTLS)" ); return( "unknown (DTLS)" );
} }
} }
#endif MBEDTLS_SSL_TRANSPORT_ELSE
#endif /* MBEDTLS_SSL_PROTO_DTLS */
#if defined(MBEDTLS_SSL_PROTO_TLS)
{
switch( ssl->minor_ver ) switch( ssl->minor_ver )
{ {
case MBEDTLS_SSL_MINOR_VERSION_0: case MBEDTLS_SSL_MINOR_VERSION_0:
@ -8617,6 +8622,8 @@ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl )
default: default:
return( "unknown" ); return( "unknown" );
} }
}
#endif /* MBEDTLS_SSL_PROTO_TLS */
} }
int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ) int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl )
@ -9610,9 +9617,14 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
{ {
continue; continue;
} }
MBEDTLS_SSL_TRANSPORT_ELSE
#endif #endif
#if defined(MBEDTLS_SSL_PROTO_TLS)
{
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
} }
#endif
}
#endif /* MBEDTLS_SSL_CLI_C */ #endif /* MBEDTLS_SSL_CLI_C */
#if defined(MBEDTLS_SSL_SRV_C) #if defined(MBEDTLS_SSL_SRV_C)
@ -9627,9 +9639,14 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
{ {
continue; continue;
} }
MBEDTLS_SSL_TRANSPORT_ELSE
#endif #endif
#if defined(MBEDTLS_SSL_PROTO_TLS)
{
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
} }
#endif
}
#endif /* MBEDTLS_SSL_SRV_C */ #endif /* MBEDTLS_SSL_SRV_C */
#if defined(MBEDTLS_SSL_RENEGOTIATION) #if defined(MBEDTLS_SSL_RENEGOTIATION)