Switch to the new code style

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/tests/suites/test_suite_psa_its.function b/tests/suites/test_suite_psa_its.function
index 12878b5..7864b9c 100644
--- a/tests/suites/test_suite_psa_its.function
+++ b/tests/suites/test_suite_psa_its.function
@@ -20,23 +20,23 @@
 #define PSA_ITS_STORAGE_FILENAME_PATTERN "%08lx%08lx"
 #define PSA_ITS_STORAGE_SUFFIX ".psa_its"
 #define PSA_ITS_STORAGE_FILENAME_LENGTH         \
-    ( sizeof( PSA_ITS_STORAGE_PREFIX ) - 1 + /*prefix without terminating 0*/ \
-      16 + /*UID (64-bit number in hex)*/                               \
-      16 + /*UID (64-bit number in hex)*/                               \
-      sizeof( PSA_ITS_STORAGE_SUFFIX ) - 1 + /*suffix without terminating 0*/ \
-      1 /*terminating null byte*/ )
+    (sizeof(PSA_ITS_STORAGE_PREFIX) - 1 +    /*prefix without terminating 0*/ \
+     16 +  /*UID (64-bit number in hex)*/                               \
+     16 +  /*UID (64-bit number in hex)*/                               \
+     sizeof(PSA_ITS_STORAGE_SUFFIX) - 1 +    /*suffix without terminating 0*/ \
+     1 /*terminating null byte*/)
 #define PSA_ITS_STORAGE_TEMP \
     PSA_ITS_STORAGE_PREFIX "tempfile" PSA_ITS_STORAGE_SUFFIX
-static void psa_its_fill_filename( psa_storage_uid_t uid, char *filename )
+static void psa_its_fill_filename(psa_storage_uid_t uid, char *filename)
 {
     /* Break up the UID into two 32-bit pieces so as not to rely on
      * long long support in snprintf. */
-    mbedtls_snprintf( filename, PSA_ITS_STORAGE_FILENAME_LENGTH,
-                      "%s" PSA_ITS_STORAGE_FILENAME_PATTERN "%s",
-                      PSA_ITS_STORAGE_PREFIX,
-                      (unsigned long) ( uid >> 32 ),
-                      (unsigned long) ( uid & 0xffffffff ),
-                      PSA_ITS_STORAGE_SUFFIX );
+    mbedtls_snprintf(filename, PSA_ITS_STORAGE_FILENAME_LENGTH,
+                     "%s" PSA_ITS_STORAGE_FILENAME_PATTERN "%s",
+                     PSA_ITS_STORAGE_PREFIX,
+                     (unsigned long) (uid >> 32),
+                     (unsigned long) (uid & 0xffffffff),
+                     PSA_ITS_STORAGE_SUFFIX);
 }
 
 /* Maximum uid used by the test, recorded so that cleanup() can delete
@@ -44,7 +44,7 @@
  * need to and should not be taken into account for uid_max. */
 static psa_storage_uid_t uid_max = 0;
 
-static void cleanup( void )
+static void cleanup(void)
 {
     /* Call remove() on all the files that a test might have created.
      * We ignore the error if the file exists but remove() fails because
@@ -55,25 +55,25 @@
      * test case. */
     char filename[PSA_ITS_STORAGE_FILENAME_LENGTH];
     psa_storage_uid_t uid;
-    for( uid = 0; uid < uid_max; uid++ )
-    {
-        psa_its_fill_filename( uid, filename );
-        (void) remove( filename );
+    for (uid = 0; uid < uid_max; uid++) {
+        psa_its_fill_filename(uid, filename);
+        (void) remove(filename);
     }
-    psa_its_fill_filename( (psa_storage_uid_t)( -1 ), filename );
-    (void) remove( filename );
-    (void) remove( PSA_ITS_STORAGE_TEMP );
+    psa_its_fill_filename((psa_storage_uid_t) (-1), filename);
+    (void) remove(filename);
+    (void) remove(PSA_ITS_STORAGE_TEMP);
     uid_max = 0;
 }
 
-static psa_status_t psa_its_set_wrap( psa_storage_uid_t uid,
-                                      uint32_t data_length,
-                                      const void *p_data,
-                                      psa_storage_create_flags_t create_flags )
+static psa_status_t psa_its_set_wrap(psa_storage_uid_t uid,
+                                     uint32_t data_length,
+                                     const void *p_data,
+                                     psa_storage_create_flags_t create_flags)
 {
-    if( uid_max != (psa_storage_uid_t)( -1 ) && uid_max < uid )
+    if (uid_max != (psa_storage_uid_t) (-1) && uid_max < uid) {
         uid_max = uid;
-    return( psa_its_set( uid, data_length, p_data, create_flags ) );
+    }
+    return psa_its_set(uid, data_length, p_data, create_flags);
 }
 
 /* END_HEADER */
@@ -84,7 +84,7 @@
  */
 
 /* BEGIN_CASE */
-void set_get_remove( int uid_arg, int flags_arg, data_t *data )
+void set_get_remove(int uid_arg, int flags_arg, data_t *data)
 {
     psa_storage_uid_t uid = uid_arg;
     uint32_t flags = flags_arg;
@@ -92,28 +92,28 @@
     unsigned char *buffer = NULL;
     size_t ret_len = 0;
 
-    ASSERT_ALLOC( buffer, data->len );
+    ASSERT_ALLOC(buffer, data->len);
 
-    PSA_ASSERT( psa_its_set_wrap( uid, data->len, data->x, flags ) );
+    PSA_ASSERT(psa_its_set_wrap(uid, data->len, data->x, flags));
 
-    PSA_ASSERT( psa_its_get_info( uid, &info ) );
-    TEST_ASSERT( info.size == data->len );
-    TEST_ASSERT( info.flags == flags );
-    PSA_ASSERT( psa_its_get( uid, 0, data->len, buffer, &ret_len ) );
-    ASSERT_COMPARE( data->x, data->len, buffer, ret_len );
+    PSA_ASSERT(psa_its_get_info(uid, &info));
+    TEST_ASSERT(info.size == data->len);
+    TEST_ASSERT(info.flags == flags);
+    PSA_ASSERT(psa_its_get(uid, 0, data->len, buffer, &ret_len));
+    ASSERT_COMPARE(data->x, data->len, buffer, ret_len);
 
-    PSA_ASSERT( psa_its_remove( uid ) );
+    PSA_ASSERT(psa_its_remove(uid));
 
 exit:
-    mbedtls_free( buffer );
-    cleanup( );
+    mbedtls_free(buffer);
+    cleanup();
 }
 /* END_CASE */
 
 /* BEGIN_CASE */
-void set_overwrite( int uid_arg,
-                    int flags1_arg, data_t *data1,
-                    int flags2_arg, data_t *data2 )
+void set_overwrite(int uid_arg,
+                   int flags1_arg, data_t *data1,
+                   int flags2_arg, data_t *data2)
 {
     psa_storage_uid_t uid = uid_arg;
     uint32_t flags1 = flags1_arg;
@@ -122,33 +122,33 @@
     unsigned char *buffer = NULL;
     size_t ret_len = 0;
 
-    ASSERT_ALLOC( buffer, MAX( data1->len, data2->len ) );
+    ASSERT_ALLOC(buffer, MAX(data1->len, data2->len));
 
-    PSA_ASSERT( psa_its_set_wrap( uid, data1->len, data1->x, flags1 ) );
-    PSA_ASSERT( psa_its_get_info( uid, &info ) );
-    TEST_ASSERT( info.size == data1->len );
-    TEST_ASSERT( info.flags == flags1 );
-    PSA_ASSERT( psa_its_get( uid, 0, data1->len, buffer, &ret_len ) );
-    ASSERT_COMPARE( data1->x, data1->len, buffer, ret_len );
+    PSA_ASSERT(psa_its_set_wrap(uid, data1->len, data1->x, flags1));
+    PSA_ASSERT(psa_its_get_info(uid, &info));
+    TEST_ASSERT(info.size == data1->len);
+    TEST_ASSERT(info.flags == flags1);
+    PSA_ASSERT(psa_its_get(uid, 0, data1->len, buffer, &ret_len));
+    ASSERT_COMPARE(data1->x, data1->len, buffer, ret_len);
 
-    PSA_ASSERT( psa_its_set_wrap( uid, data2->len, data2->x, flags2 ) );
-    PSA_ASSERT( psa_its_get_info( uid, &info ) );
-    TEST_ASSERT( info.size == data2->len );
-    TEST_ASSERT( info.flags == flags2 );
+    PSA_ASSERT(psa_its_set_wrap(uid, data2->len, data2->x, flags2));
+    PSA_ASSERT(psa_its_get_info(uid, &info));
+    TEST_ASSERT(info.size == data2->len);
+    TEST_ASSERT(info.flags == flags2);
     ret_len = 0;
-    PSA_ASSERT( psa_its_get( uid, 0, data2->len, buffer, &ret_len ) );
-    ASSERT_COMPARE( data2->x, data2->len, buffer, ret_len );
+    PSA_ASSERT(psa_its_get(uid, 0, data2->len, buffer, &ret_len));
+    ASSERT_COMPARE(data2->x, data2->len, buffer, ret_len);
 
-    PSA_ASSERT( psa_its_remove( uid ) );
+    PSA_ASSERT(psa_its_remove(uid));
 
 exit:
-    mbedtls_free( buffer );
-    cleanup( );
+    mbedtls_free(buffer);
+    cleanup();
 }
 /* END_CASE */
 
 /* BEGIN_CASE */
-void set_multiple( int first_id, int count )
+void set_multiple(int first_id, int count)
 {
     psa_storage_uid_t uid0 = first_id;
     psa_storage_uid_t uid;
@@ -156,58 +156,55 @@
     char retrieved[40];
     size_t ret_len = 0;
 
-    memset( stored, '.', sizeof( stored ) );
-    for( uid = uid0; uid < uid0 + count; uid++ )
-    {
-        mbedtls_snprintf( stored, sizeof( stored ),
-                          "Content of file 0x%08lx", (unsigned long) uid );
-        PSA_ASSERT( psa_its_set_wrap( uid, sizeof( stored ), stored, 0 ) );
+    memset(stored, '.', sizeof(stored));
+    for (uid = uid0; uid < uid0 + count; uid++) {
+        mbedtls_snprintf(stored, sizeof(stored),
+                         "Content of file 0x%08lx", (unsigned long) uid);
+        PSA_ASSERT(psa_its_set_wrap(uid, sizeof(stored), stored, 0));
     }
 
-    for( uid = uid0; uid < uid0 + count; uid++ )
-    {
-        mbedtls_snprintf( stored, sizeof( stored ),
-                          "Content of file 0x%08lx", (unsigned long) uid );
-        PSA_ASSERT( psa_its_get( uid, 0, sizeof( stored ), retrieved, &ret_len ) );
-        ASSERT_COMPARE( retrieved, ret_len,
-                        stored, sizeof( stored ) );
-        PSA_ASSERT( psa_its_remove( uid ) );
-        TEST_ASSERT( psa_its_get( uid, 0, 0, NULL, NULL ) ==
-                     PSA_ERROR_DOES_NOT_EXIST );
+    for (uid = uid0; uid < uid0 + count; uid++) {
+        mbedtls_snprintf(stored, sizeof(stored),
+                         "Content of file 0x%08lx", (unsigned long) uid);
+        PSA_ASSERT(psa_its_get(uid, 0, sizeof(stored), retrieved, &ret_len));
+        ASSERT_COMPARE(retrieved, ret_len,
+                       stored, sizeof(stored));
+        PSA_ASSERT(psa_its_remove(uid));
+        TEST_ASSERT(psa_its_get(uid, 0, 0, NULL, NULL) ==
+                    PSA_ERROR_DOES_NOT_EXIST);
     }
 
 exit:
-    cleanup( );
+    cleanup();
 }
 /* END_CASE */
 
 /* BEGIN_CASE */
-void nonexistent( int uid_arg, int create_and_remove )
+void nonexistent(int uid_arg, int create_and_remove)
 {
     psa_storage_uid_t uid = uid_arg;
     struct psa_storage_info_t info;
 
-    if( create_and_remove )
-    {
-        PSA_ASSERT( psa_its_set_wrap( uid, 0, NULL, 0 ) );
-        PSA_ASSERT( psa_its_remove( uid ) );
+    if (create_and_remove) {
+        PSA_ASSERT(psa_its_set_wrap(uid, 0, NULL, 0));
+        PSA_ASSERT(psa_its_remove(uid));
     }
 
-    TEST_ASSERT( psa_its_remove( uid ) == PSA_ERROR_DOES_NOT_EXIST );
-    TEST_ASSERT( psa_its_get_info( uid, &info ) ==
-                 PSA_ERROR_DOES_NOT_EXIST );
-    TEST_ASSERT( psa_its_get( uid, 0, 0, NULL, NULL ) ==
-                 PSA_ERROR_DOES_NOT_EXIST );
+    TEST_ASSERT(psa_its_remove(uid) == PSA_ERROR_DOES_NOT_EXIST);
+    TEST_ASSERT(psa_its_get_info(uid, &info) ==
+                PSA_ERROR_DOES_NOT_EXIST);
+    TEST_ASSERT(psa_its_get(uid, 0, 0, NULL, NULL) ==
+                PSA_ERROR_DOES_NOT_EXIST);
 
 exit:
-    cleanup( );
+    cleanup();
 }
 /* END_CASE */
 
 /* BEGIN_CASE */
-void get_at( int uid_arg, data_t *data,
-             int offset, int length_arg,
-             int expected_status )
+void get_at(int uid_arg, data_t *data,
+            int offset, int length_arg,
+            int expected_status)
 {
     psa_storage_uid_t uid = uid_arg;
     unsigned char *buffer = NULL;
@@ -217,31 +214,33 @@
     size_t i;
     size_t ret_len = 0;
 
-    ASSERT_ALLOC( buffer, length + 16 );
+    ASSERT_ALLOC(buffer, length + 16);
     trailer = buffer + length;
-    memset( trailer, '-', 16 );
+    memset(trailer, '-', 16);
 
-    PSA_ASSERT( psa_its_set_wrap( uid, data->len, data->x, 0 ) );
+    PSA_ASSERT(psa_its_set_wrap(uid, data->len, data->x, 0));
 
-    status = psa_its_get( uid, offset, length_arg, buffer, &ret_len );
-    TEST_ASSERT( status == (psa_status_t) expected_status );
-    if( status == PSA_SUCCESS )
-        ASSERT_COMPARE( data->x + offset, (size_t) length_arg,
-                        buffer, ret_len );
-    for( i = 0; i < 16; i++ )
-        TEST_ASSERT( trailer[i] == '-' );
-    PSA_ASSERT( psa_its_remove( uid ) );
+    status = psa_its_get(uid, offset, length_arg, buffer, &ret_len);
+    TEST_ASSERT(status == (psa_status_t) expected_status);
+    if (status == PSA_SUCCESS) {
+        ASSERT_COMPARE(data->x + offset, (size_t) length_arg,
+                       buffer, ret_len);
+    }
+    for (i = 0; i < 16; i++) {
+        TEST_ASSERT(trailer[i] == '-');
+    }
+    PSA_ASSERT(psa_its_remove(uid));
 
 exit:
-    mbedtls_free( buffer );
-    cleanup( );
+    mbedtls_free(buffer);
+    cleanup();
 }
 /* END_CASE */
 
 /* BEGIN_CASE */
-void get_fail( int uid_arg, data_t *data,
-               int overwrite_magic, int cut_header,
-               int expected_status )
+void get_fail(int uid_arg, data_t *data,
+              int overwrite_magic, int cut_header,
+              int expected_status)
 {
     psa_storage_uid_t uid = uid_arg;
     unsigned char *buffer = NULL;
@@ -252,54 +251,53 @@
     FILE *stream = NULL;
     char bad_char = 'X';
 
-    PSA_ASSERT( psa_its_set_wrap( uid, data->len, data->x, 0 ) );
+    PSA_ASSERT(psa_its_set_wrap(uid, data->len, data->x, 0));
 
-    psa_its_fill_filename( uid, filename );
-    stream = fopen( filename, "rb+" );
-    TEST_ASSERT( NULL != stream );
-    if( 0 != overwrite_magic )
-    {
+    psa_its_fill_filename(uid, filename);
+    stream = fopen(filename, "rb+");
+    TEST_ASSERT(NULL != stream);
+    if (0 != overwrite_magic) {
         /* Overwrite the 1st byte of the file, the ITS magic number */
-        TEST_ASSERT( fseek( stream, 0, SEEK_SET ) == 0 );
-        n = fwrite( &bad_char, 1, 1, stream );
-        TEST_ASSERT( 1 == n );
+        TEST_ASSERT(fseek(stream, 0, SEEK_SET) == 0);
+        n = fwrite(&bad_char, 1, 1, stream);
+        TEST_ASSERT(1 == n);
     }
-    if( 0 != cut_header )
-    {
+    if (0 != cut_header) {
         /* Reopen file and truncate it to 0 byte by specifying the 'w' flag */
-        stream = freopen( filename, "wb", stream );
-        TEST_ASSERT( NULL != stream );
+        stream = freopen(filename, "wb", stream);
+        TEST_ASSERT(NULL != stream);
     }
-    fclose( stream );
+    fclose(stream);
     stream = NULL;
 
-    status = psa_its_get( uid, 0, 0, buffer, &ret_len );
-    TEST_ASSERT( status == (psa_status_t) expected_status );
-    TEST_ASSERT( 0 == ret_len );
-    PSA_ASSERT( psa_its_remove( uid ) );
+    status = psa_its_get(uid, 0, 0, buffer, &ret_len);
+    TEST_ASSERT(status == (psa_status_t) expected_status);
+    TEST_ASSERT(0 == ret_len);
+    PSA_ASSERT(psa_its_remove(uid));
 
     /* Check if the file is really deleted. */
-    stream = fopen( filename, "rb" );
-    TEST_ASSERT( NULL == stream );
+    stream = fopen(filename, "rb");
+    TEST_ASSERT(NULL == stream);
 
 exit:
-    if( stream != NULL )
-        fclose( stream );
+    if (stream != NULL) {
+        fclose(stream);
+    }
 
-    mbedtls_free( buffer );
-    cleanup( );
+    mbedtls_free(buffer);
+    cleanup();
 }
 /* END_CASE */
 
 /* BEGIN_CASE */
-void set_fail( int uid_arg, data_t *data,
-               int expected_status )
+void set_fail(int uid_arg, data_t *data,
+              int expected_status)
 {
     psa_storage_uid_t uid = uid_arg;
-    TEST_ASSERT( psa_its_set_wrap( uid, data->len, data->x, 0 ) ==
-                 (psa_status_t) expected_status );
+    TEST_ASSERT(psa_its_set_wrap(uid, data->len, data->x, 0) ==
+                (psa_status_t) expected_status);
 
-    exit:
-    cleanup( );
+exit:
+    cleanup();
 }
 /* END_CASE */