From 4a28563e84946423ea1ae6c67d9de918d68b3708 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Thu, 6 Oct 2022 18:30:10 +0100 Subject: [PATCH] Refactor macro-spanning ifs in ssl_client.c Signed-off-by: David Horstmann --- library/ssl_client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/ssl_client.c b/library/ssl_client.c index e7453d573..08cb3421e 100644 --- a/library/ssl_client.c +++ b/library/ssl_client.c @@ -376,9 +376,11 @@ static int ssl_write_client_hello_cipher_suites( /* * Add TLS_EMPTY_RENEGOTIATION_INFO_SCSV */ + int renegotiating = 0; #if defined(MBEDTLS_SSL_RENEGOTIATION) - if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) + renegotiating = ( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ); #endif + if( !renegotiating ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding EMPTY_RENEGOTIATION_INFO_SCSV" ) ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); @@ -790,9 +792,11 @@ static int ssl_prepare_client_hello( mbedtls_ssl_context *ssl ) * RFC 5077 section 3.4: "When presenting a ticket, the client MAY * generate and include a Session ID in the TLS ClientHello." */ + int renegotiating = 0; #if defined(MBEDTLS_SSL_RENEGOTIATION) - if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) + renegotiating = ( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ); #endif + if( !renegotiating ) { if( ( ssl->session_negotiate->ticket != NULL ) && ( ssl->session_negotiate->ticket_len != 0 ) )