a-style fixes for code

pull/9758/head
Nir Sonnenschein 2019-02-24 14:25:25 +02:00
parent 4a4af57c22
commit ffaf083b75
1 changed files with 14 additions and 18 deletions

View File

@ -36,7 +36,7 @@ static int psa_spm_init_refence_counter = 0;
/* maximal memoty allocation for reading large hash ort mac input buffers. /* maximal memoty allocation for reading large hash ort mac input buffers.
the data will be read in chunks of size */ the data will be read in chunks of size */
#if !defined (MAX_DATA_CHUNK_SIZE_IN_BYTES) #if !defined (MAX_DATA_CHUNK_SIZE_IN_BYTES)
#define MAX_DATA_CHUNK_SIZE_IN_BYTES 400 #define MAX_DATA_CHUNK_SIZE_IN_BYTES 400
#endif #endif
#ifndef MAX_CONCURRENT_HASH_CLONES #ifndef MAX_CONCURRENT_HASH_CLONES
@ -96,7 +96,7 @@ static void destroy_hash_clone(void *source_operation)
} }
static inline psa_status_t get_hash_clone(size_t index, int32_t partition_id, static inline psa_status_t get_hash_clone(size_t index, int32_t partition_id,
psa_spm_hash_clone_t **hash_clone) psa_spm_hash_clone_t **hash_clone)
{ {
if (index >= MAX_CONCURRENT_HASH_CLONES || if (index >= MAX_CONCURRENT_HASH_CLONES ||
psa_spm_hash_clones[index].partition_id != partition_id || psa_spm_hash_clones[index].partition_id != partition_id ||
@ -228,7 +228,7 @@ static void psa_mac_operation(void)
case PSA_MAC_UPDATE: { case PSA_MAC_UPDATE: {
uint8_t * input_buffer = NULL; uint8_t *input_buffer = NULL;
size_t data_remaining = msg.in_size[1]; size_t data_remaining = msg.in_size[1];
size_t allocation_size = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES); size_t allocation_size = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES);
size_t size_to_read = 0; size_t size_to_read = 0;
@ -239,8 +239,7 @@ static void psa_mac_operation(void)
break; break;
} }
while (data_remaining > 0) while (data_remaining > 0) {
{
size_to_read = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES); size_to_read = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES);
bytes_read = psa_read(msg.handle, 1, input_buffer, bytes_read = psa_read(msg.handle, 1, input_buffer,
size_to_read); size_to_read);
@ -254,8 +253,7 @@ static void psa_mac_operation(void)
bytes_read); bytes_read);
// stop on error // stop on error
if (status != PSA_SUCCESS) if (status != PSA_SUCCESS) {
{
break; break;
} }
data_remaining = data_remaining - bytes_read; data_remaining = data_remaining - bytes_read;
@ -392,7 +390,7 @@ static void psa_hash_operation(void)
} }
case PSA_HASH_UPDATE: { case PSA_HASH_UPDATE: {
uint8_t * input_buffer = NULL; uint8_t *input_buffer = NULL;
size_t data_remaining = msg.in_size[1]; size_t data_remaining = msg.in_size[1];
size_t size_to_read = 0; size_t size_to_read = 0;
size_t allocation_size = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES); size_t allocation_size = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES);
@ -403,8 +401,7 @@ static void psa_hash_operation(void)
break; break;
} }
while (data_remaining > 0) while (data_remaining > 0) {
{
size_to_read = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES); size_to_read = MIN(data_remaining, MAX_DATA_CHUNK_SIZE_IN_BYTES);
bytes_read = psa_read(msg.handle, 1, input_buffer, bytes_read = psa_read(msg.handle, 1, input_buffer,
size_to_read); size_to_read);
@ -414,12 +411,11 @@ static void psa_hash_operation(void)
} }
status = psa_hash_update(msg.rhandle, status = psa_hash_update(msg.rhandle,
input_buffer, input_buffer,
bytes_read); bytes_read);
// stop on error // stop on error
if (status != PSA_SUCCESS) if (status != PSA_SUCCESS) {
{
break; break;
} }
data_remaining = data_remaining - bytes_read; data_remaining = data_remaining - bytes_read;