disable deprecated functions

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2020-05-13 11:18:12 +03:00
parent 9571af3d83
commit de7ac1c1c6
13 changed files with 110 additions and 70 deletions

View File

@ -678,10 +678,10 @@ DEFINE EXIT_USBKB_FLAG = -DEXIT_USBKB
DEFINE BUILD_OPTIONS=-DMDEPKG_NDEBUG -DCLOVER_BUILD $(VBIOS_PATCH_CLOVEREFI_FLAG) $(ONLY_SATA_0_FLAG) $(BLOCKIO_FLAG) $(NOUSB_FLAG) $(NOUDMA_FLAG) $(AMD_FLAG) $(SECURE_BOOT_FLAG) $(ANDX86_FLAG) $(PS2MOUSE_LEGACYBOOT_FLAG) $(DEBUG_ON_SERIAL_PORT_FLAG) $(EXIT_USBKB_FLAG)
#MSFT:*_*_*_CC_FLAGS = /FAcs /FR$(@R).SBR /wd4701 /wd4703 $(BUILD_OPTIONS)
MSFT:*_*_*_CC_FLAGS = /FAcs $(BUILD_OPTIONS) -Dinline=__inline /Zi
MSFT:*_*_*_CC_FLAGS = /FAcs $(BUILD_OPTIONS) -Dinline=__inline /Zi -D DISABLE_NEW_DEPRECATED_INTERFACES
XCODE:*_*_*_CC_FLAGS = -fno-unwind-tables -Wno-msvc-include -Os $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG)
GCC:*_*_*_CC_FLAGS = $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG)
GCC:*_*_*_CXX_FLAGS = $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG)
XCODE:*_*_*_CC_FLAGS = -fno-unwind-tables -Wno-msvc-include -Os $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG) -D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_*_*_CC_FLAGS = $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG) -D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_*_*_CXX_FLAGS = $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG) -D DISABLE_NEW_DEPRECATED_INTERFACES
#-Wunused-but-set-variable
# -Os -fno-omit-frame-pointer -maccumulate-outgoing-args

View File

@ -834,11 +834,11 @@ UpdateConModePage (
//
// Build mode string Column x Row
//
UnicodeValueToString (ModeString, 0, Col, 0);
UnicodeValueToStringS(ModeString, 50, 0, Col, 0);
PStr = &ModeString[0];
StrnCatS (PStr, 50, L" x ", StrLen(L" x ") + 1);
PStr = PStr + StrLen (PStr);
UnicodeValueToString (PStr , 0, Row, 0);
UnicodeValueToStringS(PStr, 50, 0, Row, 0);
ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);

View File

@ -1344,14 +1344,17 @@ Var_UpdateConMode (
EFI_STATUS Status;
UINTN Mode;
CONSOLE_OUT_MODE ModeInfo;
Mode = CallbackData->BmmFakeNvData.ConsoleOutMode;
Status = gST->ConOut->QueryMode (gST->ConOut, Mode, &(ModeInfo.Column), &(ModeInfo.Row));
if (!EFI_ERROR(Status)) {
PcdSet32 (PcdSetupConOutColumn, (UINT32) ModeInfo.Column);
PcdSet32 (PcdSetupConOutRow, (UINT32) ModeInfo.Row);
Status = PcdSet32S(PcdSetupConOutColumn, (UINT32)ModeInfo.Column);
if (!EFI_ERROR(Status)) {
Status = PcdSet32S(PcdSetupConOutRow, (UINT32)ModeInfo.Row);
}
}
return Status;
return EFI_SUCCESS;
}

View File

@ -401,7 +401,7 @@ GetMacAddressString(
//
HwAddress = &MacAddressNode->MacAddress.Addr[0];
for (Index = 0; Index < HwAddressSize; Index++) {
String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
String += UnicodeValueToStringS(String, BufferLen, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
if (Index < HwAddressSize - 1) {
*String++ = L':';
}
@ -411,17 +411,17 @@ GetMacAddressString(
// If VLAN is configured, it will need extra 5 characters like "\0005".
// Plus one unicode character for the null-terminator.
//
Node = (EFI_DEVICE_PATH_PROTOCOL *)MacAddressNode;
Node = (EFI_DEVICE_PATH_PROTOCOL*)MacAddressNode;
while (!IsDevicePathEnd (Node)) {
if (Node->Type == MESSAGING_DEVICE_PATH && Node->SubType == MSG_VLAN_DP) {
VlanId = ((VLAN_DEVICE_PATH *) Node)->VlanId;
VlanId = ((VLAN_DEVICE_PATH*) Node)->VlanId;
}
Node = NextDevicePathNode (Node);
}
if (VlanId != 0) {
*String++ = L'\\';
String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
String += UnicodeValueToStringS(String, BufferLen, PREFIX_ZERO | RADIX_HEX, VlanId, 4);
}
//

View File

@ -406,13 +406,13 @@ InitializeFrontPage (
//
HiiHandle = gFrontPagePrivate.HiiHandle;
CurrentLang = GetEfiGlobalVariable (L"PlatformLang");
GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL);
//
// Get Support language list from variable.
//
if (mLanguageString == NULL){
mLanguageString = GetEfiGlobalVariable (L"PlatformLangCodes");
GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID**)&mLanguageString, NULL);
if (mLanguageString == NULL) {
mLanguageString = AllocateCopyPool(
AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),
@ -428,8 +428,11 @@ InitializeFrontPage (
//
LangCode = mLanguageString;
Lang = AllocatePool (AsciiStrSize (mLanguageString));
ASSERT (Lang != NULL);
OptionCount = 0;
// ASSERT (Lang != NULL);
if (!Lang) {
return EFI_OUT_OF_RESOURCES;
}
OptionCount = 0;
while (*LangCode != 0) {
GetNextLanguage (&LangCode, Lang);
OptionCount ++;
@ -439,10 +442,15 @@ InitializeFrontPage (
// Allocate extra 1 as the end tag.
//
gFrontPagePrivate.LanguageToken = AllocateZeroPool((OptionCount + 1) * sizeof (EFI_STRING_ID));
ASSERT (gFrontPagePrivate.LanguageToken != NULL);
if (gFrontPagePrivate.LanguageToken == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);
ASSERT_EFI_ERROR(Status);
// ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return EFI_NOT_FOUND;
}
LangCode = mLanguageString;
OptionCount = 0;
@ -453,18 +461,29 @@ InitializeFrontPage (
Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
if (Status == EFI_BUFFER_TOO_SMALL) {
StringBuffer = AllocateZeroPool(StringSize);
ASSERT (StringBuffer != NULL);
// ASSERT (StringBuffer != NULL);
if (!StringBuffer) {
return EFI_OUT_OF_RESOURCES;
}
Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
ASSERT_EFI_ERROR(Status);
// ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return EFI_NOT_FOUND;
}
}
if (EFI_ERROR(Status)) {
StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16));
ASSERT (StringBuffer != NULL);
if (!StringBuffer) {
return EFI_OUT_OF_RESOURCES;
}
AsciiStrToUnicodeStrS (Lang, StringBuffer, AsciiStrSize(Lang));
}
ASSERT (StringBuffer != NULL);
if (!StringBuffer) {
return EFI_OUT_OF_RESOURCES;
}
gFrontPagePrivate.LanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);
FreePool(StringBuffer);
@ -472,13 +491,17 @@ InitializeFrontPage (
}
}
ASSERT (gFrontPagePrivate.LanguageToken != NULL);
// ASSERT (gFrontPagePrivate.LanguageToken != NULL); //already tested
LangCode = mLanguageString;
OptionCount = 0;
if (Lang == NULL) {
Lang = AllocatePool (AsciiStrSize (mLanguageString));
ASSERT (Lang != NULL);
// ASSERT (Lang != NULL);
if (!Lang) {
return EFI_OUT_OF_RESOURCES;
}
}
while (*LangCode != 0) {
GetNextLanguage (&LangCode, Lang);
@ -636,14 +659,14 @@ ConvertProcessorToString (
FreqMhz = 0;
}
StringBuffer = AllocateZeroPool(0x20);
StringBuffer = AllocateZeroPool(32);
// ASSERT (StringBuffer != NULL);
if (!StringBuffer) {
StringBuffer = L" ";
}
Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
Index = UnicodeValueToStringS(StringBuffer, 32, LEFT_JUSTIFY, FreqMhz / 1000, 3);
StrCatS (StringBuffer, 32, L".");
UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
UnicodeValueToStringS(StringBuffer + Index + 1, 31 - Index, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
StrCatS (StringBuffer, 32, L" GHz");
*String = (CHAR16 *) StringBuffer;
return ;
@ -665,16 +688,16 @@ ConvertMemorySizeToString (
{
CHAR16 *StringBuffer;
StringBuffer = AllocateZeroPool(0x20);
StringBuffer = AllocateZeroPool(32);
// ASSERT (StringBuffer != NULL);
if (!StringBuffer) {
StringBuffer = L" ";
}
UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
StrCatS (StringBuffer, 32, L" MB RAM");
UnicodeValueToStringS(StringBuffer, 32, LEFT_JUSTIFY, MemorySize, 6);
StrCatS(StringBuffer, 32, L" MB RAM");
*String = (CHAR16 *) StringBuffer;
*String = (CHAR16 *)StringBuffer;
return ;
}

View File

@ -236,7 +236,7 @@ BdsMemoryTest (
ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
StrTotalMemorySize = 128;
Pos = AllocatePool (StrTotalMemorySize);
Pos = AllocatePool(StrTotalMemorySize);
if (Pos == NULL) {
return ReturnStatus;
@ -319,7 +319,7 @@ BdsMemoryTest (
TempData
);
if (TestPercent != PreviousValue) {
UnicodeValueToString (StrPercent, 0, TestPercent, 0);
UnicodeValueToStringS(StrPercent, 80, 0, TestPercent, 0);
TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT));
if (TmpStr != NULL) {
//
@ -382,15 +382,15 @@ BdsMemoryTest (
Done:
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0);
UnicodeValueToStringS(StrTotalMemory, StrTotalMemorySize, COMMA_TYPE, TotalMemorySize, 0);
if (StrTotalMemory[0] == L',') {
StrTotalMemory++;
StrTotalMemorySize -= sizeof (CHAR16);
StrTotalMemorySize -= sizeof(CHAR16);
}
TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));
TmpStr = GetStringById(STRING_TOKEN (STR_MEM_TEST_COMPLETED));
if (TmpStr != NULL) {
StrnCatS (StrTotalMemory, 80, TmpStr, StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1);
StrnCatS(StrTotalMemory, 80, TmpStr, StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1);
FreePool(TmpStr);
}
@ -417,7 +417,7 @@ Done:
//
IsFirstBoot = PcdGetBool(PcdBootState);
if (IsFirstBoot) {
PcdSetBool(PcdBootState, FALSE);
PcdSetBoolS(PcdBootState, FALSE);
}
return ReturnStatus;

View File

@ -70,9 +70,12 @@ InstallProcessorSmbios (
// Set ProcessorVersion string
//
AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type4->ProcessorVersion);
UString = AllocateZeroPool((AsciiStrLen(AString) + 1) * sizeof(CHAR16));
ASSERT (UString != NULL);
AsciiStrToUnicodeStr (AString, UString);
INTN Size = (AsciiStrLen(AString) + 1);
UString = AllocateZeroPool(Size * sizeof(CHAR16));
if (UString == NULL) {
return;
}
AsciiStrToUnicodeStrS(AString, UString, Size);
Token = HiiSetString (gStringHandle, 0, UString, NULL);
if (Token == 0) {
@ -114,6 +117,8 @@ InstallMemorySmbios (
return ;
}
//Slice - this is very old and wrong function but it used and not influences on further behaviour
// so let it be as is
VOID
InstallMiscSmbios (
IN VOID *Smbios
@ -137,12 +142,15 @@ InstallMiscSmbios (
// Record Type 2
//
AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type0->BiosVersion);
UString = AllocateZeroPool((AsciiStrLen(AString) + 1) * sizeof(CHAR16) + sizeof(FIRMWARE_BIOS_VERSIONE));
ASSERT (UString != NULL);
INTN Size = (AsciiStrLen(AString) + 1) + sizeof(FIRMWARE_BIOS_VERSIONE) / sizeof(CHAR16);
UString = AllocateZeroPool(Size * sizeof(CHAR16));
if (UString == NULL) {
return;
}
CopyMem(UString, FIRMWARE_BIOS_VERSIONE, sizeof(FIRMWARE_BIOS_VERSIONE));
AsciiStrToUnicodeStr (AString, UString + sizeof(FIRMWARE_BIOS_VERSIONE) / sizeof(CHAR16) - 1);
AsciiStrToUnicodeStrS(AString, UString + sizeof(FIRMWARE_BIOS_VERSIONE) / sizeof(CHAR16) - 1, Size);
Token = HiiSetString (gStringHandle, 0, UString, NULL);
Token = HiiSetString(gStringHandle, 0, UString, NULL);
if (Token == 0) {
gBS->FreePool(UString);
return ;
@ -167,12 +175,15 @@ InstallMiscSmbios (
// Record Type 3
//
AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type1->ProductName);
UString = AllocateZeroPool((AsciiStrLen(AString) + 1) * sizeof(CHAR16) + sizeof(FIRMWARE_PRODUCT_NAME));
ASSERT (UString != NULL);
Size = (AsciiStrLen(AString) + 1) + sizeof(FIRMWARE_PRODUCT_NAME) / sizeof(CHAR16);
UString = AllocateZeroPool(Size * sizeof(CHAR16));
if (UString == NULL) {
return;
}
CopyMem(UString, FIRMWARE_PRODUCT_NAME, sizeof(FIRMWARE_PRODUCT_NAME));
AsciiStrToUnicodeStr (AString, UString + sizeof(FIRMWARE_PRODUCT_NAME) / sizeof(CHAR16) - 1);
AsciiStrToUnicodeStrS(AString, UString + sizeof(FIRMWARE_PRODUCT_NAME) / sizeof(CHAR16) - 1, Size);
Token = HiiSetString (gStringHandle, 0, UString, NULL);
Token = HiiSetString(gStringHandle, 0, UString, NULL);
if (Token == 0) {
gBS->FreePool(UString);
return ;

View File

@ -47,7 +47,7 @@
#define va_arg VA_ARG
#endif
#define memcmp CompareMem
#define strcpy AsciiStrCpy
#define strcpy(out,in) AsciiStrnCpyS(out, AsciiStrLen(out)+1, in, AsciiStrLen(in))
#define memmove CopyMem
#define memset(s,c,n) SetMem(s,n,c)
#define bzero(s,n) SetMem(s,n,0)

View File

@ -708,6 +708,8 @@ Var_UpdateDriverOrder (
@return Other value if the Text Mode of Console is not updated.
**/
EFI_STATUS
Var_UpdateConMode (
IN BMM_CALLBACK_DATA *CallbackData
@ -721,9 +723,9 @@ Var_UpdateConMode (
Status = gST->ConOut->QueryMode (gST->ConOut, Mode, &(ModeInfo.Column), &(ModeInfo.Row));
if (!EFI_ERROR(Status)) {
Status = PcdSet32S (PcdSetupConOutColumn, (UINT32) ModeInfo.Column);
Status = PcdSet32S(PcdSetupConOutColumn, ((UINT32)ModeInfo.Column) );
if (!EFI_ERROR(Status)) {
Status = PcdSet32S (PcdSetupConOutRow, (UINT32) ModeInfo.Row);
Status = PcdSet32S(PcdSetupConOutRow, ((UINT32)ModeInfo.Row) );
}
}

View File

@ -93,9 +93,9 @@ PrintDxeAsciiValueToString (
// implementation of the AsciiValueToString service in EFI_PRINT2_PROTOCOL
// to indicate that the service is no longer supported.
//
DEBUG ((DEBUG_ERROR, "PrintDxe: The AsciiValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the AsciiValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
ASSERT (FALSE);
// DEBUG ((DEBUG_ERROR, "PrintDxe: The AsciiValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
// DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the AsciiValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
// ASSERT (FALSE);
return 0;
#else
return AsciiValueToString (Buffer, Flags, Value, Width);

View File

@ -1563,9 +1563,10 @@ VOID devprop_add_list(AtiDevProp devprop_list[], CHAR8 *OSVersion)
if (devprop_list[i].all_ports) {
for (pnum = 1; pnum < card->ports; pnum++) {
if (devprop_list[i].get_value(val, pnum, Sier)) {
char* newname = (char*)AllocatePool(AsciiStrLen(devprop_list[i].name)+1);
AsciiStrCpy(newname, devprop_list[i].name);
newname[1] = (CHAR8)(0x30 + pnum); // convert to ascii
INTN size = AsciiStrLen(devprop_list[i].name) + 1;
char* newname = (char*)AllocatePool(size);
AsciiStrCpyS(newname, size, devprop_list[i].name);
newname[1] = (CHAR8)(0x30 + pnum); // convert to ascii for number 0..9
devprop_add_value(card->device, newname, val->data, val->size);
free_val(val);
FreePool((VOID*)newname);

View File

@ -158,7 +158,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *File
p -= 1;
}
dirNameLen = p - FileName;
StrnCpy(DirName, FileName, dirNameLen);
StrnCpyS(DirName, 256, FileName, dirNameLen);
DirName[dirNameLen] = L'\0';
Status = BaseDir->Open(BaseDir, &FileHandle, DirName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, EFI_FILE_DIRECTORY);

View File

@ -1845,14 +1845,14 @@ VOID SystemVersionInit(VOID)
CHAR16 *TmpServerPlistPath = (__typeof__(TmpServerPlistPath))AllocateZeroPool(86*sizeof(CHAR16));
CHAR16 *TmpInsPlistPath = (__typeof__(TmpInsPlistPath))AllocateZeroPool(79*sizeof(CHAR16));
CHAR16 *TmpRecPlistPath = (__typeof__(TmpRecPlistPath))AllocateZeroPool(58*sizeof(CHAR16));
StrnCpy(TmpSysPlistPath, APFSSysPlistPath, 85);
StrnCpy(TmpServerPlistPath, APFSServerPlistPath, 85);
StrnCpy(TmpInsPlistPath, APFSInstallPlistPath, 78);
StrnCpy(TmpRecPlistPath, APFSRecPlistPath, 57);
StrnCpy(TmpSysPlistPath+1, CurrentUUID.wc_str(), 36);
StrnCpy(TmpServerPlistPath+1, CurrentUUID.wc_str(), 36);
StrnCpy(TmpInsPlistPath+1, CurrentUUID.wc_str(), 36);
StrnCpy(TmpRecPlistPath+1, CurrentUUID.wc_str(), 36);
StrnCpyS(TmpSysPlistPath, 86, APFSSysPlistPath, 85);
StrnCpyS(TmpServerPlistPath, 86, APFSServerPlistPath, 85);
StrnCpyS(TmpInsPlistPath, 79, APFSInstallPlistPath, 78);
StrnCpyS(TmpRecPlistPath, 58, APFSRecPlistPath, 57);
StrnCpyS(TmpSysPlistPath+1, 57, CurrentUUID.wc_str(), 36);
StrnCpyS(TmpServerPlistPath+1, 85, CurrentUUID.wc_str(), 36);
StrnCpyS(TmpInsPlistPath+1, 78, CurrentUUID.wc_str(), 36);
StrnCpyS(TmpRecPlistPath+1, 57, CurrentUUID.wc_str(), 36);
//Fill SystemPlists/InstallPlists/RecoveryPlists arrays
SystemPlists[SysIter] = TmpSysPlistPath;
SystemPlists[SysIter+1] = TmpServerPlistPath;