[coreboot-gerrit] Patch set updated for coreboot: drivers/intel/fsp1_1: Replace for/break with returns
Leroy P Leahy (leroy.p.leahy@intel.com)
gerrit at coreboot.org
Tue May 17 18:32:45 CEST 2016
Leroy P Leahy (leroy.p.leahy at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14869
-gerrit
commit 6392061cf66c5101971c4c6535b5ba2110bb3b61
Author: Lee Leahy <leroy.p.leahy at intel.com>
Date: Tue May 17 08:57:42 2016 -0700
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 at intel.com>
---
src/drivers/intel/fsp1_1/fsp_util.c | 84 +++++++++++++++++--------------------
1 file 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 1aa3aec..49a494f 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;
}
More information about the coreboot-gerrit
mailing list