diff options
author | johpow01 <john.powell@arm.com> | 2020-07-01 17:09:57 -0500 |
---|---|---|
committer | johpow01 <john.powell@arm.com> | 2020-07-16 13:10:23 -0500 |
commit | d471bd9cfc58bce8efa8fa2d355a20950022f44d (patch) | |
tree | 00e6bd011906fbe4b5f8703454be0f2c776e90f6 /drivers/io/io_fip.c | |
parent | 8d5db315d32fd304e4f9ade13d7b62df91c88cb1 (diff) | |
download | platform_external_arm-trusted-firmware-d471bd9cfc58bce8efa8fa2d355a20950022f44d.tar.gz platform_external_arm-trusted-firmware-d471bd9cfc58bce8efa8fa2d355a20950022f44d.tar.bz2 platform_external_arm-trusted-firmware-d471bd9cfc58bce8efa8fa2d355a20950022f44d.zip |
IO Driver Misra Cleanup
This patch cleans up MISRA C violations in the IO driver files. Some
things did not make sense to fix or would require sweeping changes
but the simple issues have been resolved.
Defects Fixed
File Line Rule
drivers/io/io_fip.c 39 MISRA C-2012 Rule 5.6 (required)
drivers/io/io_fip.c 52 MISRA C-2012 Rule 8.9 (advisory)
drivers/io/io_fip.c 60 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_fip.c 285 MISRA C-2012 Rule 8.9 (advisory)
drivers/io/io_fip.c 336 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_fip.c 340 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_fip.c 342 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_memmap.c 30 MISRA C-2012 Rule 5.6 (required)
drivers/io/io_memmap.c 32 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_memmap.c 85 MISRA C-2012 Rule 11.8 (required)
drivers/io/io_semihosting.c 66 MISRA C-2012 Rule 11.8 (required)
drivers/io/io_storage.c 73 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_storage.c 116 MISRA C-2012 Rule 13.4 (advisory)
Signed-off-by: John Powell <john.powell@arm.com>
Change-Id: Id9b1b2b684588d4eaab674ed4ed04f3950dd21f4
Diffstat (limited to 'drivers/io/io_fip.c')
-rw-r--r-- | drivers/io/io_fip.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c index 02f85d603..c11ef115a 100644 --- a/drivers/io/io_fip.c +++ b/drivers/io/io_fip.c @@ -36,7 +36,7 @@ typedef struct { unsigned int file_pos; fip_toc_entry_t entry; -} file_state_t; +} fip_file_state_t; /* * Maintain dev_spec per FIP Device @@ -49,7 +49,6 @@ typedef struct { uint16_t plat_toc_flag; } fip_dev_state_t; -static const uuid_t uuid_null; /* * Only one file can be open across all FIP device * as backends like io_memmap don't support @@ -57,7 +56,7 @@ static const uuid_t uuid_null; * backend handle should be maintained per FIP device * if the same support is available in the backend */ -static file_state_t current_file = {0}; +static fip_file_state_t current_fip_file = {0}; static uintptr_t backend_dev_handle; static uintptr_t backend_image_spec; @@ -288,6 +287,7 @@ static int fip_file_open(io_dev_info_t *dev_info, const uintptr_t spec, int result; uintptr_t backend_handle; const io_uuid_spec_t *uuid_spec = (io_uuid_spec_t *)spec; + static const uuid_t uuid_null = { {0} }; /* Double braces for clang */ size_t bytes_read; int found_file = 0; @@ -300,7 +300,7 @@ static int fip_file_open(io_dev_info_t *dev_info, const uintptr_t spec, * When the system supports dynamic memory allocation we can allow more * than one open file at a time if needed. */ - if (current_file.entry.offset_address != 0) { + if (current_fip_file.entry.offset_address != 0U) { WARN("fip_file_open : Only one open file at a time.\n"); return -ENOMEM; } @@ -326,31 +326,32 @@ static int fip_file_open(io_dev_info_t *dev_info, const uintptr_t spec, found_file = 0; do { result = io_read(backend_handle, - (uintptr_t)¤t_file.entry, - sizeof(current_file.entry), + (uintptr_t)¤t_fip_file.entry, + sizeof(current_fip_file.entry), &bytes_read); if (result == 0) { - if (compare_uuids(¤t_file.entry.uuid, + if (compare_uuids(¤t_fip_file.entry.uuid, &uuid_spec->uuid) == 0) { found_file = 1; - break; } } else { WARN("Failed to read FIP (%i)\n", result); goto fip_file_open_close; } - } while (compare_uuids(¤t_file.entry.uuid, &uuid_null) != 0); + } while ((found_file == 0) && + (compare_uuids(¤t_fip_file.entry.uuid, + &uuid_null) != 0)); if (found_file == 1) { /* All fine. Update entity info with file state and return. Set - * the file position to 0. The 'current_file.entry' holds the - * base and size of the file. + * the file position to 0. The 'current_fip_file.entry' holds + * the base and size of the file. */ - current_file.file_pos = 0; - entity->info = (uintptr_t)¤t_file; + current_fip_file.file_pos = 0; + entity->info = (uintptr_t)¤t_fip_file; } else { /* Did not find the file in the FIP. */ - current_file.entry.offset_address = 0; + current_fip_file.entry.offset_address = 0; result = -ENOENT; } @@ -368,7 +369,7 @@ static int fip_file_len(io_entity_t *entity, size_t *length) assert(entity != NULL); assert(length != NULL); - *length = ((file_state_t *)entity->info)->entry.size; + *length = ((fip_file_state_t *)entity->info)->entry.size; return 0; } @@ -379,7 +380,7 @@ static int fip_file_read(io_entity_t *entity, uintptr_t buffer, size_t length, size_t *length_read) { int result; - file_state_t *fp; + fip_file_state_t *fp; size_t file_offset; size_t bytes_read; uintptr_t backend_handle; @@ -397,7 +398,7 @@ static int fip_file_read(io_entity_t *entity, uintptr_t buffer, size_t length, goto fip_file_read_exit; } - fp = (file_state_t *)entity->info; + fp = (fip_file_state_t *)entity->info; /* Seek to the position in the FIP where the payload lives */ file_offset = fp->entry.offset_address + fp->file_pos; @@ -436,8 +437,8 @@ static int fip_file_close(io_entity_t *entity) /* Clear our current file pointer. * If we had malloc() we would free() here. */ - if (current_file.entry.offset_address != 0) { - zeromem(¤t_file, sizeof(current_file)); + if (current_fip_file.entry.offset_address != 0U) { + zeromem(¤t_fip_file, sizeof(current_fip_file)); } /* Clear the Entity info. */ |