Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/tests/suites/test_suite_net.function b/tests/suites/test_suite_net.function
index 08d48b3..fa09f5a 100644
--- a/tests/suites/test_suite_net.function
+++ b/tests/suites/test_suite_net.function
@@ -30,19 +30,18 @@
*
* \return \c 0 on success, a negative error code on error.
*/
-static int open_file_on_fd( mbedtls_net_context *ctx, int wanted_fd )
+static int open_file_on_fd(mbedtls_net_context *ctx, int wanted_fd)
{
- int got_fd = open( "/dev/null", O_RDONLY );
- TEST_ASSERT( got_fd >= 0 );
- if( got_fd != wanted_fd )
- {
- TEST_ASSERT( dup2( got_fd, wanted_fd ) >= 0 );
- TEST_ASSERT( close( got_fd ) >= 0 );
+ int got_fd = open("/dev/null", O_RDONLY);
+ TEST_ASSERT(got_fd >= 0);
+ if (got_fd != wanted_fd) {
+ TEST_ASSERT(dup2(got_fd, wanted_fd) >= 0);
+ TEST_ASSERT(close(got_fd) >= 0);
}
ctx->fd = wanted_fd;
- return( 0 );
+ return 0;
exit:
- return( -1 );
+ return -1;
}
#endif /* MBEDTLS_PLATFORM_IS_UNIXLIKE */
@@ -54,16 +53,17 @@
*/
/* BEGIN_CASE */
-void context_init_free( int reinit )
+void context_init_free(int reinit)
{
mbedtls_net_context ctx;
- mbedtls_net_init( &ctx );
- mbedtls_net_free( &ctx );
+ mbedtls_net_init(&ctx);
+ mbedtls_net_free(&ctx);
- if( reinit )
- mbedtls_net_init( &ctx );
- mbedtls_net_free( &ctx );
+ if (reinit) {
+ mbedtls_net_init(&ctx);
+ }
+ mbedtls_net_free(&ctx);
/* This test case always succeeds, functionally speaking. A plausible
* bug might trigger an invalid pointer dereference or a memory leak. */
@@ -72,7 +72,7 @@
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_PLATFORM_IS_UNIXLIKE */
-void poll_beyond_fd_setsize( )
+void poll_beyond_fd_setsize()
{
/* Test that mbedtls_net_poll does not misbehave when given a file
* descriptor greater or equal to FD_SETSIZE. This code is specific to
@@ -85,7 +85,7 @@
mbedtls_net_context ctx;
uint8_t buf[1];
- mbedtls_net_init( &ctx );
+ mbedtls_net_init(&ctx);
/* On many systems, by default, the maximum permitted file descriptor
* number is less than FD_SETSIZE. If so, raise the limit if
@@ -99,17 +99,16 @@
* might do); but we don't do such things in our test code, so the unit
* test will run if it can.
*/
- TEST_ASSERT( getrlimit( RLIMIT_NOFILE, &rlim_nofile ) == 0 );
- if( rlim_nofile.rlim_cur < FD_SETSIZE + 1 )
- {
+ TEST_ASSERT(getrlimit(RLIMIT_NOFILE, &rlim_nofile) == 0);
+ if (rlim_nofile.rlim_cur < FD_SETSIZE + 1) {
rlim_t old_rlim_cur = rlim_nofile.rlim_cur;
rlim_nofile.rlim_cur = FD_SETSIZE + 1;
- TEST_ASSUME( setrlimit( RLIMIT_NOFILE, &rlim_nofile ) == 0 );
+ TEST_ASSUME(setrlimit(RLIMIT_NOFILE, &rlim_nofile) == 0);
rlim_nofile.rlim_cur = old_rlim_cur;
restore_rlim_nofile = 1;
}
- TEST_ASSERT( open_file_on_fd( &ctx, FD_SETSIZE ) == 0 );
+ TEST_ASSERT(open_file_on_fd(&ctx, FD_SETSIZE) == 0);
/* In principle, mbedtls_net_poll() with valid arguments should succeed.
* However, we know that on Unix-like platforms (and others), this function
@@ -122,16 +121,17 @@
* is problematic on the particular platform where the code is running,
* a memory sanitizer such as UBSan should catch it.
*/
- ret = mbedtls_net_poll( &ctx, MBEDTLS_NET_POLL_READ, 0 );
- TEST_EQUAL( ret, MBEDTLS_ERR_NET_POLL_FAILED );
+ ret = mbedtls_net_poll(&ctx, MBEDTLS_NET_POLL_READ, 0);
+ TEST_EQUAL(ret, MBEDTLS_ERR_NET_POLL_FAILED);
/* mbedtls_net_recv_timeout() uses select() and fd_set in the same way. */
- ret = mbedtls_net_recv_timeout( &ctx, buf, sizeof( buf ), 0 );
- TEST_EQUAL( ret, MBEDTLS_ERR_NET_POLL_FAILED );
+ ret = mbedtls_net_recv_timeout(&ctx, buf, sizeof(buf), 0);
+ TEST_EQUAL(ret, MBEDTLS_ERR_NET_POLL_FAILED);
exit:
- mbedtls_net_free( &ctx );
- if( restore_rlim_nofile )
- setrlimit( RLIMIT_NOFILE, &rlim_nofile );
+ mbedtls_net_free(&ctx);
+ if (restore_rlim_nofile) {
+ setrlimit(RLIMIT_NOFILE, &rlim_nofile);
+ }
}
/* END_CASE */