Switch to the new code style
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/programs/ssl/mini_client.c b/programs/ssl/mini_client.c
index efcf650..6dbbc6d 100644
--- a/programs/ssl/mini_client.c
+++ b/programs/ssl/mini_client.c
@@ -40,12 +40,12 @@
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_SSL_CLI_C) || \
!defined(UNIX)
-int main( void )
+int main(void)
{
- mbedtls_printf( "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or "
- "MBEDTLS_NET_C and/or MBEDTLS_SSL_CLI_C and/or UNIX "
- "not defined.\n");
- mbedtls_exit( 0 );
+ mbedtls_printf("MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or "
+ "MBEDTLS_NET_C and/or MBEDTLS_SSL_CLI_C and/or UNIX "
+ "not defined.\n");
+ mbedtls_exit(0);
}
#else
@@ -137,8 +137,7 @@
};
#endif /* MBEDTLS_X509_CRT_PARSE_C */
-enum exit_codes
-{
+enum exit_codes {
exit_ok = 0,
ctr_drbg_seed_failed,
ssl_config_defaults_failed,
@@ -152,7 +151,7 @@
};
-int main( void )
+int main(void)
{
int ret = exit_ok;
mbedtls_net_context server_fd;
@@ -165,62 +164,57 @@
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ssl_context ssl;
mbedtls_ssl_config conf;
- mbedtls_ctr_drbg_init( &ctr_drbg );
+ mbedtls_ctr_drbg_init(&ctr_drbg);
/*
* 0. Initialize and setup stuff
*/
- mbedtls_net_init( &server_fd );
- mbedtls_ssl_init( &ssl );
- mbedtls_ssl_config_init( &conf );
+ mbedtls_net_init(&server_fd);
+ mbedtls_ssl_init(&ssl);
+ mbedtls_ssl_config_init(&conf);
#if defined(MBEDTLS_X509_CRT_PARSE_C)
- mbedtls_x509_crt_init( &ca );
+ mbedtls_x509_crt_init(&ca);
#endif
- mbedtls_entropy_init( &entropy );
- if( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
- (const unsigned char *) pers, strlen( pers ) ) != 0 )
- {
+ mbedtls_entropy_init(&entropy);
+ if (mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
+ (const unsigned char *) pers, strlen(pers)) != 0) {
ret = ctr_drbg_seed_failed;
goto exit;
}
- if( mbedtls_ssl_config_defaults( &conf,
- MBEDTLS_SSL_IS_CLIENT,
- MBEDTLS_SSL_TRANSPORT_STREAM,
- MBEDTLS_SSL_PRESET_DEFAULT ) != 0 )
- {
+ if (mbedtls_ssl_config_defaults(&conf,
+ MBEDTLS_SSL_IS_CLIENT,
+ MBEDTLS_SSL_TRANSPORT_STREAM,
+ MBEDTLS_SSL_PRESET_DEFAULT) != 0) {
ret = ssl_config_defaults_failed;
goto exit;
}
- mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
+ mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg);
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
- mbedtls_ssl_conf_psk( &conf, psk, sizeof( psk ),
- (const unsigned char *) psk_id, sizeof( psk_id ) - 1 );
+ mbedtls_ssl_conf_psk(&conf, psk, sizeof(psk),
+ (const unsigned char *) psk_id, sizeof(psk_id) - 1);
#endif
#if defined(MBEDTLS_X509_CRT_PARSE_C)
- if( mbedtls_x509_crt_parse_der( &ca, ca_cert, sizeof( ca_cert ) ) != 0 )
- {
+ if (mbedtls_x509_crt_parse_der(&ca, ca_cert, sizeof(ca_cert)) != 0) {
ret = x509_crt_parse_failed;
goto exit;
}
- mbedtls_ssl_conf_ca_chain( &conf, &ca, NULL );
- mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_REQUIRED );
+ mbedtls_ssl_conf_ca_chain(&conf, &ca, NULL);
+ mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_REQUIRED);
#endif
- if( mbedtls_ssl_setup( &ssl, &conf ) != 0 )
- {
+ if (mbedtls_ssl_setup(&ssl, &conf) != 0) {
ret = ssl_setup_failed;
goto exit;
}
#if defined(MBEDTLS_X509_CRT_PARSE_C)
- if( mbedtls_ssl_set_hostname( &ssl, HOSTNAME ) != 0 )
- {
+ if (mbedtls_ssl_set_hostname(&ssl, HOSTNAME) != 0) {
ret = hostname_failed;
goto exit;
}
@@ -229,7 +223,7 @@
/*
* 1. Start the connection
*/
- memset( &addr, 0, sizeof( addr ) );
+ memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
ret = 1; /* for endianness detection */
@@ -237,23 +231,20 @@
addr.sin_addr.s_addr = *((char *) &ret) == ret ? ADDR_LE : ADDR_BE;
ret = 0;
- if( ( server_fd.fd = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
- {
+ if ((server_fd.fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ret = socket_failed;
goto exit;
}
- if( connect( server_fd.fd,
- (const struct sockaddr *) &addr, sizeof( addr ) ) < 0 )
- {
+ if (connect(server_fd.fd,
+ (const struct sockaddr *) &addr, sizeof(addr)) < 0) {
ret = connect_failed;
goto exit;
}
- mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL );
+ mbedtls_ssl_set_bio(&ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL);
- if( mbedtls_ssl_handshake( &ssl ) != 0 )
- {
+ if (mbedtls_ssl_handshake(&ssl) != 0) {
ret = ssl_handshake_failed;
goto exit;
}
@@ -261,26 +252,25 @@
/*
* 2. Write the GET request and close the connection
*/
- if( mbedtls_ssl_write( &ssl, (const unsigned char *) GET_REQUEST,
- sizeof( GET_REQUEST ) - 1 ) <= 0 )
- {
+ if (mbedtls_ssl_write(&ssl, (const unsigned char *) GET_REQUEST,
+ sizeof(GET_REQUEST) - 1) <= 0) {
ret = ssl_write_failed;
goto exit;
}
- mbedtls_ssl_close_notify( &ssl );
+ mbedtls_ssl_close_notify(&ssl);
exit:
- mbedtls_net_free( &server_fd );
+ mbedtls_net_free(&server_fd);
- mbedtls_ssl_free( &ssl );
- mbedtls_ssl_config_free( &conf );
- mbedtls_ctr_drbg_free( &ctr_drbg );
- mbedtls_entropy_free( &entropy );
+ mbedtls_ssl_free(&ssl);
+ mbedtls_ssl_config_free(&conf);
+ mbedtls_ctr_drbg_free(&ctr_drbg);
+ mbedtls_entropy_free(&entropy);
#if defined(MBEDTLS_X509_CRT_PARSE_C)
- mbedtls_x509_crt_free( &ca );
+ mbedtls_x509_crt_free(&ca);
#endif
- mbedtls_exit( ret );
+ mbedtls_exit(ret);
}
#endif