Add cast to return value of GetNvramVariable (prepa C++)

This commit is contained in:
jief 2019-12-27 16:10:42 +01:00
parent 9b01a6fe58
commit 5e650e92cf
7 changed files with 18 additions and 18 deletions

View File

@ -371,7 +371,7 @@ GetBootOrder (
//
// Get gEfiGlobalVariableGuid:BootOrder and it's length
//
*BootOrder = GetNvramVariable (BOOT_ORDER_VAR, &gEfiGlobalVariableGuid, NULL, &BootOrderSize);
*BootOrder = (__typeof__(*BootOrder))GetNvramVariable (BOOT_ORDER_VAR, &gEfiGlobalVariableGuid, NULL, &BootOrderSize);
if (*BootOrder == NULL) {
DBG(" EFI_NOT_FOUND\n");
return EFI_NOT_FOUND;
@ -717,7 +717,7 @@ GetBootOption (
BootOption->BootNum = BootNum;
UnicodeSPrint (VarName, sizeof(VarName), L"Boot%04X", BootNum);
BootOption->Variable = GetNvramVariable (VarName, &gEfiGlobalVariableGuid, NULL, (UINTN *)(UINTN)(OFFSET_OF(BO_BOOT_OPTION, VariableSize) + (UINTN)BootOption));
BootOption->Variable = (__typeof__(BootOption->Variable))GetNvramVariable (VarName, &gEfiGlobalVariableGuid, NULL, (UINTN *)(UINTN)(OFFSET_OF(BO_BOOT_OPTION, VariableSize) + (UINTN)BootOption));
if (BootOption->Variable == NULL) {
return EFI_NOT_FOUND;
}

View File

@ -259,7 +259,7 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
// using AddNvramVariable content instead of calling the function to do LangLen calculation only when necessary
// Do not mess with prev-lang:kbd on UEFI systems without NVRAM emulation; it's OS X's business
KbdPrevLang = L"prev-lang:kbd";
OldData = GetNvramVariable(KbdPrevLang, &gEfiAppleBootGuid, NULL, NULL);
OldData = (__typeof__(OldData))GetNvramVariable(KbdPrevLang, &gEfiAppleBootGuid, NULL, NULL);
if (OldData == NULL) {
LangLen = 16;
VariablePtr = &gSettings.Language[15];
@ -276,7 +276,7 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
}
//#define EFI_PLATFORM_LANG_VARIABLE_NAME L"PlatformLang"
PlatformLang = GetNvramVariable(EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, NULL, NULL);
PlatformLang = (__typeof__(PlatformLang))GetNvramVariable(EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, NULL, NULL);
//
// On some platforms with missing gEfiUnicodeCollation2ProtocolGuid EFI_PLATFORM_LANG_VARIABLE_NAME is set
// to the value different from "en-...". This is not going to work with our driver UEFI Shell load failures.

View File

@ -148,7 +148,7 @@ SetNvramVariable (
UINT32 OldAttributes = 0;
//DBG ("SetNvramVariable (%s, guid, 0x%x, %d):", VariableName, Attributes, DataSize);
OldData = GetNvramVariable (VariableName, VendorGuid, &OldAttributes, &OldDataSize);
OldData = (__typeof__(OldData))GetNvramVariable (VariableName, VendorGuid, &OldAttributes, &OldDataSize);
if (OldData != NULL) {
// var already exists - check if it equal to new value
//DBG (" exists(0x%x, %d)", OldAttributes, OldDataSize);
@ -191,7 +191,7 @@ AddNvramVariable (
VOID *OldData;
//DBG ("SetNvramVariable (%s, guid, 0x%x, %d):\n", VariableName, Attributes, DataSize);
OldData = GetNvramVariable (VariableName, VendorGuid, NULL, NULL);
OldData = (__typeof__(OldData))GetNvramVariable (VariableName, VendorGuid, NULL, NULL);
if (OldData == NULL)
{
// set new value
@ -448,7 +448,7 @@ GetSmcKeys (BOOLEAN WriteToSMC)
continue; //the variable is not interesting for us
}
Data = GetNvramVariable (Name, &Guid, NULL, &DataSize);
Data = (__typeof__(Data))GetNvramVariable (Name, &Guid, NULL, &DataSize);
if (Data) {
/* UINTN Index;
DBG(" %s:", Name);
@ -712,7 +712,7 @@ GetEfiBootDeviceFromNvram ()
return EFI_SUCCESS;
}
gEfiBootDeviceData = GetNvramVariable (L"efi-boot-next-data", &gEfiAppleBootGuid, NULL, &Size);
gEfiBootDeviceData = (__typeof__(gEfiBootDeviceData))GetNvramVariable (L"efi-boot-next-data", &gEfiAppleBootGuid, NULL, &Size);
if (gEfiBootDeviceData != NULL) {
// DBG("Got efi-boot-next-data size=%d\n", Size);
if (IsDevicePathValid(gEfiBootDeviceData, Size)) {
@ -729,9 +729,9 @@ GetEfiBootDeviceFromNvram ()
EFI_STATUS Status;
Status = GetVariable2 (L"aptiofixflag", &gEfiAppleBootGuid, &Value, &Size2);
if (EFI_ERROR(Status)) {
gEfiBootDeviceData = GetNvramVariable (L"efi-boot-device-data", &gEfiAppleBootGuid, NULL, &Size);
gEfiBootDeviceData = (__typeof__(gEfiBootDeviceData))GetNvramVariable (L"efi-boot-device-data", &gEfiAppleBootGuid, NULL, &Size);
} else {
gEfiBootDeviceData = GetNvramVariable (L"specialbootdevice", &gEfiAppleBootGuid, NULL, &Size);
gEfiBootDeviceData = (__typeof__(gEfiBootDeviceData))GetNvramVariable (L"specialbootdevice", &gEfiAppleBootGuid, NULL, &Size);
}
if (gEfiBootDeviceData != NULL) {
@ -758,7 +758,7 @@ GetEfiBootDeviceFromNvram ()
// then Startup Disk sets BootCampHD to Win disk dev path.
//
if (DevicePathType(gEfiBootDeviceData) == HARDWARE_DEVICE_PATH && DevicePathSubType (gEfiBootDeviceData) == HW_MEMMAP_DP) {
gBootCampHD = GetNvramVariable (L"BootCampHD", &gEfiAppleBootGuid, NULL, &Size);
gBootCampHD = (__typeof__(gBootCampHD))GetNvramVariable (L"BootCampHD", &gEfiAppleBootGuid, NULL, &Size);
gEfiBootVolume = gBootCampHD;
if (gBootCampHD == NULL) {

View File

@ -513,7 +513,7 @@ SetBootCurrent(REFIT_MENU_ENTRY *LoadedEntry)
DBG("Can't save BootCurrent, status=%r\n", Status);
}
//Next step is rotate BootOrder to set BootNum to first place
BootOrder = GetNvramVariable (L"BootOrder", &gEfiGlobalVariableGuid, NULL, &BootOrderSize);
BootOrder = (__typeof__(BootOrder))GetNvramVariable (L"BootOrder", &gEfiGlobalVariableGuid, NULL, &BootOrderSize);
if (BootOrder == NULL) {
return;
}
@ -4302,7 +4302,7 @@ InitTheme(
}
// Try theme from nvram
if (ThemeDict == NULL && UseThemeDefinedInNVRam) {
ChosenTheme = GetNvramVariable(L"Clover.Theme", &gEfiAppleBootGuid, NULL, &Size);
ChosenTheme = (__typeof__(ChosenTheme))GetNvramVariable(L"Clover.Theme", &gEfiAppleBootGuid, NULL, &Size);
if (ChosenTheme != NULL) {
if (AsciiStrCmp (ChosenTheme, "embedded") == 0) {
goto finish;

View File

@ -260,10 +260,10 @@ GetStoredOutput()
}
DBG("found %d handles with audio\n", AudioIoHandleCount);
// Get stored device path size. First from AppleBootGuid
StoredDevicePath = GetNvramVariable(L"Clover.SoundDevice", &gEfiAppleBootGuid, NULL, &StoredDevicePathSize);
StoredDevicePath = (__typeof__(StoredDevicePath))GetNvramVariable(L"Clover.SoundDevice", &gEfiAppleBootGuid, NULL, &StoredDevicePathSize);
if (!StoredDevicePath) {
// second attempt with BootChimeGuid
StoredDevicePath = GetNvramVariable(BOOT_CHIME_VAR_DEVICE, &gBootChimeVendorVariableGuid, NULL, &StoredDevicePathSize);
StoredDevicePath = (__typeof__(StoredDevicePath))GetNvramVariable(BOOT_CHIME_VAR_DEVICE, &gBootChimeVendorVariableGuid, NULL, &StoredDevicePathSize);
if (!StoredDevicePath) {
MsgLog("No AudioIoDevice stored\n");
Status = EFI_NOT_FOUND;

View File

@ -1359,7 +1359,7 @@ VOID GetDefaultSettings()
gSettings.BooterConfig = 0;
// MemSet(gSettings.BooterCfgStr, 64, 0);
// AsciiStrCpyS(gSettings.BooterCfgStr, 64, "log=0");
CHAR8 *OldCfgStr = GetNvramVariable (L"bootercfg", &gEfiAppleBootGuid, NULL, NULL);
CHAR8 *OldCfgStr = (__typeof__(OldCfgStr))GetNvramVariable (L"bootercfg", &gEfiAppleBootGuid, NULL, NULL);
if (OldCfgStr) {
AsciiStrCpyS(gSettings.BooterCfgStr, 64, OldCfgStr);
FreePool(OldCfgStr);

View File

@ -1666,7 +1666,7 @@ VOID SetVariablesFromNvram()
// DbgHeader("SetVariablesFromNvram");
tmpString = GetNvramVariable(L"boot-args", &gEfiAppleBootGuid, NULL, &Size);
tmpString = (__typeof__(tmpString))GetNvramVariable(L"boot-args", &gEfiAppleBootGuid, NULL, &Size);
if (tmpString && (Size <= 0x1000) && (Size > 0)) {
DBG("found boot-args in NVRAM:%a, size=%d\n", tmpString, Size);
// use and forget old one
@ -1728,7 +1728,7 @@ VOID SetVariablesFromNvram()
FreePool(tmpString);
}
tmpString = GetNvramVariable(L"nvda_drv", &gEfiAppleBootGuid, NULL, NULL);
tmpString = (__typeof__(tmpString))GetNvramVariable(L"nvda_drv", &gEfiAppleBootGuid, NULL, NULL);
if (tmpString && AsciiStrCmp(tmpString, "1") == 0) {
gSettings.NvidiaWeb = TRUE;
}