[coreboot-gerrit] New patch to review for coreboot: drivers/intel/fsp1_1: Replace for/break with goto

Leroy P Leahy (leroy.p.leahy@intel.com) gerrit at coreboot.org
Tue May 17 18:11:05 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 f96477b8eb806d2cea9ffd7c8d508cfa0e8a1e43
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 goto
    
    Coverity does not like the use of for/break, switch to using goto
    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 | 90 ++++++++++++++++++-------------------
 1 file changed, 44 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..2e748cc 100644
--- a/src/drivers/intel/fsp1_1/fsp_util.c
+++ b/src/drivers/intel/fsp1_1/fsp_util.c
@@ -41,61 +41,59 @@ 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) {
+		fsp_ptr.u8 = (u8 *)ERROR_NO_FV_SIG;
+		goto header_not_found;
+	}
 
-		/* 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)) {
+		fsp_ptr.u8 = (u8 *)ERROR_NO_FFS_GUID;
+		goto header_not_found;
+	}
 
-		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) {
+		fsp_ptr.u8 = (u8 *)ERROR_NO_INFO_HEADER;
+		goto header_not_found;
+	}
 
-		/* 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) {
+		fsp_ptr.u8 = (u8 *)ERROR_IMAGEBASE_MISMATCH;
+		goto header_not_found;
+	}
 
-		/* 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) {
+		fsp_ptr.u8 = (u8 *)ERROR_INFO_HEAD_SIG_MISMATCH;
+		goto header_not_found;
 	}
 
+	/* 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;
+
+header_not_found:
 	return fsp_ptr.fih;
 }
 



More information about the coreboot-gerrit mailing list