Remove unecessary cast. Some cleanups.

This commit is contained in:
Jief L 2020-02-22 00:22:30 +03:00
parent 9378884f6e
commit 8199d9b75c
16 changed files with 47 additions and 56 deletions

View File

@ -2064,7 +2064,7 @@ class Build():
if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict:
FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName]
for FdRegion in FdDict.RegionList:
if str(FdRegion.RegionType) is 'FILE' and self.Platform.VpdToolGuid in str(FdRegion.RegionDataList):
if str(FdRegion.RegionType) == 'FILE' and self.Platform.VpdToolGuid in str(FdRegion.RegionDataList):
if int(FdRegion.Offset) % 8 != 0:
EdkLogger.error("build", FORMAT_INVALID, 'The VPD Base Address %s must be 8-byte aligned.' % (FdRegion.Offset))
Wa.FdfProfile = Fdf.Profile

View File

@ -26,7 +26,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Disable warning when last field of data structure is a zero sized array.
//
#pragma warning ( disable : 4200 )
#pragma warning ( disable : 4804 )
#endif
/**
@ -40,7 +39,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
@param Size The expected size for the TYPE.
**/
#define VERIFY_SIZE_OF(TYPE, Size) extern UINT8 _VerifySizeof##TYPE[((sizeof(TYPE) == (Size))?1:0) / ((sizeof(TYPE) == (Size))?1:0)]
#define VERIFY_SIZE_OF(TYPE, Size) extern UINT8 _VerifySizeof##TYPE[(unsigned char)((sizeof(TYPE) == (Size))) / (unsigned char)((sizeof(TYPE) == (Size)))]
//
// Verify that ProcessorBind.h produced UEFI Data Types that are compliant with

View File

@ -310,11 +310,8 @@ EFI_STATUS ScanDeviceHandles(EFI_HANDLE ControllerHandle,
//
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, HandleCount, HandleBuffer);
if (EFI_ERROR (Status)) goto Error;
#ifdef _MSC_VER
*HandleType = static_cast<UINT32*>(AllocatePool(*HandleCount * sizeof(UINT32)));
#else
*HandleType = (__typeof__(*HandleType))AllocatePool (*HandleCount * sizeof (UINT32));
#endif
*HandleType = (__typeof_am__(*HandleType))AllocatePool (*HandleCount * sizeof (UINT32));
if (*HandleType == NULL) goto Error;
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {

View File

@ -267,7 +267,7 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
--VariablePtr;
}
gRT->SetVariable((CHAR16*)KbdPrevLang, &gEfiAppleBootGuid, Attributes, LangLen, &gSettings.Language);
gRT->SetVariable(KbdPrevLang, &gEfiAppleBootGuid, Attributes, LangLen, &gSettings.Language);
} else {
FreePool(OldData);
}

View File

@ -848,7 +848,7 @@ LoadNvramPlist (
// DBG (" parsing error\n");
// }
FreePool ((VOID*)NvramPtr);
FreePool (NvramPtr);
// we will leave nvram.plist loaded and parsed for later processing
//FreeTag(gNvramDict);

View File

@ -1736,7 +1736,6 @@ extern BOOLEAN gRemapSmBiosIsRequire; // syscl: pass arg
//-----------------------------------
//void FreePool(const wchar_t * A);
VOID
FixBiosDsdt (
@ -2298,8 +2297,6 @@ iStrLen(
UINTN MaxLen
);
//VOID CheckEmptyFB(); //not needed to be global
EFI_STATUS
PrepatchSmbios (VOID);

View File

@ -408,7 +408,7 @@ ParseLoadOptions (
AsciiConf = (__typeof__(AsciiConf))AllocateCopyPool (TailSize + 1, Start);
if (AsciiConf != NULL) {
*(AsciiConf + TailSize) = '\0';
*Conf = (CHAR16*)AllocateZeroPool ((TailSize + 1) * sizeof (CHAR16));
*Conf = (__typeof_am__(*Conf))AllocateZeroPool ((TailSize + 1) * sizeof (CHAR16));
AsciiStrToUnicodeStrS (AsciiConf, *Conf, TailSize);
FreePool (AsciiConf);
}
@ -1062,7 +1062,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
}
if (AsciiStrSize(Prop2->string) > 1) {
Patches->ForceKexts[Patches->NrForceKexts] = (CHAR16*)AllocateZeroPool (AsciiStrSize(Prop2->string) * sizeof(CHAR16));
Patches->ForceKexts[Patches->NrForceKexts] = (__typeof_am__(Patches->ForceKexts[Patches->NrForceKexts]))AllocateZeroPool (AsciiStrSize(Prop2->string) * sizeof(CHAR16));
AsciiStrToUnicodeStrS(Prop2->string, Patches->ForceKexts[Patches->NrForceKexts], 255);
DBG (" - [%d]: %s\n", Patches->NrForceKexts, Patches->ForceKexts[Patches->NrForceKexts]);
++Patches->NrForceKexts;
@ -1588,7 +1588,7 @@ MatchOSes *GetStrArraySeparatedByChar(CHAR8 *str, CHAR8 sep)
/* comp = (CHAR8 *) AllocatePool(newLen);
AsciiStrnCpy(comp, str + startLocation, newLen);
comp[newLen] = '\0'; */
mo->array[i] = (CHAR8*)AllocateCopyPool(newLen, str + startLocation);
mo->array[i] = (__typeof_am__(mo->array[i]))AllocateCopyPool(newLen, str + startLocation);
mo->array[i][newLen - 1] = '\0';
}
@ -1596,7 +1596,7 @@ MatchOSes *GetStrArraySeparatedByChar(CHAR8 *str, CHAR8 sep)
}
else {
// DBG("str contains only one component and it is our string %s!\n", str);
mo->array[0] = (CHAR8*)AllocateCopyPool(AsciiStrLen(str)+1, str);
mo->array[0] = (__typeof_am__(mo->array[0]))AllocateCopyPool(AsciiStrLen(str)+1, str);
}
return mo;
}
@ -5051,7 +5051,7 @@ GetUserSettings(
for (j = 0; j < PropCount; j++) {
Prop3 = NULL;
DevProps = *Child;
*Child = (DEV_PROPERTY *)AllocateZeroPool(sizeof(DEV_PROPERTY));
*Child = (__typeof_am__(*Child))AllocateZeroPool(sizeof(__typeof_am__(*Child)));
(*Child)->Next = DevProps;
if (EFI_ERROR(GetElement(Prop2, j, &Prop3))) { // Prop3 -> <key>
@ -5628,7 +5628,7 @@ GetUserSettings(
} else {
AsciiSPrint(DSDTPatchesLabel, 255, " (NoLabel)");
}
gSettings.PatchDsdtLabel[i] = (CHAR8*)AllocateZeroPool(256);
gSettings.PatchDsdtLabel[i] = (__typeof_am__(gSettings.PatchDsdtLabel[i]))AllocateZeroPool(256);
AsciiSPrint(gSettings.PatchDsdtLabel[i], 255, "%a", DSDTPatchesLabel);
DBG(" (%a)", gSettings.PatchDsdtLabel[i]);
@ -6730,8 +6730,8 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry)
Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8);
}
}
FreePool((VOID*)fileBuffer);
FreePool((VOID*)targetString);
FreePool(fileBuffer);
FreePool(targetString);
}
}
}

View File

@ -180,16 +180,16 @@ VOID* GetSmbiosTablesFromHob (VOID)
EFI_PHYSICAL_ADDRESS *Table;
EFI_PEI_HOB_POINTERS GuidHob;
GuidHob.Raw = (__typeof__(GuidHob.Raw))GetFirstGuidHob (&gEfiSmbiosTableGuid);
GuidHob.Raw = (__typeof_am__(GuidHob.Raw))GetFirstGuidHob (&gEfiSmbiosTableGuid);
if (GuidHob.Raw != NULL) {
Table = (__typeof__(Table))GET_GUID_HOB_DATA (GuidHob.Guid);
if (Table != NULL) {
return (VOID *)(UINTN)*Table;
}
}
GuidHob.Raw = (__typeof__(GuidHob.Raw))GetFirstGuidHob (&gEfiSmbios3TableGuid);
GuidHob.Raw = (__typeof_am__(GuidHob.Raw))GetFirstGuidHob (&gEfiSmbios3TableGuid);
if (GuidHob.Raw != NULL) {
Table = (__typeof__(Table))GET_GUID_HOB_DATA (GuidHob.Guid);
Table = (__typeof_am__(Table))GET_GUID_HOB_DATA (GuidHob.Guid);
if (Table != NULL) {
return (VOID *)(UINTN)*Table;
}
@ -2107,14 +2107,14 @@ VOID FinalizeSmbios() //continue
BOOLEAN FoundTable3 = FALSE;
// Get Hob List
HobStart.Raw = (__typeof__(HobStart.Raw))GetHobList();
HobStart.Raw = (__typeof_am__(HobStart.Raw))GetHobList();
if (HobStart.Raw != NULL) {
// find SMBIOS in hob
for (Index = 0; Index < sizeof (gTableGuidArray) / sizeof (*gTableGuidArray); ++Index) {
GuidHob.Raw = (__typeof__(HobStart.Raw))GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);
GuidHob.Raw = (__typeof_am__(HobStart.Raw))GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);
if (GuidHob.Raw != NULL) {
Table = (__typeof__(Table))GET_GUID_HOB_DATA (GuidHob.Guid);
Table = (__typeof_am__(Table))GET_GUID_HOB_DATA (GuidHob.Guid);
//TableLength = GET_GUID_HOB_DATA_SIZE (GuidHob);
if (Table != NULL) {
if (Index != 0) {

View File

@ -72,7 +72,7 @@ XStringW::XStringW(const wchar_t aChar)
{
DBG("Constructor(const wchar_t aChar)\n");
Init(1);
XStringW::StrnCpy(&aChar, 1);
StrnCpy(&aChar, 1);
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@ -132,7 +132,7 @@ void XStringW::StrnCpy(const wchar_t *buf, UINTN len)
void XStringW::StrCpy(const wchar_t *buf)
{
if ( buf && *buf ) {
XStringW::StrnCpy(buf, StrLen(buf));
StrnCpy(buf, StrLen(buf));
}else{
SetLength(0); /* data()[0]=0 done in SetLength */
}
@ -154,13 +154,13 @@ void XStringW::StrnCat(const wchar_t *buf, UINTN len)
inline void XStringW::StrCat(const wchar_t *buf)
{
if ( buf && *buf ) {
XStringW::StrnCat(buf, StrLen(buf));
StrnCat(buf, StrLen(buf));
}
}
void XStringW::StrCat(const XStringW &uneXStringWW)
{
XStringW::StrnCat(uneXStringWW.data(), uneXStringWW.length());
StrnCat(uneXStringWW.data(), uneXStringWW.length());
}
void XStringW::Delete(UINTN pos, UINTN count)
@ -183,7 +183,7 @@ void XStringW::Insert(UINTN pos, const XStringW& Str)
CopyMem(data(pos), Str.data(), Str.length()*sizeof(wchar_t));
SetLength(length()+Str.length());
}else{
XStringW::StrCat(Str);
StrCat(Str);
}
}
@ -245,14 +245,14 @@ XStringW XStringW::basename() const
{
UINTN idx = RIdxOf(LPATH_SEPARATOR);
if ( idx == MAX_UINTN ) return XStringW();
return XStringW::SubString(idx+1, length()-idx-1);
return SubString(idx+1, length()-idx-1);
}
XStringW XStringW::dirname() const
{
UINTN idx = RIdxOf(LPATH_SEPARATOR);
if ( idx == MAX_UINTN ) return XStringW();
return XStringW::SubString(0, idx);
return SubString(0, idx);
}
XStringW XStringW::SubString(UINTN pos, UINTN count) const

View File

@ -115,11 +115,11 @@ public:
void Replace(wchar_t c1, wchar_t c2);
XStringW SubStringReplace(wchar_t c1, wchar_t c2);
INTN Compare(const wchar_t* S) const { return StrCmp((const CHAR16*)data(), (const CHAR16*)S) ; }
INTN Compare(const wchar_t* S) const { return StrCmp(data(), S) ; }
bool Equal(const wchar_t* S) const { return Compare(S) == 0; };
bool BeginingEqual(const wchar_t* S) const { return StrnCmp((const CHAR16*)data(), (const CHAR16*)S, StrLen((const CHAR16*)S)); }
bool SubStringEqual(UINTN Pos, const wchar_t* S) const { return StrCmp((const CHAR16*)data(Pos), (const CHAR16*)S); }
bool BeginingEqual(const wchar_t* S) const { return StrnCmp(data(), S, StrLen(S)); }
bool SubStringEqual(UINTN Pos, const wchar_t* S) const { return StrCmp(data(Pos), S); }
XStringW basename() const;
XStringW dirname() const;

View File

@ -51,7 +51,6 @@ DBG("atexit(%p, %p, %p, %d)\n", destructor_func, objptr, dso, sizeof(atexit_func
#elif defined(_MSC_VER)
extern "C" int atexit(void(__cdecl *)(void));
extern "C" int atexit(void(__cdecl *destructor_func)(void))
{
DBG("atexit(%p, %p, %p, %d)\n", destructor_func, objptr, dso, sizeof(atexit_func_entry_t));

View File

@ -409,7 +409,7 @@ EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize)
nsvgDeleteRasterizer(rast);
*dict = (TagPtr)AllocateZeroPool(sizeof(TagStruct));
*dict = (__typeof_am__(*dict))AllocateZeroPool(sizeof(TagStruct));
(*dict)->type = kTagTypeNone;
GlobalConfig.TypeSVG = TRUE;
GlobalConfig.ThemeDesignHeight = (int)SVGimage->height;

View File

@ -436,7 +436,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
// end of folder checking
// Delete existing file if it exists
Status = BaseDir->Open(BaseDir, &FileHandle, (CHAR16*)FileName,
Status = BaseDir->Open(BaseDir, &FileHandle, FileName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
if (!EFI_ERROR(Status)) {
Status = FileHandle->Delete(FileHandle);
@ -449,7 +449,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
if (CreateNew) {
// Write new file
Status = BaseDir->Open(BaseDir, &FileHandle, (CHAR16*)FileName,
Status = BaseDir->Open(BaseDir, &FileHandle, FileName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) {
// DBG("no write %r\n", Status);

View File

@ -169,6 +169,7 @@
cpp_util/globals_dtor.h
cpp_util/operatorNewDelete.cpp
cpp_util/operatorNewDelete.h
cpp_util/remove_ref.h
[Sources.IA32]
libeg/ftol.asm | MSFT

View File

@ -69,8 +69,10 @@
// variables
#ifdef FIRMWARE_REVISION
CONST CHAR16 gFirmwareRevisionM[] = FIRMWARE_REVISION;
CONST CHAR16 *gFirmwareRevision = &gFirmwareRevisionM[0];
//CONST CHAR16 gFirmwareRevisionM[] = FIRMWARE_REVISION;
//CONST CHAR16 *gFirmwareRevision = &gFirmwareRevisionM[0];
CONST CHAR16 *gFirmwareRevision = FIRMWARE_REVISION;
#else
CONST CHAR16 *gFirmwareRevision = NULL;
#endif
@ -118,12 +120,12 @@ extern UINTN AudioNum;
extern HDA_OUTPUTS AudioList[20];
extern EFI_AUDIO_IO_PROTOCOL *AudioIo;
#ifdef _cplusplus
void FreePool(const wchar_t * A)
{
FreePool((VOID*)A);
}
#endif
//#ifdef _cplusplus
//void FreePool(const wchar_t * A)
//{
// FreePool((VOID*)A);
//}
//#endif
static EFI_STATUS LoadEFIImageList(IN EFI_DEVICE_PATH **DevicePaths,
IN CONST CHAR16 *ImageTitle,
@ -489,11 +491,7 @@ VOID FilterBootPatches(IN LOADER_ENTRY *Entry)
VOID ReadSIPCfg()
{
UINT32 csrCfg = gSettings.CsrActiveConfig & CSR_VALID_FLAGS;
#ifdef _MSC_VER
CHAR16 *csrLog = (decltype(csrLog))AllocateZeroPool(SVALUE_MAX_SIZE);
#else
CHAR16 *csrLog = (__typeof__(csrLog))AllocateZeroPool(SVALUE_MAX_SIZE);
#endif
if (csrCfg & CSR_ALLOW_UNTRUSTED_KEXTS)
StrCatS(csrLog, SVALUE_MAX_SIZE/2, L"CSR_ALLOW_UNTRUSTED_KEXTS");

View File

@ -2829,7 +2829,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
for (i = 0; i < (INTN)Screen->InfoLineCount; i++) {
gST->ConOut->SetCursorPosition (gST->ConOut, 3, 4 + i);
gST->ConOut->OutputString (gST->ConOut, (CHAR16*)Screen->InfoLines[i]);
gST->ConOut->OutputString (gST->ConOut, Screen->InfoLines[i]);
}
}
@ -4352,7 +4352,7 @@ UINTN RunMenu(IN REFIT_MENU_SCREEN *Screen, OUT REFIT_MENU_ENTRY **ChosenEntry)
VOID NewEntry(REFIT_MENU_ENTRY **Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title)
{
//create entry
*Entry = (REFIT_MENU_ENTRY*) AllocateZeroPool(sizeof(LOADER_ENTRY));
*Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY));
if (Title) {
(*Entry)->Title = PoolPrint(L"%a", Title);
} else {
@ -4363,7 +4363,7 @@ VOID NewEntry(REFIT_MENU_ENTRY **Entry, REFIT_MENU_SCREEN **SubScreen, ACTION At
(*Entry)->Tag = TAG_OPTIONS;
(*Entry)->AtClick = AtClick;
// create the submenu
*SubScreen = (REFIT_MENU_SCREEN*)AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
*SubScreen = (__typeof_am__(*SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
(*SubScreen)->Title = (*Entry)->Title;
(*SubScreen)->TitleImage = (*Entry)->Image;
(*SubScreen)->ID = ID;