mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-25 21:21:05 +00:00
Refactor slightly to silence a clang-analyze warning
Since the buffer is used in a few places, it seems Clang isn't clever enough to realise that the first byte is never touched. So, even though the function has a correct null check for ssl->handshake, Clang complains. Pulling the handshake type out into its own variable is enough for Clang's analysis to kick in though.
This commit is contained in:
parent
b47fd5e8c9
commit
f0021645b0
|
@ -2709,7 +2709,7 @@ void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl )
|
||||||
*/
|
*/
|
||||||
int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl )
|
int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
int ret, done = 0;
|
int ret, done = 0, out_msg_type;
|
||||||
size_t len = ssl->out_msglen;
|
size_t len = ssl->out_msglen;
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write record" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write record" ) );
|
||||||
|
@ -2725,7 +2725,9 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl )
|
||||||
#endif
|
#endif
|
||||||
if( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )
|
if( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )
|
||||||
{
|
{
|
||||||
if( ssl->out_msg[0] != MBEDTLS_SSL_HS_HELLO_REQUEST &&
|
out_msg_type = ssl->out_msg[0];
|
||||||
|
|
||||||
|
if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST &&
|
||||||
ssl->handshake == NULL )
|
ssl->handshake == NULL )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||||
|
@ -2752,7 +2754,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl )
|
||||||
len += 8;
|
len += 8;
|
||||||
|
|
||||||
/* Write message_seq and update it, except for HelloRequest */
|
/* Write message_seq and update it, except for HelloRequest */
|
||||||
if( ssl->out_msg[0] != MBEDTLS_SSL_HS_HELLO_REQUEST )
|
if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST )
|
||||||
{
|
{
|
||||||
ssl->out_msg[4] = ( ssl->handshake->out_msg_seq >> 8 ) & 0xFF;
|
ssl->out_msg[4] = ( ssl->handshake->out_msg_seq >> 8 ) & 0xFF;
|
||||||
ssl->out_msg[5] = ( ssl->handshake->out_msg_seq ) & 0xFF;
|
ssl->out_msg[5] = ( ssl->handshake->out_msg_seq ) & 0xFF;
|
||||||
|
@ -2770,7 +2772,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl )
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||||
|
|
||||||
if( ssl->out_msg[0] != MBEDTLS_SSL_HS_HELLO_REQUEST )
|
if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST )
|
||||||
ssl->handshake->update_checksum( ssl, ssl->out_msg, len );
|
ssl->handshake->update_checksum( ssl, ssl->out_msg, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue