From deff65a4fd3769550a583d7cec1c2fcf9ba65d28 Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Tue, 17 May 2011 12:13:35 +0000 Subject: [PATCH] CalculateSum8() and CalculateSum16() defined in BaseLib are used to calculate checksum. Signed-off-by: lzeng14 Reviewed-by: rsun3 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11674 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/FwVol/Ffs.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c index 5eb22d0ac5..2bd4405cf1 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c +++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c @@ -1,7 +1,7 @@ /** @file FFS file access utilities. -Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -105,18 +105,9 @@ VerifyFvHeaderChecksum ( IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader ) { - UINT32 Index; - UINT32 HeaderLength; UINT16 Checksum; - UINT16 *Ptr; - HeaderLength = FvHeader->HeaderLength; - Ptr = (UINT16 *)FvHeader; - Checksum = 0; - - for (Index = 0; Index < HeaderLength / sizeof (UINT16); Index++) { - Checksum = (UINT16)(Checksum + Ptr[Index]); - } + Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength); if (Checksum == 0) { return TRUE; @@ -140,16 +131,9 @@ VerifyHeaderChecksum ( IN EFI_FFS_FILE_HEADER *FfsHeader ) { - UINT32 Index; - UINT8 *Ptr; - UINT8 HeaderChecksum; - - Ptr = (UINT8 *)FfsHeader; - HeaderChecksum = 0; - for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) { - HeaderChecksum = (UINT8)(HeaderChecksum + Ptr[Index]); - } + UINT8 HeaderChecksum; + HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER)); HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File); if (HeaderChecksum == 0) { -- 2.39.2