diff options
author | Lee Leahy <leroy.p.leahy@intel.com> | 2016-05-17 08:57:42 -0700 |
---|---|---|
committer | Leroy P Leahy <leroy.p.leahy@intel.com> | 2016-05-17 20:15:59 +0200 |
commit | 00c35c1a9873eda27944d076a31397dbcb50befd (patch) | |
tree | deec4d4f8716c51b2823e165b8dd88371b9ae2fd /src/drivers | |
parent | c1cbc605cd8d01b096edbcdb44134ca5632bde0a (diff) |
drivers/intel/fsp1_1: Replace for/break with returns
Coverity does not like the use of for/break, switch to using returns
instead.
Found-by: Coverity CID 1349855
TEST=Build and run on Galileo Gen2
Change-Id: I4e5767b09faefa275dd32d3b76dda063f7c22f6f
Signed-off-by: Lee Leahy <leroy.p.leahy@intel.com>
Reviewed-on: https://review.coreboot.org/14869
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/intel/fsp1_1/fsp_util.c | 84 |
1 files changed, 38 insertions, 46 deletions
diff --git a/src/drivers/intel/fsp1_1/fsp_util.c b/src/drivers/intel/fsp1_1/fsp_util.c index 1aa3aec92c..49a494feda 100644 --- a/src/drivers/intel/fsp1_1/fsp_util.c +++ b/src/drivers/intel/fsp1_1/fsp_util.c @@ -41,61 +41,53 @@ FSP_INFO_HEADER *find_fsp(uintptr_t fsp_base_address) u32 *image_id; - for (;;) { - /* Get the FSP binary base address in CBFS */ - fsp_ptr.u32 = fsp_base_address; + /* Get the FSP binary base address in CBFS */ + fsp_ptr.u32 = fsp_base_address; - /* Check the FV signature, _FVH */ - if (fsp_ptr.fvh->Signature != 0x4856465F) { - fsp_ptr.u8 = (u8 *)ERROR_NO_FV_SIG; - break; - } - - /* Locate the file header which follows the FV header. */ - fsp_ptr.u8 += fsp_ptr.fvh->ExtHeaderOffset; - fsp_ptr.u8 += fsp_ptr.fveh->ExtHeaderSize; - fsp_ptr.u8 = (u8 *)ALIGN_UP(fsp_ptr.u32, 8); - - /* Check the FFS GUID */ - if ((((u32 *)&fsp_ptr.ffh->Name)[0] != 0x912740BE) - || (((u32 *)&fsp_ptr.ffh->Name)[1] != 0x47342284) - || (((u32 *)&fsp_ptr.ffh->Name)[2] != 0xB08471B9) - || (((u32 *)&fsp_ptr.ffh->Name)[3] != 0x0C3F3527)) { - fsp_ptr.u8 = (u8 *)ERROR_NO_FFS_GUID; - break; - } + /* Check the FV signature, _FVH */ + if (fsp_ptr.fvh->Signature != 0x4856465F) { + return (FSP_INFO_HEADER *)ERROR_NO_FV_SIG; + } - /* Locate the Raw Section Header */ - fsp_ptr.u8 += sizeof(EFI_FFS_FILE_HEADER); + /* Locate the file header which follows the FV header. */ + fsp_ptr.u8 += fsp_ptr.fvh->ExtHeaderOffset; + fsp_ptr.u8 += fsp_ptr.fveh->ExtHeaderSize; + fsp_ptr.u8 = (u8 *)ALIGN_UP(fsp_ptr.u32, 8); + + /* Check the FFS GUID */ + if ((((u32 *)&fsp_ptr.ffh->Name)[0] != 0x912740BE) + || (((u32 *)&fsp_ptr.ffh->Name)[1] != 0x47342284) + || (((u32 *)&fsp_ptr.ffh->Name)[2] != 0xB08471B9) + || (((u32 *)&fsp_ptr.ffh->Name)[3] != 0x0C3F3527)) { + return (FSP_INFO_HEADER *)ERROR_NO_FFS_GUID; + } - if (fsp_ptr.rs->Type != EFI_SECTION_RAW) { - fsp_ptr.u8 = (u8 *)ERROR_NO_INFO_HEADER; - break; - } + /* Locate the Raw Section Header */ + fsp_ptr.u8 += sizeof(EFI_FFS_FILE_HEADER); - /* Locate the FSP INFO Header which follows the Raw Header. */ - fsp_ptr.u8 += sizeof(EFI_RAW_SECTION); + if (fsp_ptr.rs->Type != EFI_SECTION_RAW) { + return (FSP_INFO_HEADER *)ERROR_NO_INFO_HEADER; + } - /* Verify that the FSP base address.*/ - if (fsp_ptr.fih->ImageBase != fsp_base_address) { - fsp_ptr.u8 = (u8 *)ERROR_IMAGEBASE_MISMATCH; - break; - } + /* Locate the FSP INFO Header which follows the Raw Header. */ + fsp_ptr.u8 += sizeof(EFI_RAW_SECTION); - /* Verify the FSP Signature */ - if (fsp_ptr.fih->Signature != FSP_SIG) { - fsp_ptr.u8 = (u8 *)ERROR_INFO_HEAD_SIG_MISMATCH; - break; - } + /* Verify that the FSP base address.*/ + if (fsp_ptr.fih->ImageBase != fsp_base_address) { + return (FSP_INFO_HEADER *)ERROR_IMAGEBASE_MISMATCH; + } - /* Verify the FSP ID */ - image_id = (u32 *)&fsp_ptr.fih->ImageId[0]; - if ((image_id[0] != fsp_id.int_id[0]) - || (image_id[1] != fsp_id.int_id[1])) - fsp_ptr.u8 = (u8 *)ERROR_FSP_SIG_MISMATCH; - break; + /* Verify the FSP Signature */ + if (fsp_ptr.fih->Signature != FSP_SIG) { + return (FSP_INFO_HEADER *)ERROR_INFO_HEAD_SIG_MISMATCH; } + /* Verify the FSP ID */ + image_id = (u32 *)&fsp_ptr.fih->ImageId[0]; + if ((image_id[0] != fsp_id.int_id[0]) + || (image_id[1] != fsp_id.int_id[1])) + return (FSP_INFO_HEADER *)ERROR_FSP_SIG_MISMATCH; + return fsp_ptr.fih; } |