From 59c6f2ef21b7c9fabd1c7e4eb4101530a78b97b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 22 Jan 2015 11:06:40 +0000 Subject: [PATCH] Avoid nested if's without braces. Creates a potential for confusing code if we later want to add an else clause. --- library/ssl_cli.c | 16 +++++++++------- library/ssl_srv.c | 16 ++++++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 95699b4a8f..c3729eeaec 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -605,16 +605,18 @@ static int ssl_write_client_hello( ssl_context *ssl ) */ #if defined(POLARSSL_SSL_RENEGOTIATION) if( ssl->renegotiation == SSL_INITIAL_HANDSHAKE ) -#endif - if( ssl->session_negotiate->ticket != NULL && - ssl->session_negotiate->ticket_len != 0 ) { - ret = ssl->f_rng( ssl->p_rng, ssl->session_negotiate->id, 32 ); +#endif + if( ssl->session_negotiate->ticket != NULL && + ssl->session_negotiate->ticket_len != 0 ) + { + ret = ssl->f_rng( ssl->p_rng, ssl->session_negotiate->id, 32 ); - if( ret != 0 ) - return( ret ); + if( ret != 0 ) + return( ret ); - ssl->session_negotiate->length = n = 32; + ssl->session_negotiate->length = n = 32; + } } #endif /* POLARSSL_SSL_SESSION_TICKETS */ diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 0b947ba081..138d1f981a 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1248,10 +1248,12 @@ static int ssl_parse_client_hello( ssl_context *ssl ) #if defined(POLARSSL_SSL_RENEGOTIATION) if( ssl->renegotiation == SSL_INITIAL_HANDSHAKE ) #endif - if( ( ret = ssl_fetch_input( ssl, 5 ) ) != 0 ) { - SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); - return( ret ); + if( ( ret = ssl_fetch_input( ssl, 5 ) ) != 0 ) + { + SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); + return( ret ); + } } buf = ssl->in_hdr; @@ -1301,10 +1303,12 @@ static int ssl_parse_client_hello( ssl_context *ssl ) #if defined(POLARSSL_SSL_RENEGOTIATION) if( ssl->renegotiation == SSL_INITIAL_HANDSHAKE ) #endif - if( ( ret = ssl_fetch_input( ssl, 5 + n ) ) != 0 ) { - SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); - return( ret ); + if( ( ret = ssl_fetch_input( ssl, 5 + n ) ) != 0 ) + { + SSL_DEBUG_RET( 1, "ssl_fetch_input", ret ); + return( ret ); + } } buf = ssl->in_msg;