summaryrefslogtreecommitdiffstats
path: root/SignedCapsulePkg/Library
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:14 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitb87864896714cf3062a7bc6d577d8fbd62d105e5 (patch)
tree95bf726dde947a9da3abd39c4fe998f7f1a3ab4f /SignedCapsulePkg/Library
parent47d20b54f9a65b08aa602a1866c1b59a69088dfc (diff)
downloadedk2-b87864896714cf3062a7bc6d577d8fbd62d105e5.tar.gz
SignedCapsulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the SignedCapsulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Diffstat (limited to 'SignedCapsulePkg/Library')
-rw-r--r--SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c446
-rw-r--r--SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c603
-rw-r--r--SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c15
3 files changed, 578 insertions, 486 deletions
diff --git a/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c b/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c
index 0f1444ba06..d65d988c75 100644
--- a/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c
+++ b/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c
@@ -30,9 +30,9 @@
#include <Protocol/FirmwareManagement.h>
-EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *mImageFmpInfo;
-UINTN mImageFmpInfoSize;
-EFI_GUID mEdkiiSystemFirmwareFileGuid;
+EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *mImageFmpInfo;
+UINTN mImageFmpInfoSize;
+EFI_GUID mEdkiiSystemFirmwareFileGuid;
/**
Check if a block of buffer is erased.
@@ -46,16 +46,16 @@ EFI_GUID mEdkiiSystemFirmwareFileGuid;
**/
BOOLEAN
IsBufferErased (
- IN UINT8 ErasePolarity,
- IN VOID *InBuffer,
- IN UINTN BufferSize
+ IN UINT8 ErasePolarity,
+ IN VOID *InBuffer,
+ IN UINTN BufferSize
)
{
- UINTN Count;
- UINT8 EraseByte;
- UINT8 *Buffer;
+ UINTN Count;
+ UINT8 EraseByte;
+ UINT8 *Buffer;
- if(ErasePolarity == 1) {
+ if (ErasePolarity == 1) {
EraseByte = 0xFF;
} else {
EraseByte = 0;
@@ -86,17 +86,17 @@ IsBufferErased (
**/
BOOLEAN
GetSectionByType (
- IN VOID *SectionBuffer,
- IN UINT32 SectionBufferSize,
- IN EFI_SECTION_TYPE SectionType,
- IN UINTN SectionInstance,
- OUT VOID **OutSectionBuffer,
- OUT UINTN *OutSectionSize
+ IN VOID *SectionBuffer,
+ IN UINT32 SectionBufferSize,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ OUT VOID **OutSectionBuffer,
+ OUT UINTN *OutSectionSize
)
{
- EFI_COMMON_SECTION_HEADER *SectionHeader;
- UINTN SectionSize;
- UINTN Instance;
+ EFI_COMMON_SECTION_HEADER *SectionHeader;
+ UINTN SectionSize;
+ UINTN Instance;
DEBUG ((DEBUG_INFO, "GetSectionByType - Buffer: 0x%08x - 0x%08x\n", SectionBuffer, SectionBufferSize));
@@ -108,20 +108,20 @@ GetSectionByType (
Instance = 0;
while ((UINTN)SectionHeader < (UINTN)SectionBuffer + SectionBufferSize) {
DEBUG ((DEBUG_INFO, "GetSectionByType - Section: 0x%08x\n", SectionHeader));
- if (IS_SECTION2(SectionHeader)) {
- SectionSize = SECTION2_SIZE(SectionHeader);
+ if (IS_SECTION2 (SectionHeader)) {
+ SectionSize = SECTION2_SIZE (SectionHeader);
} else {
- SectionSize = SECTION_SIZE(SectionHeader);
+ SectionSize = SECTION_SIZE (SectionHeader);
}
if (SectionHeader->Type == SectionType) {
if (Instance == SectionInstance) {
*OutSectionBuffer = (UINT8 *)SectionHeader;
- *OutSectionSize = SectionSize;
- DEBUG((DEBUG_INFO, "GetSectionByType - 0x%x - 0x%x\n", *OutSectionBuffer, *OutSectionSize));
+ *OutSectionSize = SectionSize;
+ DEBUG ((DEBUG_INFO, "GetSectionByType - 0x%x - 0x%x\n", *OutSectionBuffer, *OutSectionSize));
return TRUE;
} else {
- DEBUG((DEBUG_INFO, "GetSectionByType - find section instance %x\n", Instance));
+ DEBUG ((DEBUG_INFO, "GetSectionByType - find section instance %x\n", Instance));
Instance++;
}
} else {
@@ -134,7 +134,7 @@ GetSectionByType (
//
// Next Section
//
- SectionHeader = (EFI_COMMON_SECTION_HEADER *)((UINTN)SectionHeader + ALIGN_VALUE(SectionSize, 4));
+ SectionHeader = (EFI_COMMON_SECTION_HEADER *)((UINTN)SectionHeader + ALIGN_VALUE (SectionSize, 4));
}
return FALSE;
@@ -155,25 +155,25 @@ GetSectionByType (
**/
BOOLEAN
GetFfsByName (
- IN VOID *FdStart,
- IN UINTN FdSize,
- IN EFI_GUID *FileName,
- IN EFI_FV_FILETYPE Type,
- OUT VOID **OutFfsBuffer,
- OUT UINTN *OutFfsBufferSize
+ IN VOID *FdStart,
+ IN UINTN FdSize,
+ IN EFI_GUID *FileName,
+ IN EFI_FV_FILETYPE Type,
+ OUT VOID **OutFfsBuffer,
+ OUT UINTN *OutFfsBufferSize
)
{
- UINTN FvSize;
- EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
- EFI_FFS_FILE_HEADER *FfsHeader;
- UINT32 FfsSize;
- UINTN TestLength;
- BOOLEAN FvFound;
+ UINTN FvSize;
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINT32 FfsSize;
+ UINTN TestLength;
+ BOOLEAN FvFound;
DEBUG ((DEBUG_INFO, "GetFfsByName - FV: 0x%08x - 0x%08x\n", (UINTN)FdStart, (UINTN)FdSize));
- FvFound = FALSE;
+ FvFound = FALSE;
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FdStart;
while ((UINTN)FvHeader < (UINTN)FdStart + FdSize - 1) {
FvSize = (UINTN)FdStart + FdSize - (UINTN)FvHeader;
@@ -182,12 +182,14 @@ GetFfsByName (
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)((UINTN)FvHeader + SIZE_4KB);
continue;
}
- DEBUG((DEBUG_INFO, "checking FV....0x%08x - 0x%x\n", FvHeader, FvHeader->FvLength));
+
+ DEBUG ((DEBUG_INFO, "checking FV....0x%08x - 0x%x\n", FvHeader, FvHeader->FvLength));
FvFound = TRUE;
if (FvHeader->FvLength > FvSize) {
- DEBUG((DEBUG_ERROR, "GetFfsByName - FvSize: 0x%08x, MaxSize - 0x%08x\n", (UINTN)FvHeader->FvLength, (UINTN)FvSize));
+ DEBUG ((DEBUG_ERROR, "GetFfsByName - FvSize: 0x%08x, MaxSize - 0x%08x\n", (UINTN)FvHeader->FvLength, (UINTN)FvSize));
return FALSE;
}
+
FvSize = (UINTN)FvHeader->FvLength;
//
@@ -195,44 +197,47 @@ GetFfsByName (
//
if (FvHeader->ExtHeaderOffset != 0) {
FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)FvHeader + FvHeader->ExtHeaderOffset);
- FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvExtHeader + FvExtHeader->ExtHeaderSize);
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvExtHeader + FvExtHeader->ExtHeaderSize);
} else {
FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvHeader + FvHeader->HeaderLength);
}
- FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FvHeader + ALIGN_VALUE((UINTN)FfsHeader - (UINTN)FvHeader, 8));
+
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FvHeader + ALIGN_VALUE ((UINTN)FfsHeader - (UINTN)FvHeader, 8));
while ((UINTN)FfsHeader < (UINTN)FvHeader + FvSize - 1) {
- DEBUG((DEBUG_INFO, "GetFfsByName - FFS: 0x%08x\n", FfsHeader));
+ DEBUG ((DEBUG_INFO, "GetFfsByName - FFS: 0x%08x\n", FfsHeader));
TestLength = (UINTN)((UINTN)FvHeader + FvSize - (UINTN)FfsHeader);
- if (TestLength > sizeof(EFI_FFS_FILE_HEADER)) {
- TestLength = sizeof(EFI_FFS_FILE_HEADER);
+ if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
+ TestLength = sizeof (EFI_FFS_FILE_HEADER);
}
- if (IsBufferErased(1, FfsHeader, TestLength)) {
+
+ if (IsBufferErased (1, FfsHeader, TestLength)) {
break;
}
- if (IS_FFS_FILE2(FfsHeader)) {
- FfsSize = FFS_FILE2_SIZE(FfsHeader);
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ FfsSize = FFS_FILE2_SIZE (FfsHeader);
} else {
- FfsSize = FFS_FILE_SIZE(FfsHeader);
+ FfsSize = FFS_FILE_SIZE (FfsHeader);
}
- if (CompareGuid(FileName, &FfsHeader->Name) &&
- ((Type == EFI_FV_FILETYPE_ALL) || (FfsHeader->Type == Type))) {
- *OutFfsBuffer = FfsHeader;
+ if (CompareGuid (FileName, &FfsHeader->Name) &&
+ ((Type == EFI_FV_FILETYPE_ALL) || (FfsHeader->Type == Type)))
+ {
+ *OutFfsBuffer = FfsHeader;
*OutFfsBufferSize = FfsSize;
return TRUE;
} else {
//
// Any other type is not allowed
//
- DEBUG((DEBUG_INFO, "GetFfsByName - other FFS type 0x%x, name %g\n", FfsHeader->Type, &FfsHeader->Name));
+ DEBUG ((DEBUG_INFO, "GetFfsByName - other FFS type 0x%x, name %g\n", FfsHeader->Type, &FfsHeader->Name));
}
//
// Next File
//
- FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FfsHeader + ALIGN_VALUE(FfsSize, 8));
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FfsHeader + ALIGN_VALUE (FfsSize, 8));
}
//
@@ -242,8 +247,9 @@ GetFfsByName (
}
if (!FvFound) {
- DEBUG((DEBUG_ERROR, "GetFfsByName - NO FV Found\n"));
+ DEBUG ((DEBUG_ERROR, "GetFfsByName - NO FV Found\n"));
}
+
return FALSE;
}
@@ -261,29 +267,30 @@ GetFfsByName (
BOOLEAN
EFIAPI
ExtractDriverFvImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **DriverFvImage,
- OUT UINTN *DriverFvImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **DriverFvImage,
+ OUT UINTN *DriverFvImageSize
)
{
- BOOLEAN Result;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 FileHeaderSize;
- *DriverFvImage = NULL;
+ *DriverFvImage = NULL;
*DriverFvImageSize = 0;
- Result = GetFfsByName(AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleDriverFvFileGuid, EFI_FV_FILETYPE_RAW, DriverFvImage, DriverFvImageSize);
+ Result = GetFfsByName (AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleDriverFvFileGuid, EFI_FV_FILETYPE_RAW, DriverFvImage, DriverFvImageSize);
if (!Result) {
return FALSE;
}
- if (IS_FFS_FILE2(*DriverFvImage)) {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
+ if (IS_FFS_FILE2 (*DriverFvImage)) {
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
- *DriverFvImage = (UINT8 *)*DriverFvImage + FileHeaderSize;
+
+ *DriverFvImage = (UINT8 *)*DriverFvImage + FileHeaderSize;
*DriverFvImageSize = *DriverFvImageSize - FileHeaderSize;
return Result;
@@ -303,29 +310,30 @@ ExtractDriverFvImage (
BOOLEAN
EFIAPI
ExtractConfigImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **ConfigImage,
- OUT UINTN *ConfigImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **ConfigImage,
+ OUT UINTN *ConfigImageSize
)
{
- BOOLEAN Result;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 FileHeaderSize;
- *ConfigImage = NULL;
+ *ConfigImage = NULL;
*ConfigImageSize = 0;
- Result = GetFfsByName(AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleConfigFileGuid, EFI_FV_FILETYPE_RAW, ConfigImage, ConfigImageSize);
+ Result = GetFfsByName (AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleConfigFileGuid, EFI_FV_FILETYPE_RAW, ConfigImage, ConfigImageSize);
if (!Result) {
return FALSE;
}
- if (IS_FFS_FILE2(*ConfigImage)) {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
+ if (IS_FFS_FILE2 (*ConfigImage)) {
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
- *ConfigImage = (UINT8 *)*ConfigImage + FileHeaderSize;
+
+ *ConfigImage = (UINT8 *)*ConfigImage + FileHeaderSize;
*ConfigImageSize = *ConfigImageSize - FileHeaderSize;
return Result;
@@ -348,20 +356,20 @@ ExtractConfigImage (
BOOLEAN
EFIAPI
ExtractAuthenticatedImage (
- IN VOID *Image,
- IN UINTN ImageSize,
- OUT UINT32 *LastAttemptStatus,
- OUT VOID **AuthenticatedImage,
- OUT UINTN *AuthenticatedImageSize
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ OUT UINT32 *LastAttemptStatus,
+ OUT VOID **AuthenticatedImage,
+ OUT UINTN *AuthenticatedImageSize
)
{
- EFI_FIRMWARE_IMAGE_AUTHENTICATION *ImageAuth;
- EFI_STATUS Status;
- GUID *CertType;
- VOID *PublicKeyData;
- UINTN PublicKeyDataLength;
+ EFI_FIRMWARE_IMAGE_AUTHENTICATION *ImageAuth;
+ EFI_STATUS Status;
+ GUID *CertType;
+ VOID *PublicKeyData;
+ UINTN PublicKeyDataLength;
- DEBUG((DEBUG_INFO, "ExtractAuthenticatedImage - Image: 0x%08x - 0x%08x\n", (UINTN)Image, (UINTN)ImageSize));
+ DEBUG ((DEBUG_INFO, "ExtractAuthenticatedImage - Image: 0x%08x - 0x%08x\n", (UINTN)Image, (UINTN)ImageSize));
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
if ((Image == NULL) || (ImageSize == 0)) {
@@ -369,82 +377,91 @@ ExtractAuthenticatedImage (
}
ImageAuth = (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image;
- if (ImageSize < sizeof(EFI_FIRMWARE_IMAGE_AUTHENTICATION)) {
- DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
+ if (ImageSize < sizeof (EFI_FIRMWARE_IMAGE_AUTHENTICATION)) {
+ DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
return FALSE;
}
- if (ImageAuth->AuthInfo.Hdr.dwLength <= OFFSET_OF(WIN_CERTIFICATE_UEFI_GUID, CertData)) {
- DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too small\n"));
+
+ if (ImageAuth->AuthInfo.Hdr.dwLength <= OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)) {
+ DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too small\n"));
return FALSE;
}
- if ((UINTN) ImageAuth->AuthInfo.Hdr.dwLength > MAX_UINTN - sizeof(UINT64)) {
- DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too big\n"));
+
+ if ((UINTN)ImageAuth->AuthInfo.Hdr.dwLength > MAX_UINTN - sizeof (UINT64)) {
+ DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too big\n"));
return FALSE;
}
- if (ImageSize <= sizeof(ImageAuth->MonotonicCount) + ImageAuth->AuthInfo.Hdr.dwLength) {
- DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
+
+ if (ImageSize <= sizeof (ImageAuth->MonotonicCount) + ImageAuth->AuthInfo.Hdr.dwLength) {
+ DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
return FALSE;
}
+
if (ImageAuth->AuthInfo.Hdr.wRevision != 0x0200) {
- DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - wRevision: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wRevision, (UINTN)0x0200));
+ DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - wRevision: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wRevision, (UINTN)0x0200));
return FALSE;
}
+
if (ImageAuth->AuthInfo.Hdr.wCertificateType != WIN_CERT_TYPE_EFI_GUID) {
- DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - wCertificateType: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wCertificateType, (UINTN)WIN_CERT_TYPE_EFI_GUID));
+ DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - wCertificateType: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wCertificateType, (UINTN)WIN_CERT_TYPE_EFI_GUID));
return FALSE;
}
CertType = &ImageAuth->AuthInfo.CertType;
- DEBUG((DEBUG_INFO, "ExtractAuthenticatedImage - CertType: %g\n", CertType));
-
- if (CompareGuid(&gEfiCertPkcs7Guid, CertType)) {
- PublicKeyData = PcdGetPtr(PcdPkcs7CertBuffer);
- PublicKeyDataLength = PcdGetSize(PcdPkcs7CertBuffer);
- } else if (CompareGuid(&gEfiCertTypeRsa2048Sha256Guid, CertType)) {
- PublicKeyData = PcdGetPtr(PcdRsa2048Sha256PublicKeyBuffer);
- PublicKeyDataLength = PcdGetSize(PcdRsa2048Sha256PublicKeyBuffer);
+ DEBUG ((DEBUG_INFO, "ExtractAuthenticatedImage - CertType: %g\n", CertType));
+
+ if (CompareGuid (&gEfiCertPkcs7Guid, CertType)) {
+ PublicKeyData = PcdGetPtr (PcdPkcs7CertBuffer);
+ PublicKeyDataLength = PcdGetSize (PcdPkcs7CertBuffer);
+ } else if (CompareGuid (&gEfiCertTypeRsa2048Sha256Guid, CertType)) {
+ PublicKeyData = PcdGetPtr (PcdRsa2048Sha256PublicKeyBuffer);
+ PublicKeyDataLength = PcdGetSize (PcdRsa2048Sha256PublicKeyBuffer);
} else {
return FALSE;
}
+
ASSERT (PublicKeyData != NULL);
ASSERT (PublicKeyDataLength != 0);
- Status = AuthenticateFmpImage(
+ Status = AuthenticateFmpImage (
ImageAuth,
ImageSize,
PublicKeyData,
PublicKeyDataLength
);
switch (Status) {
- case RETURN_SUCCESS:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
- break;
- case RETURN_SECURITY_VIOLATION:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR;
- break;
- case RETURN_INVALID_PARAMETER:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
- break;
- case RETURN_UNSUPPORTED:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
- break;
- case RETURN_OUT_OF_RESOURCES:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES;
- break;
- default:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
- break;
- }
- if (EFI_ERROR(Status)) {
+ case RETURN_SUCCESS:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+ break;
+ case RETURN_SECURITY_VIOLATION:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR;
+ break;
+ case RETURN_INVALID_PARAMETER:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
+ break;
+ case RETURN_UNSUPPORTED:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
+ break;
+ case RETURN_OUT_OF_RESOURCES:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES;
+ break;
+ default:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+ break;
+ }
+
+ if (EFI_ERROR (Status)) {
return FALSE;
}
if (AuthenticatedImage != NULL) {
- *AuthenticatedImage = (UINT8 *)ImageAuth + ImageAuth->AuthInfo.Hdr.dwLength + sizeof(ImageAuth->MonotonicCount);
+ *AuthenticatedImage = (UINT8 *)ImageAuth + ImageAuth->AuthInfo.Hdr.dwLength + sizeof (ImageAuth->MonotonicCount);
}
+
if (AuthenticatedImageSize != NULL) {
- *AuthenticatedImageSize = ImageSize - ImageAuth->AuthInfo.Hdr.dwLength - sizeof(ImageAuth->MonotonicCount);
+ *AuthenticatedImageSize = ImageSize - ImageAuth->AuthInfo.Hdr.dwLength - sizeof (ImageAuth->MonotonicCount);
}
+
return TRUE;
}
@@ -462,41 +479,45 @@ ExtractAuthenticatedImage (
BOOLEAN
EFIAPI
ExtractSystemFirmwareImageFmpInfo (
- IN VOID *SystemFirmwareImage,
- IN UINTN SystemFirmwareImageSize,
- OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo,
- OUT UINTN *ImageFmpInfoSize
+ IN VOID *SystemFirmwareImage,
+ IN UINTN SystemFirmwareImageSize,
+ OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo,
+ OUT UINTN *ImageFmpInfoSize
)
{
- BOOLEAN Result;
- UINT32 SectionHeaderSize;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 SectionHeaderSize;
+ UINT32 FileHeaderSize;
- *ImageFmpInfo = NULL;
+ *ImageFmpInfo = NULL;
*ImageFmpInfoSize = 0;
- Result = GetFfsByName(SystemFirmwareImage, SystemFirmwareImageSize, &gEdkiiSystemFirmwareImageDescriptorFileGuid, EFI_FV_FILETYPE_ALL, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
+ Result = GetFfsByName (SystemFirmwareImage, SystemFirmwareImageSize, &gEdkiiSystemFirmwareImageDescriptorFileGuid, EFI_FV_FILETYPE_ALL, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
if (!Result) {
return FALSE;
}
+
if (IS_FFS_FILE2 (*ImageFmpInfo)) {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
- *ImageFmpInfo = (VOID *)((UINT8 *)*ImageFmpInfo + FileHeaderSize);
+
+ *ImageFmpInfo = (VOID *)((UINT8 *)*ImageFmpInfo + FileHeaderSize);
*ImageFmpInfoSize = *ImageFmpInfoSize - FileHeaderSize;
- Result = GetSectionByType(*ImageFmpInfo, (UINT32)*ImageFmpInfoSize, EFI_SECTION_RAW, 0, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
+ Result = GetSectionByType (*ImageFmpInfo, (UINT32)*ImageFmpInfoSize, EFI_SECTION_RAW, 0, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
if (!Result) {
return FALSE;
}
- if (IS_SECTION2(*ImageFmpInfo)) {
- SectionHeaderSize = sizeof(EFI_RAW_SECTION2);
+
+ if (IS_SECTION2 (*ImageFmpInfo)) {
+ SectionHeaderSize = sizeof (EFI_RAW_SECTION2);
} else {
- SectionHeaderSize = sizeof(EFI_RAW_SECTION);
+ SectionHeaderSize = sizeof (EFI_RAW_SECTION);
}
- *ImageFmpInfo = (VOID *)((UINT8 *)*ImageFmpInfo + SectionHeaderSize);
+
+ *ImageFmpInfo = (VOID *)((UINT8 *)*ImageFmpInfo + SectionHeaderSize);
*ImageFmpInfoSize = *ImageFmpInfoSize - SectionHeaderSize;
return TRUE;
@@ -516,32 +537,34 @@ ExtractSystemFirmwareImageFmpInfo (
BOOLEAN
EFIAPI
ExtractSystemFirmwareImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **SystemFirmwareImage,
- OUT UINTN *SystemFirmwareImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **SystemFirmwareImage,
+ OUT UINTN *SystemFirmwareImageSize
)
{
- BOOLEAN Result;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 FileHeaderSize;
- *SystemFirmwareImage = NULL;
+ *SystemFirmwareImage = NULL;
*SystemFirmwareImageSize = 0;
- Result = GetFfsByName(AuthenticatedImage, AuthenticatedImageSize, &mEdkiiSystemFirmwareFileGuid, EFI_FV_FILETYPE_RAW, SystemFirmwareImage, SystemFirmwareImageSize);
+ Result = GetFfsByName (AuthenticatedImage, AuthenticatedImageSize, &mEdkiiSystemFirmwareFileGuid, EFI_FV_FILETYPE_RAW, SystemFirmwareImage, SystemFirmwareImageSize);
if (!Result) {
// no nested FV, just return all data.
- *SystemFirmwareImage = AuthenticatedImage;
+ *SystemFirmwareImage = AuthenticatedImage;
*SystemFirmwareImageSize = AuthenticatedImageSize;
return TRUE;
}
+
if (IS_FFS_FILE2 (*SystemFirmwareImage)) {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
- FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
+ FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
- *SystemFirmwareImage = (UINT8 *)*SystemFirmwareImage + FileHeaderSize;
+
+ *SystemFirmwareImage = (UINT8 *)*SystemFirmwareImage + FileHeaderSize;
*SystemFirmwareImageSize = *SystemFirmwareImageSize - FileHeaderSize;
return Result;
@@ -568,22 +591,22 @@ ExtractSystemFirmwareImage (
EFI_STATUS
EFIAPI
CapsuleAuthenticateSystemFirmware (
- IN VOID *Image,
- IN UINTN ImageSize,
- IN BOOLEAN ForceVersionMatch,
- OUT UINT32 *LastAttemptVersion,
- OUT UINT32 *LastAttemptStatus,
- OUT VOID **AuthenticatedImage,
- OUT UINTN *AuthenticatedImageSize
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ IN BOOLEAN ForceVersionMatch,
+ OUT UINT32 *LastAttemptVersion,
+ OUT UINT32 *LastAttemptStatus,
+ OUT VOID **AuthenticatedImage,
+ OUT UINTN *AuthenticatedImageSize
)
{
- BOOLEAN Result;
- EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageFmpInfo;
- UINTN ImageFmpInfoSize;
- EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageFmpInfo;
- UINTN CurrentImageFmpInfoSize;
- VOID *SystemFirmwareImage;
- UINTN SystemFirmwareImageSize;
+ BOOLEAN Result;
+ EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageFmpInfo;
+ UINTN ImageFmpInfoSize;
+ EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageFmpInfo;
+ UINTN CurrentImageFmpInfoSize;
+ VOID *SystemFirmwareImage;
+ UINTN SystemFirmwareImageSize;
*LastAttemptVersion = 0;
@@ -592,55 +615,56 @@ CapsuleAuthenticateSystemFirmware (
// Do not touch FMP protocol and its private structure.
//
if (mImageFmpInfo == NULL) {
- DEBUG((DEBUG_INFO, "ImageFmpInfo is not set\n"));
+ DEBUG ((DEBUG_INFO, "ImageFmpInfo is not set\n"));
return EFI_SECURITY_VIOLATION;
}
- Result = ExtractAuthenticatedImage((VOID *)Image, ImageSize, LastAttemptStatus, AuthenticatedImage, AuthenticatedImageSize);
+ Result = ExtractAuthenticatedImage ((VOID *)Image, ImageSize, LastAttemptStatus, AuthenticatedImage, AuthenticatedImageSize);
if (!Result) {
- DEBUG((DEBUG_INFO, "ExtractAuthenticatedImage - fail\n"));
+ DEBUG ((DEBUG_INFO, "ExtractAuthenticatedImage - fail\n"));
return EFI_SECURITY_VIOLATION;
}
- DEBUG((DEBUG_INFO, "AuthenticatedImage - 0x%x - 0x%x\n", *AuthenticatedImage, *AuthenticatedImageSize));
+ DEBUG ((DEBUG_INFO, "AuthenticatedImage - 0x%x - 0x%x\n", *AuthenticatedImage, *AuthenticatedImageSize));
- Result = ExtractSystemFirmwareImage(*AuthenticatedImage, *AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
+ Result = ExtractSystemFirmwareImage (*AuthenticatedImage, *AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
if (!Result) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
- DEBUG((DEBUG_INFO, "ExtractSystemFirmwareImage - fail\n"));
+ DEBUG ((DEBUG_INFO, "ExtractSystemFirmwareImage - fail\n"));
return EFI_SECURITY_VIOLATION;
}
- DEBUG((DEBUG_INFO, "SystemFirmwareImage - 0x%x - 0x%x\n", SystemFirmwareImage, SystemFirmwareImageSize));
- Result = ExtractSystemFirmwareImageFmpInfo(SystemFirmwareImage, SystemFirmwareImageSize, &ImageFmpInfo, &ImageFmpInfoSize);
+ DEBUG ((DEBUG_INFO, "SystemFirmwareImage - 0x%x - 0x%x\n", SystemFirmwareImage, SystemFirmwareImageSize));
+
+ Result = ExtractSystemFirmwareImageFmpInfo (SystemFirmwareImage, SystemFirmwareImageSize, &ImageFmpInfo, &ImageFmpInfoSize);
if (!Result) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
- DEBUG((DEBUG_INFO, "ExtractSystemFirmwareImageFmpInfo - fail\n"));
+ DEBUG ((DEBUG_INFO, "ExtractSystemFirmwareImageFmpInfo - fail\n"));
return EFI_SECURITY_VIOLATION;
}
*LastAttemptVersion = ImageFmpInfo->Version;
- DEBUG((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", ImageFmpInfo, ImageFmpInfoSize));
- DEBUG((DEBUG_INFO, "NewImage Version - 0x%x\n", ImageFmpInfo->Version));
- DEBUG((DEBUG_INFO, "NewImage LowestSupportedImageVersion - 0x%x\n", ImageFmpInfo->LowestSupportedImageVersion));
+ DEBUG ((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", ImageFmpInfo, ImageFmpInfoSize));
+ DEBUG ((DEBUG_INFO, "NewImage Version - 0x%x\n", ImageFmpInfo->Version));
+ DEBUG ((DEBUG_INFO, "NewImage LowestSupportedImageVersion - 0x%x\n", ImageFmpInfo->LowestSupportedImageVersion));
- CurrentImageFmpInfo = mImageFmpInfo;
+ CurrentImageFmpInfo = mImageFmpInfo;
CurrentImageFmpInfoSize = mImageFmpInfoSize;
- DEBUG((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", CurrentImageFmpInfo, CurrentImageFmpInfoSize));
- DEBUG((DEBUG_INFO, "Current Version - 0x%x\n", CurrentImageFmpInfo->Version));
- DEBUG((DEBUG_INFO, "Current LowestSupportedImageVersion - 0x%x\n", CurrentImageFmpInfo->LowestSupportedImageVersion));
+ DEBUG ((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", CurrentImageFmpInfo, CurrentImageFmpInfoSize));
+ DEBUG ((DEBUG_INFO, "Current Version - 0x%x\n", CurrentImageFmpInfo->Version));
+ DEBUG ((DEBUG_INFO, "Current LowestSupportedImageVersion - 0x%x\n", CurrentImageFmpInfo->LowestSupportedImageVersion));
if (ForceVersionMatch) {
if (CurrentImageFmpInfo->Version != ImageFmpInfo->Version) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION;
- DEBUG((DEBUG_INFO, "ForceVersionMatch check - fail\n"));
+ DEBUG ((DEBUG_INFO, "ForceVersionMatch check - fail\n"));
return EFI_SECURITY_VIOLATION;
}
} else {
if (ImageFmpInfo->Version < CurrentImageFmpInfo->LowestSupportedImageVersion) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION;
- DEBUG((DEBUG_INFO, "LowestSupportedImageVersion check - fail\n"));
+ DEBUG ((DEBUG_INFO, "LowestSupportedImageVersion check - fail\n"));
return EFI_SECURITY_VIOLATION;
}
}
@@ -661,17 +685,18 @@ CapsuleAuthenticateSystemFirmware (
VOID
EFIAPI
EdkiiSystemCapsuleLibPcdCallBack (
- IN CONST GUID *CallBackGuid OPTIONAL,
- IN UINTN CallBackToken,
- IN OUT VOID *TokenData,
- IN UINTN TokenDataSize
+ IN CONST GUID *CallBackGuid OPTIONAL,
+ IN UINTN CallBackToken,
+ IN OUT VOID *TokenData,
+ IN UINTN TokenDataSize
)
{
if (CompareGuid (CallBackGuid, &gEfiSignedCapsulePkgTokenSpaceGuid) &&
- CallBackToken == PcdToken (PcdEdkiiSystemFirmwareImageDescriptor)) {
+ (CallBackToken == PcdToken (PcdEdkiiSystemFirmwareImageDescriptor)))
+ {
mImageFmpInfoSize = TokenDataSize;
- mImageFmpInfo = AllocateCopyPool (mImageFmpInfoSize, TokenData);
- ASSERT(mImageFmpInfo != NULL);
+ mImageFmpInfo = AllocateCopyPool (mImageFmpInfoSize, TokenData);
+ ASSERT (mImageFmpInfo != NULL);
//
// Cancel Callback after get the real set value
//
@@ -683,8 +708,9 @@ EdkiiSystemCapsuleLibPcdCallBack (
}
if (CompareGuid (CallBackGuid, &gEfiSignedCapsulePkgTokenSpaceGuid) &&
- CallBackToken == PcdToken (PcdEdkiiSystemFirmwareFileGuid)) {
- CopyGuid(&mEdkiiSystemFirmwareFileGuid, TokenData);
+ (CallBackToken == PcdToken (PcdEdkiiSystemFirmwareFileGuid)))
+ {
+ CopyGuid (&mEdkiiSystemFirmwareFileGuid, TokenData);
//
// Cancel Callback after get the real set value
//
@@ -707,13 +733,14 @@ EdkiiSystemCapsuleLibConstructor (
VOID
)
{
- mImageFmpInfoSize = PcdGetSize(PcdEdkiiSystemFirmwareImageDescriptor);
- mImageFmpInfo = PcdGetPtr(PcdEdkiiSystemFirmwareImageDescriptor);
+ mImageFmpInfoSize = PcdGetSize (PcdEdkiiSystemFirmwareImageDescriptor);
+ mImageFmpInfo = PcdGetPtr (PcdEdkiiSystemFirmwareImageDescriptor);
//
// Verify Firmware Image Descriptor first
//
- if (mImageFmpInfoSize < sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR) ||
- mImageFmpInfo->Signature != EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) {
+ if ((mImageFmpInfoSize < sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR)) ||
+ (mImageFmpInfo->Signature != EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE))
+ {
//
// SystemFirmwareImageDescriptor is not set.
// Register PCD set callback to hook PCD value set.
@@ -727,10 +754,10 @@ EdkiiSystemCapsuleLibConstructor (
);
} else {
mImageFmpInfo = AllocateCopyPool (mImageFmpInfoSize, mImageFmpInfo);
- ASSERT(mImageFmpInfo != NULL);
+ ASSERT (mImageFmpInfo != NULL);
}
- CopyGuid(&mEdkiiSystemFirmwareFileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid));
+ CopyGuid (&mEdkiiSystemFirmwareFileGuid, PcdGetPtr (PcdEdkiiSystemFirmwareFileGuid));
//
// Verify GUID value first
//
@@ -741,5 +768,6 @@ EdkiiSystemCapsuleLibConstructor (
EdkiiSystemCapsuleLibPcdCallBack
);
}
+
return EFI_SUCCESS;
}
diff --git a/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c b/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c
index bea45e0d3b..0a44131a08 100644
--- a/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c
+++ b/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c
@@ -37,30 +37,30 @@
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-#define IS_HYPHEN(a) ((a) == '-')
-#define IS_NULL(a) ((a) == '\0')
+#define IS_HYPHEN(a) ((a) == '-')
+#define IS_NULL(a) ((a) == '\0')
// This is default allocation. Reallocation will happen if it is not enough.
-#define MAX_LINE_LENGTH 512
+#define MAX_LINE_LENGTH 512
typedef struct _INI_SECTION_ITEM SECTION_ITEM;
struct _INI_SECTION_ITEM {
- CHAR8 *PtrSection;
- UINTN SecNameLen;
- CHAR8 *PtrEntry;
- CHAR8 *PtrValue;
- SECTION_ITEM *PtrNext;
+ CHAR8 *PtrSection;
+ UINTN SecNameLen;
+ CHAR8 *PtrEntry;
+ CHAR8 *PtrValue;
+ SECTION_ITEM *PtrNext;
};
typedef struct _INI_COMMENT_LINE COMMENT_LINE;
struct _INI_COMMENT_LINE {
- CHAR8 *PtrComment;
- COMMENT_LINE *PtrNext;
+ CHAR8 *PtrComment;
+ COMMENT_LINE *PtrNext;
};
typedef struct {
- SECTION_ITEM *SectionHead;
- COMMENT_LINE *CommentHead;
+ SECTION_ITEM *SectionHead;
+ COMMENT_LINE *CommentHead;
} INI_PARSING_LIB_CONTEXT;
/**
@@ -78,17 +78,20 @@ IsValidDigitalChar (
IN BOOLEAN IncludeHex
)
{
- if (DigitalChar >= '0' && DigitalChar <= '9') {
+ if ((DigitalChar >= '0') && (DigitalChar <= '9')) {
return TRUE;
}
+
if (IncludeHex) {
- if (DigitalChar >= 'a' && DigitalChar <= 'f') {
+ if ((DigitalChar >= 'a') && (DigitalChar <= 'f')) {
return TRUE;
}
- if (DigitalChar >= 'A' && DigitalChar <= 'F') {
+
+ if ((DigitalChar >= 'A') && (DigitalChar <= 'F')) {
return TRUE;
}
}
+
return FALSE;
}
@@ -105,18 +108,22 @@ IsValidNameChar (
IN CHAR8 NameChar
)
{
- if (NameChar >= 'a' && NameChar <= 'z') {
+ if ((NameChar >= 'a') && (NameChar <= 'z')) {
return TRUE;
}
- if (NameChar >= 'A' && NameChar <= 'Z') {
+
+ if ((NameChar >= 'A') && (NameChar <= 'Z')) {
return TRUE;
}
- if (NameChar >= '0' && NameChar <= '9') {
+
+ if ((NameChar >= '0') && (NameChar <= '9')) {
return TRUE;
}
+
if (NameChar == '_') {
return TRUE;
}
+
return FALSE;
}
@@ -138,11 +145,13 @@ IsValidDigital (
)
{
UINTN Index;
+
for (Index = 0; Index < Length; Index++) {
- if (!IsValidDigitalChar(Digital[Index], IncludeHex)) {
+ if (!IsValidDigitalChar (Digital[Index], IncludeHex)) {
return FALSE;
}
}
+
return TRUE;
}
@@ -161,7 +170,7 @@ IsValidDecimalString (
IN UINTN Length
)
{
- return IsValidDigital(Decimal, Length, FALSE);
+ return IsValidDigital (Decimal, Length, FALSE);
}
/**
@@ -182,13 +191,16 @@ IsValidHexString (
if (Length <= 2) {
return FALSE;
}
+
if (Hex[0] != '0') {
return FALSE;
}
- if (Hex[1] != 'x' && Hex[1] != 'X') {
+
+ if ((Hex[1] != 'x') && (Hex[1] != 'X')) {
return FALSE;
}
- return IsValidDigital(&Hex[2], Length - 2, TRUE);
+
+ return IsValidDigital (&Hex[2], Length - 2, TRUE);
}
/**
@@ -207,11 +219,13 @@ IsValidName (
)
{
UINTN Index;
+
for (Index = 0; Index < Length; Index++) {
- if (!IsValidNameChar(Name[Index])) {
+ if (!IsValidNameChar (Name[Index])) {
return FALSE;
}
}
+
return TRUE;
}
@@ -230,36 +244,46 @@ IsValidGuid (
IN UINTN Length
)
{
- if (Length != sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") - 1) {
+ if (Length != sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") - 1) {
return FALSE;
}
- if (!IS_HYPHEN(Value[8])) {
+
+ if (!IS_HYPHEN (Value[8])) {
return FALSE;
}
- if (!IS_HYPHEN(Value[13])) {
+
+ if (!IS_HYPHEN (Value[13])) {
return FALSE;
}
- if (!IS_HYPHEN(Value[18])) {
+
+ if (!IS_HYPHEN (Value[18])) {
return FALSE;
}
- if (!IS_HYPHEN(Value[23])) {
+
+ if (!IS_HYPHEN (Value[23])) {
return FALSE;
}
- if (!IsValidDigital(&Value[0], 8, TRUE)) {
+
+ if (!IsValidDigital (&Value[0], 8, TRUE)) {
return FALSE;
}
- if (!IsValidDigital(&Value[9], 4, TRUE)) {
+
+ if (!IsValidDigital (&Value[9], 4, TRUE)) {
return FALSE;
}
- if (!IsValidDigital(&Value[14], 4, TRUE)) {
+
+ if (!IsValidDigital (&Value[14], 4, TRUE)) {
return FALSE;
}
- if (!IsValidDigital(&Value[19], 4, TRUE)) {
+
+ if (!IsValidDigital (&Value[19], 4, TRUE)) {
return FALSE;
}
- if (!IsValidDigital(&Value[24], 12, TRUE)) {
+
+ if (!IsValidDigital (&Value[24], 12, TRUE)) {
return FALSE;
}
+
return TRUE;
}
@@ -278,9 +302,10 @@ IsValidValue (
IN UINTN Length
)
{
- if (IsValidName(Value, Length) || IsValidGuid(Value, Length)) {
+ if (IsValidName (Value, Length) || IsValidGuid (Value, Length)) {
return TRUE;
}
+
return FALSE;
}
@@ -294,28 +319,30 @@ DumpIniSection (
IN VOID *Context
)
{
- INI_PARSING_LIB_CONTEXT *IniContext;
- SECTION_ITEM *PtrSection;
- SECTION_ITEM *Section;
+ INI_PARSING_LIB_CONTEXT *IniContext;
+ SECTION_ITEM *PtrSection;
+ SECTION_ITEM *Section;
if (Context == NULL) {
return;
}
IniContext = Context;
- Section = IniContext->SectionHead;
+ Section = IniContext->SectionHead;
while (Section != NULL) {
PtrSection = Section;
- Section = Section->PtrNext;
+ Section = Section->PtrNext;
if (PtrSection->PtrSection != NULL) {
- DEBUG((DEBUG_VERBOSE, "Section - %a\n", PtrSection->PtrSection));
+ DEBUG ((DEBUG_VERBOSE, "Section - %a\n", PtrSection->PtrSection));
}
+
if (PtrSection->PtrEntry != NULL) {
DEBUG ((DEBUG_VERBOSE, " Entry - %a\n", PtrSection->PtrEntry));
}
+
if (PtrSection->PtrValue != NULL) {
- DEBUG((DEBUG_VERBOSE, " Value - %a\n", PtrSection->PtrValue));
+ DEBUG ((DEBUG_VERBOSE, " Value - %a\n", PtrSection->PtrValue));
}
}
}
@@ -335,26 +362,27 @@ DumpIniSection (
**/
EFI_STATUS
ProfileGetLine (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT UINT8 *LineBuffer,
- IN OUT UINTN *LineSize
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT UINT8 *LineBuffer,
+ IN OUT UINTN *LineSize
)
{
- UINTN Length;
- UINT8 *PtrBuf;
- UINTN PtrEnd;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINTN PtrEnd;
- PtrBuf = Buffer;
- PtrEnd = (UINTN)Buffer + BufferSize;
+ PtrBuf = Buffer;
+ PtrEnd = (UINTN)Buffer + BufferSize;
//
// 0x0D indicates a line break. Otherwise there is no line break
//
while ((UINTN)PtrBuf < PtrEnd) {
- if (*PtrBuf == 0x0D || *PtrBuf == 0x0A) {
+ if ((*PtrBuf == 0x0D) || (*PtrBuf == 0x0A)) {
break;
}
+
PtrBuf++;
}
@@ -363,14 +391,14 @@ ProfileGetLine (
// The buffer ends without any line break
// or it is the last character of the buffer
//
- Length = BufferSize;
+ Length = BufferSize;
} else if (*(PtrBuf + 1) == 0x0A) {
//
// Further check if a 0x0A follows. If yes, count 0xA
//
- Length = (UINTN) PtrBuf - (UINTN) Buffer + 2;
+ Length = (UINTN)PtrBuf - (UINTN)Buffer + 2;
} else {
- Length = (UINTN) PtrBuf - (UINTN) Buffer + 1;
+ Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;
}
if (Length > (*LineSize)) {
@@ -379,7 +407,7 @@ ProfileGetLine (
}
SetMem (LineBuffer, *LineSize, 0x0);
- *LineSize = Length;
+ *LineSize = Length;
CopyMem (LineBuffer, Buffer, Length);
return EFI_SUCCESS;
@@ -396,13 +424,13 @@ ProfileGetLine (
**/
VOID
ProfileTrim (
- IN OUT UINT8 *Buffer,
- IN OUT UINTN *BufferSize
+ IN OUT UINT8 *Buffer,
+ IN OUT UINTN *BufferSize
)
{
- UINTN Length;
- UINT8 *PtrBuf;
- UINT8 *PtrEnd;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINT8 *PtrEnd;
if (*BufferSize == 0) {
return;
@@ -411,36 +439,40 @@ ProfileTrim (
//
// Trim the tail first, include CR, LF, TAB, and SPACE.
//
- Length = *BufferSize;
- PtrBuf = (UINT8 *) ((UINTN) Buffer + Length - 1);
+ Length = *BufferSize;
+ PtrBuf = (UINT8 *)((UINTN)Buffer + Length - 1);
while (PtrBuf >= Buffer) {
- if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )
- && (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {
+ if ( (*PtrBuf != 0x0D) && (*PtrBuf != 0x0A)
+ && (*PtrBuf != 0x20) && (*PtrBuf != 0x09))
+ {
break;
}
- PtrBuf --;
+
+ PtrBuf--;
}
//
// all spaces, a blank line, return directly;
//
if (PtrBuf < Buffer) {
- *BufferSize = 0;
+ *BufferSize = 0;
return;
}
- Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;
- PtrEnd = PtrBuf;
- PtrBuf = Buffer;
+ Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;
+ PtrEnd = PtrBuf;
+ PtrBuf = Buffer;
//
// Now skip the heading CR, LF, TAB and SPACE
//
while (PtrBuf <= PtrEnd) {
- if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )
- && (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {
+ if ( (*PtrBuf != 0x0D) && (*PtrBuf != 0x0A)
+ && (*PtrBuf != 0x20) && (*PtrBuf != 0x09))
+ {
break;
}
+
PtrBuf++;
}
@@ -448,18 +480,18 @@ ProfileTrim (
// If no heading CR, LF, TAB or SPACE, directly return
//
if (PtrBuf == Buffer) {
- *BufferSize = Length;
+ *BufferSize = Length;
return;
}
- *BufferSize = (UINTN)PtrEnd - (UINTN)PtrBuf + 1;
+ *BufferSize = (UINTN)PtrEnd - (UINTN)PtrBuf + 1;
//
// The first Buffer..PtrBuf characters are CR, LF, TAB or SPACE.
// Now move out all these characters.
//
while (PtrBuf <= PtrEnd) {
- *Buffer = *PtrBuf;
+ *Buffer = *PtrBuf;
Buffer++;
PtrBuf++;
}
@@ -480,12 +512,12 @@ ProfileTrim (
**/
EFI_STATUS
ProfileGetComments (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT COMMENT_LINE **CommentHead
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT COMMENT_LINE **CommentHead
)
{
- COMMENT_LINE *CommentItem;
+ COMMENT_LINE *CommentItem;
CommentItem = NULL;
CommentItem = AllocatePool (sizeof (COMMENT_LINE));
@@ -493,8 +525,8 @@ ProfileGetComments (
return EFI_OUT_OF_RESOURCES;
}
- CommentItem->PtrNext = *CommentHead;
- *CommentHead = CommentItem;
+ CommentItem->PtrNext = *CommentHead;
+ *CommentHead = CommentItem;
//
// Add a trailing '\0'
@@ -504,6 +536,7 @@ ProfileGetComments (
FreePool (CommentItem);
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (CommentItem->PtrComment, Buffer, BufferSize);
*(CommentItem->PtrComment + BufferSize) = '\0';
@@ -523,34 +556,37 @@ ProfileGetComments (
**/
EFI_STATUS
ProfileGetSection (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT SECTION_ITEM **SectionHead
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT SECTION_ITEM **SectionHead
)
{
- SECTION_ITEM *SectionItem;
- UINTN Length;
- UINT8 *PtrBuf;
- UINT8 *PtrEnd;
+ SECTION_ITEM *SectionItem;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINT8 *PtrEnd;
- ASSERT(BufferSize >= 1);
+ ASSERT (BufferSize >= 1);
//
// The first character of Buffer is '[', now we want for ']'
//
- PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);
- PtrBuf = (UINT8 *)((UINTN)Buffer + 1);
+ PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);
+ PtrBuf = (UINT8 *)((UINTN)Buffer + 1);
while (PtrBuf <= PtrEnd) {
if (*PtrBuf == ']') {
break;
}
- PtrBuf ++;
+
+ PtrBuf++;
}
+
if (PtrBuf > PtrEnd) {
//
// Not found. Invalid line
//
return EFI_NOT_FOUND;
}
+
if (PtrBuf <= Buffer + 1) {
// Empty name
return EFI_NOT_FOUND;
@@ -559,11 +595,11 @@ ProfileGetSection (
//
// excluding the heading '[' and tailing ']'
//
- Length = PtrBuf - Buffer - 1;
+ Length = PtrBuf - Buffer - 1;
ProfileTrim (
Buffer + 1,
&Length
- );
+ );
//
// Invalid line if the section name is null
@@ -572,7 +608,7 @@ ProfileGetSection (
return EFI_NOT_FOUND;
}
- if (!IsValidName((CHAR8 *)Buffer + 1, Length)) {
+ if (!IsValidName ((CHAR8 *)Buffer + 1, Length)) {
return EFI_INVALID_PARAMETER;
}
@@ -620,21 +656,21 @@ ProfileGetSection (
**/
EFI_STATUS
ProfileGetEntry (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT SECTION_ITEM **SectionHead
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT SECTION_ITEM **SectionHead
)
{
- EFI_STATUS Status;
- SECTION_ITEM *SectionItem;
- SECTION_ITEM *PtrSection;
- UINTN Length;
- UINT8 *PtrBuf;
- UINT8 *PtrEnd;
+ EFI_STATUS Status;
+ SECTION_ITEM *SectionItem;
+ SECTION_ITEM *PtrSection;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINT8 *PtrEnd;
- Status = EFI_SUCCESS;
- PtrBuf = Buffer;
- PtrEnd = (UINT8 *) ((UINTN)Buffer + BufferSize - 1);
+ Status = EFI_SUCCESS;
+ PtrBuf = Buffer;
+ PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);
//
// First search for '='
@@ -643,14 +679,17 @@ ProfileGetEntry (
if (*PtrBuf == '=') {
break;
}
+
PtrBuf++;
}
+
if (PtrBuf > PtrEnd) {
//
// Not found. Invalid line
//
return EFI_NOT_FOUND;
}
+
if (PtrBuf <= Buffer) {
// Empty name
return EFI_NOT_FOUND;
@@ -659,11 +698,11 @@ ProfileGetEntry (
//
// excluding the tailing '='
//
- Length = PtrBuf - Buffer;
+ Length = PtrBuf - Buffer;
ProfileTrim (
Buffer,
&Length
- );
+ );
//
// Invalid line if the entry name is null
@@ -672,7 +711,7 @@ ProfileGetEntry (
return EFI_NOT_FOUND;
}
- if (!IsValidName((CHAR8 *)Buffer, Length)) {
+ if (!IsValidName ((CHAR8 *)Buffer, Length)) {
return EFI_INVALID_PARAMETER;
}
@@ -682,7 +721,8 @@ ProfileGetEntry (
if (*SectionHead == NULL) {
return Status;
}
- PtrSection = *SectionHead;
+
+ PtrSection = *SectionHead;
SectionItem = AllocatePool (sizeof (SECTION_ITEM));
if (SectionItem == NULL) {
@@ -703,6 +743,7 @@ ProfileGetEntry (
if (SectionItem->PtrSection == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (SectionItem->PtrSection, PtrSection->PtrSection, PtrSection->SecNameLen + 1);
//
@@ -710,47 +751,51 @@ ProfileGetEntry (
//
SectionItem->PtrEntry = AllocatePool (Length + 1);
if (SectionItem->PtrEntry == NULL) {
- FreePool(SectionItem->PtrSection);
+ FreePool (SectionItem->PtrSection);
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (SectionItem->PtrEntry, Buffer, Length);
*(SectionItem->PtrEntry + Length) = '\0';
//
// Next search for '#' or ';'
//
- PtrBuf = PtrBuf + 1;
- Buffer = PtrBuf;
+ PtrBuf = PtrBuf + 1;
+ Buffer = PtrBuf;
while (PtrBuf <= PtrEnd) {
- if (*PtrBuf == '#' || *PtrBuf == ';') {
+ if ((*PtrBuf == '#') || (*PtrBuf == ';')) {
break;
}
+
PtrBuf++;
}
+
if (PtrBuf <= Buffer) {
// Empty name
- FreePool(SectionItem->PtrEntry);
- FreePool(SectionItem->PtrSection);
+ FreePool (SectionItem->PtrEntry);
+ FreePool (SectionItem->PtrSection);
return EFI_NOT_FOUND;
}
- Length = PtrBuf - Buffer;
+
+ Length = PtrBuf - Buffer;
ProfileTrim (
Buffer,
&Length
- );
+ );
//
// Invalid line if the entry value is null
//
if (Length == 0) {
- FreePool(SectionItem->PtrEntry);
- FreePool(SectionItem->PtrSection);
+ FreePool (SectionItem->PtrEntry);
+ FreePool (SectionItem->PtrSection);
return EFI_NOT_FOUND;
}
- if (!IsValidValue((CHAR8 *)Buffer, Length)) {
- FreePool(SectionItem->PtrEntry);
- FreePool(SectionItem->PtrSection);
+ if (!IsValidValue ((CHAR8 *)Buffer, Length)) {
+ FreePool (SectionItem->PtrEntry);
+ FreePool (SectionItem->PtrSection);
return EFI_INVALID_PARAMETER;
}
@@ -759,10 +804,11 @@ ProfileGetEntry (
//
SectionItem->PtrValue = AllocatePool (Length + 1);
if (SectionItem->PtrValue == NULL) {
- FreePool(SectionItem->PtrEntry);
- FreePool(SectionItem->PtrSection);
+ FreePool (SectionItem->PtrEntry);
+ FreePool (SectionItem->PtrSection);
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (SectionItem->PtrValue, Buffer, Length);
*(SectionItem->PtrValue + Length) = '\0';
@@ -778,34 +824,38 @@ ProfileGetEntry (
**/
VOID
FreeAllList (
- IN SECTION_ITEM *Section,
- IN COMMENT_LINE *Comment
+ IN SECTION_ITEM *Section,
+ IN COMMENT_LINE *Comment
)
{
- SECTION_ITEM *PtrSection;
- COMMENT_LINE *PtrComment;
+ SECTION_ITEM *PtrSection;
+ COMMENT_LINE *PtrComment;
while (Section != NULL) {
- PtrSection = Section;
- Section = Section->PtrNext;
+ PtrSection = Section;
+ Section = Section->PtrNext;
if (PtrSection->PtrEntry != NULL) {
FreePool (PtrSection->PtrEntry);
}
+
if (PtrSection->PtrSection != NULL) {
FreePool (PtrSection->PtrSection);
}
+
if (PtrSection->PtrValue != NULL) {
FreePool (PtrSection->PtrValue);
}
+
FreePool (PtrSection);
}
while (Comment != NULL) {
- PtrComment = Comment;
- Comment = Comment->PtrNext;
+ PtrComment = Comment;
+ Comment = Comment->PtrNext;
if (PtrComment->PtrComment != NULL) {
FreePool (PtrComment->PtrComment);
}
+
FreePool (PtrComment);
}
@@ -826,30 +876,31 @@ FreeAllList (
**/
EFI_STATUS
UpdateGetProfileString (
- IN SECTION_ITEM *Section,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT CHAR8 **EntryValue
+ IN SECTION_ITEM *Section,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT CHAR8 **EntryValue
)
{
- *EntryValue = NULL;
+ *EntryValue = NULL;
while (Section != NULL) {
- if (AsciiStrCmp ((CONST CHAR8 *) Section->PtrSection, (CONST CHAR8 *) SectionName) == 0) {
+ if (AsciiStrCmp ((CONST CHAR8 *)Section->PtrSection, (CONST CHAR8 *)SectionName) == 0) {
if (Section->PtrEntry != NULL) {
- if (AsciiStrCmp ((CONST CHAR8 *) Section->PtrEntry, (CONST CHAR8 *) EntryName) == 0) {
+ if (AsciiStrCmp ((CONST CHAR8 *)Section->PtrEntry, (CONST CHAR8 *)EntryName) == 0) {
break;
}
}
}
- Section = Section->PtrNext;
+
+ Section = Section->PtrNext;
}
if (Section == NULL) {
return EFI_NOT_FOUND;
}
- *EntryValue = Section->PtrValue;
+ *EntryValue = Section->PtrValue;
return EFI_SUCCESS;
}
@@ -870,27 +921,27 @@ UpdateGetProfileString (
**/
EFI_STATUS
PreProcessDataFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize,
- IN OUT SECTION_ITEM **SectionHead,
- IN OUT COMMENT_LINE **CommentHead
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize,
+ IN OUT SECTION_ITEM **SectionHead,
+ IN OUT COMMENT_LINE **CommentHead
)
{
- EFI_STATUS Status;
- CHAR8 *Source;
- CHAR8 *CurrentPtr;
- CHAR8 *BufferEnd;
- CHAR8 *PtrLine;
- UINTN LineLength;
- UINTN SourceLength;
- UINTN MaxLineLength;
-
- *SectionHead = NULL;
- *CommentHead = NULL;
- BufferEnd = (CHAR8 *) ( (UINTN) DataBuffer + BufferSize);
- CurrentPtr = (CHAR8 *) DataBuffer;
- MaxLineLength = MAX_LINE_LENGTH;
- Status = EFI_SUCCESS;
+ EFI_STATUS Status;
+ CHAR8 *Source;
+ CHAR8 *CurrentPtr;
+ CHAR8 *BufferEnd;
+ CHAR8 *PtrLine;
+ UINTN LineLength;
+ UINTN SourceLength;
+ UINTN MaxLineLength;
+
+ *SectionHead = NULL;
+ *CommentHead = NULL;
+ BufferEnd = (CHAR8 *)((UINTN)DataBuffer + BufferSize);
+ CurrentPtr = (CHAR8 *)DataBuffer;
+ MaxLineLength = MAX_LINE_LENGTH;
+ Status = EFI_SUCCESS;
PtrLine = AllocatePool (MaxLineLength);
if (PtrLine == NULL) {
@@ -898,19 +949,19 @@ PreProcessDataFile (
}
while (CurrentPtr < BufferEnd) {
- Source = CurrentPtr;
- SourceLength = (UINTN)BufferEnd - (UINTN)CurrentPtr;
- LineLength = MaxLineLength;
+ Source = CurrentPtr;
+ SourceLength = (UINTN)BufferEnd - (UINTN)CurrentPtr;
+ LineLength = MaxLineLength;
//
// With the assumption that line length is less than 512
// characters. Otherwise BUFFER_TOO_SMALL will be returned.
//
- Status = ProfileGetLine (
- (UINT8 *) Source,
- SourceLength,
- (UINT8 *) PtrLine,
- &LineLength
- );
+ Status = ProfileGetLine (
+ (UINT8 *)Source,
+ SourceLength,
+ (UINT8 *)PtrLine,
+ &LineLength
+ );
if (EFI_ERROR (Status)) {
if (Status == EFI_BUFFER_TOO_SMALL) {
//
@@ -918,36 +969,39 @@ PreProcessDataFile (
// to the returned LineLength and try again.
//
FreePool (PtrLine);
- PtrLine = NULL;
+ PtrLine = NULL;
PtrLine = AllocatePool (LineLength);
if (PtrLine == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
break;
}
- SourceLength = LineLength;
- Status = ProfileGetLine (
- (UINT8 *) Source,
- SourceLength,
- (UINT8 *) PtrLine,
- &LineLength
- );
+
+ SourceLength = LineLength;
+ Status = ProfileGetLine (
+ (UINT8 *)Source,
+ SourceLength,
+ (UINT8 *)PtrLine,
+ &LineLength
+ );
if (EFI_ERROR (Status)) {
break;
}
- MaxLineLength = LineLength;
+
+ MaxLineLength = LineLength;
} else {
break;
}
}
- CurrentPtr = (CHAR8 *) ( (UINTN) CurrentPtr + LineLength);
+
+ CurrentPtr = (CHAR8 *)((UINTN)CurrentPtr + LineLength);
//
// Line got. Trim the line before processing it.
//
ProfileTrim (
- (UINT8 *) PtrLine,
+ (UINT8 *)PtrLine,
&LineLength
- );
+ );
//
// Blank line
@@ -956,24 +1010,24 @@ PreProcessDataFile (
continue;
}
- if (PtrLine[0] == '#' || PtrLine[0] == ';') {
- Status = ProfileGetComments (
- (UINT8 *) PtrLine,
- LineLength,
- CommentHead
- );
+ if ((PtrLine[0] == '#') || (PtrLine[0] == ';')) {
+ Status = ProfileGetComments (
+ (UINT8 *)PtrLine,
+ LineLength,
+ CommentHead
+ );
} else if (PtrLine[0] == '[') {
- Status = ProfileGetSection (
- (UINT8 *) PtrLine,
- LineLength,
- SectionHead
- );
+ Status = ProfileGetSection (
+ (UINT8 *)PtrLine,
+ LineLength,
+ SectionHead
+ );
} else {
- Status = ProfileGetEntry (
- (UINT8 *) PtrLine,
- LineLength,
- SectionHead
- );
+ Status = ProfileGetEntry (
+ (UINT8 *)PtrLine,
+ LineLength,
+ SectionHead
+ );
}
if (EFI_ERROR (Status)) {
@@ -1002,18 +1056,18 @@ PreProcessDataFile (
VOID *
EFIAPI
OpenIniFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize
)
{
- EFI_STATUS Status;
- INI_PARSING_LIB_CONTEXT *IniContext;
+ EFI_STATUS Status;
+ INI_PARSING_LIB_CONTEXT *IniContext;
- if (DataBuffer == NULL || BufferSize == 0) {
+ if ((DataBuffer == NULL) || (BufferSize == 0)) {
return NULL;
}
- IniContext = AllocateZeroPool(sizeof(INI_PARSING_LIB_CONTEXT));
+ IniContext = AllocateZeroPool (sizeof (INI_PARSING_LIB_CONTEXT));
if (IniContext == NULL) {
return NULL;
}
@@ -1027,12 +1081,13 @@ OpenIniFile (
&IniContext->SectionHead,
&IniContext->CommentHead
);
- if (EFI_ERROR(Status)) {
- FreePool(IniContext);
+ if (EFI_ERROR (Status)) {
+ FreePool (IniContext);
return NULL;
}
+
DEBUG_CODE_BEGIN ();
- DumpIniSection(IniContext);
+ DumpIniSection (IniContext);
DEBUG_CODE_END ();
return IniContext;
}
@@ -1050,29 +1105,29 @@ OpenIniFile (
**/
EFI_STATUS
EFIAPI
-GetStringFromDataFile(
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT CHAR8 **EntryValue
+GetStringFromDataFile (
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT CHAR8 **EntryValue
)
{
- INI_PARSING_LIB_CONTEXT *IniContext;
- EFI_STATUS Status;
+ INI_PARSING_LIB_CONTEXT *IniContext;
+ EFI_STATUS Status;
- if (Context == NULL || SectionName == NULL || EntryName == NULL || EntryValue == NULL) {
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (EntryValue == NULL)) {
return EFI_INVALID_PARAMETER;
}
IniContext = Context;
- *EntryValue = NULL;
- Status = UpdateGetProfileString (
- IniContext->SectionHead,
- SectionName,
- EntryName,
- EntryValue
- );
+ *EntryValue = NULL;
+ Status = UpdateGetProfileString (
+ IniContext->SectionHead,
+ SectionName,
+ EntryName,
+ EntryValue
+ );
return Status;
}
@@ -1090,34 +1145,36 @@ GetStringFromDataFile(
EFI_STATUS
EFIAPI
GetGuidFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT EFI_GUID *Guid
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT EFI_GUID *Guid
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
- RETURN_STATUS RStatus;
+ CHAR8 *Value;
+ EFI_STATUS Status;
+ RETURN_STATUS RStatus;
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Guid == NULL) {
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Guid == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Status = GetStringFromDataFile(
+ Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
ASSERT (Value != NULL);
RStatus = AsciiStrToGuid (Value, Guid);
if (RETURN_ERROR (RStatus) || (Value[GUID_STRING_LENGTH] != '\0')) {
return EFI_NOT_FOUND;
}
+
return EFI_SUCCESS;
}
@@ -1135,33 +1192,35 @@ GetGuidFromDataFile (
EFI_STATUS
EFIAPI
GetDecimalUintnFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINTN *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINTN *Data
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
+ CHAR8 *Value;
+ EFI_STATUS Status;
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Status = GetStringFromDataFile(
+ Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
ASSERT (Value != NULL);
- if (!IsValidDecimalString(Value, AsciiStrLen(Value))) {
+ if (!IsValidDecimalString (Value, AsciiStrLen (Value))) {
return EFI_NOT_FOUND;
}
- *Data = AsciiStrDecimalToUintn(Value);
+
+ *Data = AsciiStrDecimalToUintn (Value);
return EFI_SUCCESS;
}
@@ -1179,33 +1238,35 @@ GetDecimalUintnFromDataFile (
EFI_STATUS
EFIAPI
GetHexUintnFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINTN *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINTN *Data
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
+ CHAR8 *Value;
+ EFI_STATUS Status;
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Status = GetStringFromDataFile(
+ Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
ASSERT (Value != NULL);
- if (!IsValidHexString(Value, AsciiStrLen(Value))) {
+ if (!IsValidHexString (Value, AsciiStrLen (Value))) {
return EFI_NOT_FOUND;
}
- *Data = AsciiStrHexToUintn(Value);
+
+ *Data = AsciiStrHexToUintn (Value);
return EFI_SUCCESS;
}
@@ -1223,33 +1284,35 @@ GetHexUintnFromDataFile (
EFI_STATUS
EFIAPI
GetHexUint64FromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINT64 *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINT64 *Data
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
+ CHAR8 *Value;
+ EFI_STATUS Status;
- if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {
+ if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Status = GetStringFromDataFile(
+ Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
+
ASSERT (Value != NULL);
- if (!IsValidHexString(Value, AsciiStrLen(Value))) {
+ if (!IsValidHexString (Value, AsciiStrLen (Value))) {
return EFI_NOT_FOUND;
}
- *Data = AsciiStrHexToUint64(Value);
+
+ *Data = AsciiStrHexToUint64 (Value);
return EFI_SUCCESS;
}
@@ -1261,17 +1324,17 @@ GetHexUint64FromDataFile (
VOID
EFIAPI
CloseIniFile (
- IN VOID *Context
+ IN VOID *Context
)
{
- INI_PARSING_LIB_CONTEXT *IniContext;
+ INI_PARSING_LIB_CONTEXT *IniContext;
if (Context == NULL) {
- return ;
+ return;
}
IniContext = Context;
- FreeAllList(IniContext->SectionHead, IniContext->CommentHead);
+ FreeAllList (IniContext->SectionHead, IniContext->CommentHead);
return;
}
diff --git a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c
index fd89a5218c..1a73b5da2e 100644
--- a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c
+++ b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c
@@ -11,7 +11,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/PlatformFlashAccessLib.h>
-UINT64 mInternalFdAddress;
+UINT64 mInternalFdAddress;
/**
Perform flash write operation with progress indicator. The start and end
@@ -59,7 +59,8 @@ PerformFlashWriteWithProgress (
if (FlashAddressType == FlashAddressTypeRelativeAddress) {
FlashAddress = FlashAddress + mInternalFdAddress;
}
- CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length);
+
+ CopyMem ((VOID *)(UINTN)(FlashAddress), Buffer, Length);
return EFI_SUCCESS;
}
@@ -80,11 +81,11 @@ PerformFlashWriteWithProgress (
EFI_STATUS
EFIAPI
PerformFlashWrite (
- IN PLATFORM_FIRMWARE_TYPE FirmwareType,
- IN EFI_PHYSICAL_ADDRESS FlashAddress,
- IN FLASH_ADDRESS_TYPE FlashAddressType,
- IN VOID *Buffer,
- IN UINTN Length
+ IN PLATFORM_FIRMWARE_TYPE FirmwareType,
+ IN EFI_PHYSICAL_ADDRESS FlashAddress,
+ IN FLASH_ADDRESS_TYPE FlashAddressType,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
return PerformFlashWriteWithProgress (