diff --git a/rEFIt_UEFI/Platform/AcpiPatcher.c b/rEFIt_UEFI/Platform/AcpiPatcher.c index c4545145f..c9191453a 100644 --- a/rEFIt_UEFI/Platform/AcpiPatcher.c +++ b/rEFIt_UEFI/Platform/AcpiPatcher.c @@ -230,7 +230,7 @@ void AddDropTable(EFI_ACPI_DESCRIPTION_HEADER* Table, UINT32 Index) CopyMem(&OTID[0], &Table->OemTableId, 8); //DBG(" Found table: %a %a len=%d\n", sign, OTID, (INT32)Table->Length); DBG(" - [%02d]: %a %a len=%d\n", Index, sign, OTID, (INT32)Table->Length); - ACPI_DROP_TABLE* DropTable = AllocateZeroPool(sizeof(ACPI_DROP_TABLE)); + ACPI_DROP_TABLE* DropTable = (__typeof__(DropTable))AllocateZeroPool(sizeof(ACPI_DROP_TABLE)); DropTable->Signature = Table->Signature; DropTable->TableId = Table->OemTableId; DropTable->Length = Table->Length; @@ -782,7 +782,7 @@ VOID MarkTableAsSaved(VOID *TableEntry) //DBG(" Allocaing mSavedTables"); mSavedTablesEntries = SAVED_TABLES_ALLOC_ENTRIES; mSavedTablesNum = 0; - mSavedTables = AllocateZeroPool(sizeof(*mSavedTables) * mSavedTablesEntries); + mSavedTables = (__typeof__(mSavedTables))AllocateZeroPool(sizeof(*mSavedTables) * mSavedTablesEntries); if (mSavedTables == NULL) { return; } @@ -804,7 +804,7 @@ VOID MarkTableAsSaved(VOID *TableEntry) if (mSavedTablesNum + 1 >= mSavedTablesEntries) { // not enough space //DBG(" - extending mSavedTables from %d", mSavedTablesEntries); - mSavedTables = ReallocatePool( + mSavedTables = (__typeof__(mSavedTables))ReallocatePool( sizeof(*mSavedTables) * mSavedTablesEntries, sizeof(*mSavedTables) * (mSavedTablesEntries + SAVED_TABLES_ALLOC_ENTRIES), mSavedTables @@ -1186,7 +1186,7 @@ EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE* GetFadt() // EFI_STATUS Status; - RsdPtr = FindAcpiRsdPtr(); + RsdPtr = (__typeof(RsdPtr))FindAcpiRsdPtr(); if (RsdPtr == NULL) { /*Status = */EfiGetSystemConfigurationTable (&gEfiAcpi20TableGuid, (VOID **)&RsdPtr); if (RsdPtr == NULL) { @@ -2078,7 +2078,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion) // XsdtReplaceSizes array is used to keep track of allocations for the merged tables, // as those tables may need to be freed if patched later. - XsdtReplaceSizes = AllocateZeroPool(XsdtTableCount() * sizeof(*XsdtReplaceSizes)); + XsdtReplaceSizes = (__typeof__(XsdtReplaceSizes))AllocateZeroPool(XsdtTableCount() * sizeof(*XsdtReplaceSizes)); // Load merged ACPI files from ACPI/patched LoadAllPatchedAML(AcpiOemPath, AUTOMERGE_PASS1); diff --git a/rEFIt_UEFI/Platform/AmlGenerator.c b/rEFIt_UEFI/Platform/AmlGenerator.c index 0fed1bedb..8f8363072 100644 --- a/rEFIt_UEFI/Platform/AmlGenerator.c +++ b/rEFIt_UEFI/Platform/AmlGenerator.c @@ -91,7 +91,7 @@ AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, /* CONST*/ UINT8* buffer, UINT32 si { node->Type = AML_CHUNK_NONE; node->Length = (UINT16)size; - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); CopyMem(node->Buffer, buffer, node->Length); } @@ -107,7 +107,7 @@ AML_CHUNK* aml_add_byte(AML_CHUNK* parent, UINT8 value) node->Type = AML_CHUNK_BYTE; node->Length = 1; - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); node->Buffer[0] = value; } @@ -122,7 +122,7 @@ AML_CHUNK* aml_add_word(AML_CHUNK* parent, UINT16 value) { node->Type = AML_CHUNK_WORD; node->Length = 2; - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); node->Buffer[0] = value & 0xff; node->Buffer[1] = value >> 8; } @@ -138,7 +138,7 @@ AML_CHUNK* aml_add_dword(AML_CHUNK* parent, UINT32 value) { node->Type = AML_CHUNK_DWORD; node->Length = 4; - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); node->Buffer[0] = value & 0xff; node->Buffer[1] = (value >> 8) & 0xff; node->Buffer[2] = (value >> 16) & 0xff; @@ -156,7 +156,7 @@ AML_CHUNK* aml_add_qword(AML_CHUNK* parent, UINT64 value) { node->Type = AML_CHUNK_QWORD; node->Length = 8; - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); node->Buffer[0] = value & 0xff; node->Buffer[1] = RShiftU64(value, 8) & 0xff; node->Buffer[2] = RShiftU64(value, 16) & 0xff; @@ -206,7 +206,7 @@ UINT32 aml_fill_name(AML_CHUNK* node, /* CONST*/ CHAR8* name) if (count == 1) { node->Length = (UINT16)(4 + root); - node->Buffer = AllocateZeroPool (node->Length+4); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length+4); CopyMem(node->Buffer, name, 4 + root); offset += 4 + root; return (UINT32)offset; @@ -215,7 +215,7 @@ UINT32 aml_fill_name(AML_CHUNK* node, /* CONST*/ CHAR8* name) if (count == 2) { node->Length = 2 + 8; - node->Buffer = AllocateZeroPool (node->Length+4); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length+4); node->Buffer[offset++] = 0x5c; // Root Char node->Buffer[offset++] = 0x2e; // Double name CopyMem(node->Buffer+offset, name + root, 8); @@ -224,7 +224,7 @@ UINT32 aml_fill_name(AML_CHUNK* node, /* CONST*/ CHAR8* name) } node->Length = (UINT16)(3 + (count << 2)); - node->Buffer = AllocateZeroPool (node->Length+4); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length+4); node->Buffer[offset++] = 0x5c; // Root Char node->Buffer[offset++] = 0x2f; // Multi name node->Buffer[offset++] = (CHAR8)count; // Names count @@ -288,7 +288,7 @@ AML_CHUNK* aml_add_package(AML_CHUNK* parent) node->Type = AML_CHUNK_PACKAGE; node->Length = 1; - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); } return node; @@ -303,7 +303,7 @@ AML_CHUNK* aml_add_alias(AML_CHUNK* parent, /* CONST*/ CHAR8* name1, /* CONST*/ node->Type = AML_CHUNK_ALIAS; node->Length = 8; - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); aml_fill_simple_name(node->Buffer, name1); aml_fill_simple_name(node->Buffer+4, name2); } @@ -385,7 +385,7 @@ AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, /* CONST*/ UINT8* data, UINT32 INTN offset=0; node->Type = AML_CHUNK_BUFFER; node->Length = (UINT8)(size + 2); - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); node->Buffer[offset++] = AML_CHUNK_BYTE; //0x0A node->Buffer[offset++] = (CHAR8)size; CopyMem(node->Buffer+offset, data, node->Length); @@ -394,7 +394,7 @@ AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, /* CONST*/ UINT8* data, UINT32 return node; } -AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, /* CONST*/ CHAR8* StringBuf) +AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, CONST CHAR8* StringBuf) { AML_CHUNK* node = aml_create_node(parent); @@ -404,7 +404,7 @@ AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, /* CONST*/ CHAR8* StringBuf) UINTN len = AsciiStrLen(StringBuf); node->Type = AML_CHUNK_BUFFER; node->Length = (UINT8)(len + 3); - node->Buffer = AllocateZeroPool (node->Length); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (node->Length); node->Buffer[offset++] = AML_CHUNK_BYTE; node->Buffer[offset++] = (CHAR8)(len + 1); CopyMem(node->Buffer+offset, StringBuf, len); @@ -423,7 +423,7 @@ AML_CHUNK* aml_add_string(AML_CHUNK* parent, /* CONST*/ CHAR8* StringBuf) INTN len = AsciiStrLen(StringBuf); node->Type = AML_CHUNK_STRING; node->Length = (UINT8)(len + 1); - node->Buffer = AllocateZeroPool (len + 1); + node->Buffer = (__typeof__(node->Buffer))AllocateZeroPool (len + 1); CopyMem(node->Buffer, StringBuf, len); // node->Buffer[len] = '\0'; } diff --git a/rEFIt_UEFI/Platform/AmlGenerator.h b/rEFIt_UEFI/Platform/AmlGenerator.h index 071138d46..179388f47 100644 --- a/rEFIt_UEFI/Platform/AmlGenerator.h +++ b/rEFIt_UEFI/Platform/AmlGenerator.h @@ -40,7 +40,7 @@ UINT32 aml_write_size(UINT32 size, CHAR8* buffer, UINT32 offset); // add by pcj AML_CHUNK* aml_add_string(AML_CHUNK* parent, /* CONST*/ CHAR8* string); AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, /* CONST*/ UINT8* data,UINT32 size); -AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, /* CONST*/ CHAR8* string); +AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, CONST CHAR8* string); AML_CHUNK* aml_add_device(AML_CHUNK* parent, /* CONST*/ CHAR8* name); AML_CHUNK* aml_add_local0(AML_CHUNK* parent); AML_CHUNK* aml_add_store(AML_CHUNK* parent); diff --git a/rEFIt_UEFI/Platform/BdsConnect.c b/rEFIt_UEFI/Platform/BdsConnect.c index 8416caf67..669840b7f 100644 --- a/rEFIt_UEFI/Platform/BdsConnect.c +++ b/rEFIt_UEFI/Platform/BdsConnect.c @@ -311,7 +311,7 @@ EFI_STATUS ScanDeviceHandles(EFI_HANDLE ControllerHandle, Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, HandleCount, HandleBuffer); if (EFI_ERROR (Status)) goto Error; - *HandleType = AllocatePool (*HandleCount * sizeof (UINT32)); + *HandleType = (__typeof__(*HandleType))AllocatePool (*HandleCount * sizeof (UINT32)); if (*HandleType == NULL) goto Error; for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) { @@ -459,7 +459,7 @@ EFI_STATUS BdsLibConnectMostlyAllEfi() if (!Parent) { if (HandleType[Index] & EFI_HANDLE_TYPE_DEVICE_HANDLE) { - Status = gBS->HandleProtocol (AllHandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID*)&PciIo); + Status = gBS->HandleProtocol (AllHandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID**)&PciIo); if (!EFI_ERROR (Status)) { Status = PciIo->Pci.Read (PciIo,EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci); if (!EFI_ERROR (Status)) { diff --git a/rEFIt_UEFI/Platform/BootOptions.c b/rEFIt_UEFI/Platform/BootOptions.c index 698c964aa..2364dc6c0 100644 --- a/rEFIt_UEFI/Platform/BootOptions.c +++ b/rEFIt_UEFI/Platform/BootOptions.c @@ -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; @@ -413,7 +413,7 @@ AddToBootOrder ( // // Make new order buffer with space for our option // - BootOrderNew = AllocateZeroPool ((BootOrderLen + 1) * sizeof(UINT16)); + BootOrderNew = (__typeof__(BootOrderNew))AllocateZeroPool ((BootOrderLen + 1) * sizeof(UINT16)); if (BootOrderNew == NULL) { DBG("AddToBootOrder: EFI_OUT_OF_RESOURCES\n"); if (BootOrder) { @@ -667,7 +667,7 @@ CompileBootOption ( + BootOption->DescriptionSize + BootOption->FilePathListLength + BootOption->OptionalDataSize; - BootOption->Variable = AllocateZeroPool (BootOption->VariableSize); + BootOption->Variable = (__typeof__(BootOption->Variable))AllocateZeroPool (BootOption->VariableSize); if (BootOption->Variable == NULL) { DBG("CompileBootOption: EFI_OUT_OF_RESOURCES\n"); return EFI_OUT_OF_RESOURCES; @@ -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; } diff --git a/rEFIt_UEFI/Platform/DataHubCpu.c b/rEFIt_UEFI/Platform/DataHubCpu.c index cb0acae77..2b71c6b95 100644 --- a/rEFIt_UEFI/Platform/DataHubCpu.c +++ b/rEFIt_UEFI/Platform/DataHubCpu.c @@ -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. @@ -464,10 +464,10 @@ SetupDataForOSX(BOOLEAN Hibernate) // Locate DataHub Protocol Status = gBS->LocateProtocol(&gEfiDataHubProtocolGuid, NULL, (VOID**)&gDataHub); if (!EFI_ERROR(Status)) { - ProductName = AllocateZeroPool(128); + ProductName = (__typeof__(ProductName))AllocateZeroPool(128); AsciiStrToUnicodeStrS(gSettings.ProductName, ProductName, 64); - SerialNumber = AllocateZeroPool(128); + SerialNumber = (__typeof__(SerialNumber))AllocateZeroPool(128); AsciiStrToUnicodeStrS(gSettings.SerialNr, SerialNumber, 64); LogDataHub(&gEfiProcessorSubClassGuid, L"FSBFrequency", &FrontSideBus, sizeof(UINT64)); diff --git a/rEFIt_UEFI/Platform/DevicePath.c b/rEFIt_UEFI/Platform/DevicePath.c index c90b1ece8..c16888b65 100644 --- a/rEFIt_UEFI/Platform/DevicePath.c +++ b/rEFIt_UEFI/Platform/DevicePath.c @@ -42,7 +42,7 @@ CatPrint ( VA_LIST Args; UINTN StringSize; - AppendStr = AllocateZeroPool (0x1000); + AppendStr = (__typeof__(AppendStr))AllocateZeroPool (0x1000); if (AppendStr == NULL) { return Str->Str; } @@ -52,13 +52,13 @@ CatPrint ( VA_END (Args); if (NULL == Str->Str) { StringSize = StrSize (AppendStr); - Str->Str = AllocateZeroPool (StringSize); + Str->Str = (__typeof__(Str->Str))AllocateZeroPool (StringSize); // ASSERT (Str->Str != NULL); } else { StringSize = StrSize (AppendStr); StringSize += (StrSize (Str->Str) - sizeof (UINT16)); - Str->Str = ReallocatePool ( + Str->Str = (__typeof__(Str->Str))ReallocatePool ( StrSize (Str->Str), StringSize, Str->Str @@ -1610,7 +1610,7 @@ DevicePathToStr ( Done: NewSize = (Str.Len + 1) * sizeof (CHAR16); - Str.Str = ReallocatePool (NewSize, NewSize, Str.Str); + Str.Str = (__typeof__(Str.Str))ReallocatePool (NewSize, NewSize, Str.Str); // ASSERT (Str.Str != NULL); if (!Str.Str) { return NULL; diff --git a/rEFIt_UEFI/Platform/Edid.c b/rEFIt_UEFI/Platform/Edid.c index b9db9bc57..775d135d8 100644 --- a/rEFIt_UEFI/Platform/Edid.c +++ b/rEFIt_UEFI/Platform/Edid.c @@ -42,7 +42,7 @@ InitializeEdidOverride () EFI_STATUS Status; EFI_EDID_OVERRIDE_PROTOCOL *EdidOverride; - EdidOverride = AllocateCopyPool(sizeof(EFI_EDID_OVERRIDE_PROTOCOL), &gEdidOverride); + EdidOverride = (__typeof__(EdidOverride))AllocateCopyPool(sizeof(EFI_EDID_OVERRIDE_PROTOCOL), &gEdidOverride); Status = gBS->InstallMultipleProtocolInterfaces ( &gImageHandle, @@ -69,7 +69,7 @@ UINT8* getCurrentEdid (VOID) if (!EFI_ERROR (Status)) { DBG(" size=%d", EdidProtocol->SizeOfEdid); if (EdidProtocol->SizeOfEdid > 0) { - Edid = AllocateCopyPool (EdidProtocol->SizeOfEdid, EdidProtocol->Edid); + Edid = (__typeof__(Edid))AllocateCopyPool (EdidProtocol->SizeOfEdid, EdidProtocol->Edid); } } DBG(" %a\n", Edid != NULL ? "found" : "not found"); @@ -119,7 +119,7 @@ EFI_STATUS GetEdidDiscovered(VOID) if (N == 0) { return EFI_NOT_FOUND; } - gSettings.CustomEDID = AllocateAlignedPages(EFI_SIZE_TO_PAGES(N), 128); + gSettings.CustomEDID = (__typeof__(gSettings.CustomEDID))AllocateAlignedPages(EFI_SIZE_TO_PAGES(N), 128); CopyMem(gSettings.CustomEDID, EdidDiscovered->Edid, N); DebugDumpEDID("--- Discovered EDID Table", N); } diff --git a/rEFIt_UEFI/Platform/FixBiosDsdt.c b/rEFIt_UEFI/Platform/FixBiosDsdt.c index 7238eb833..b3c24d09e 100644 --- a/rEFIt_UEFI/Platform/FixBiosDsdt.c +++ b/rEFIt_UEFI/Platform/FixBiosDsdt.c @@ -884,7 +884,7 @@ VOID findCPU(UINT8* dsdt, UINT32 length) if (acpi_cpu_score) { FreePool(acpi_cpu_score); } - acpi_cpu_score = AllocateZeroPool(128); + acpi_cpu_score = (__typeof__(acpi_cpu_score))AllocateZeroPool(128); acpi_cpu_count = 0; // 5B 83 41 0C 5C 2E 5F 50 52 5F 43 50 55 30 01 10 // 10 00 00 06 @@ -1034,7 +1034,7 @@ VOID findCPU(UINT8* dsdt, UINT32 length) } if (add_name) { - acpi_cpu_name[acpi_cpu_count] = AllocateZeroPool(5); + acpi_cpu_name[acpi_cpu_count] = (__typeof__(acpi_cpu_name[acpi_cpu_count]))AllocateZeroPool(5); CopyMem(acpi_cpu_name[acpi_cpu_count], dsdt+offset, 4); acpi_cpu_processor_id[acpi_cpu_count] = dsdt[offset + 4]; i = offset + 5; @@ -1056,7 +1056,7 @@ VOID findCPU(UINT8* dsdt, UINT32 length) if (!acpi_cpu_count) { for (i=0; i < acpi_cpu_max; i++) { - acpi_cpu_name[i] = AllocateZeroPool(5); + acpi_cpu_name[i] = (__typeof__(acpi_cpu_name[i]))AllocateZeroPool(5); AsciiSPrint(acpi_cpu_name[i], 5, "CPU%1x", i); acpi_cpu_processor_id[i] = (UINT8)(i & 0x7F); } @@ -2370,7 +2370,7 @@ UINT32 FIXLPCB (UINT8 *dsdt, UINT32 len) continue; } LPCBSIZE = get_size(dsdt, LPCBADR); - device_name[3] = AllocateZeroPool(5); + device_name[3] = (__typeof__(device_name[3]))AllocateZeroPool(5); CopyMem(device_name[3], dsdt + j, 4); MsgLog("found LPCB device NAME(_ADR,0x001F0000) at %x And Name is %a\n", j, device_name[3]); @@ -2424,7 +2424,7 @@ UINT32 FIXLPCB (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - lpcb = AllocateZeroPool(root->Size); + lpcb = (__typeof__(lpcb))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, lpcb, 0); aml_destroy_node(root); @@ -2683,7 +2683,7 @@ Skip_DSM: //now insert video DBG("now inserting Video device\n"); aml_calculate_size(root); - display = AllocateZeroPool(root->Size); + display = (__typeof__(display))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, display, 0); aml_destroy_node(root); @@ -2791,7 +2791,7 @@ UINT32 AddHDMI (UINT8 *dsdt, UINT32 len) if (!devadr1) { continue; } - device_name[11] = AllocateZeroPool(5); + device_name[11] = (__typeof__(device_name[11]))AllocateZeroPool(5); CopyMem(device_name[11], dsdt+k, 4); DBG("found HDMI device [0x%08x:%x] at %x and Name is %a\n", HDMIADR1, HDMIADR2, devadr1, device_name[11]); @@ -2884,7 +2884,7 @@ UINT32 AddHDMI (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - hdmi = AllocateZeroPool(root->Size); + hdmi = (__typeof__(hdmi))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, hdmi, 0); aml_destroy_node(root); @@ -2966,7 +2966,7 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card) continue; } - device_name[1] = AllocateZeroPool(5); + device_name[1] = (__typeof__(device_name[1]))AllocateZeroPool(5); CopyMem(device_name[1], dsdt+k, 4); DBG("found NetWork device [0x%08x:%x] at %x and Name is %a\n", NetworkADR1[card], NetworkADR2[card], NetworkADR, device_name[1]); @@ -3083,7 +3083,7 @@ UINT32 FIXNetwork (UINT8 *dsdt, UINT32 len, UINT32 card) } // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - network = AllocateZeroPool(root->Size); + network = (__typeof__(network))AllocateZeroPool(root->Size); if (!network) { return len; } @@ -3166,7 +3166,7 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len) if (!ArptADR) { continue; } - device_name[9] = AllocateZeroPool(5); + device_name[9] = (__typeof__(device_name[9]))AllocateZeroPool(5); CopyMem(device_name[9], dsdt+k, 4); DBG("found Airport device [%08x:%x] at %x And Name is %a\n", ArptADR1, ArptADR2, ArptADR, device_name[9]); @@ -3280,7 +3280,7 @@ UINT32 FIXAirport (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - network = AllocateZeroPool(root->Size); + network = (__typeof__(network))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, network, 0); aml_destroy_node(root); @@ -3466,7 +3466,7 @@ UINT32 AddMCHC (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) */ aml_calculate_size(root); - mchc = AllocateZeroPool(root->Size); + mchc = (__typeof__(mchc))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, mchc, 0); aml_destroy_node(root); @@ -3553,7 +3553,7 @@ UINT32 AddIMEI (UINT8 *dsdt, UINT32 len) } aml_calculate_size(root); - imei = AllocateZeroPool(root->Size); + imei = (__typeof__(imei))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, imei, 0); aml_destroy_node(root); @@ -3611,7 +3611,7 @@ UINT32 FIXFirewire (UINT8 *dsdt, UINT32 len) continue; } - device_name[2] = AllocateZeroPool(5); + device_name[2] = (__typeof__(device_name[2]))AllocateZeroPool(5); CopyMem(device_name[2], dsdt+k, 4); DBG("found Firewire device NAME(_ADR,0x%08x) at %x And Name is %a\n", FirewireADR2, k, device_name[2]); @@ -3701,7 +3701,7 @@ UINT32 FIXFirewire (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - firewire = AllocateZeroPool(root->Size); + firewire = (__typeof__(firewire))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, firewire, 0); aml_destroy_node(root); @@ -3754,7 +3754,7 @@ UINT32 AddHDEF (UINT8 *dsdt, UINT32 len, CHAR8* OSVersion) } // BridgeSize = get_size(dsdt, HDAADR); - device_name[4] = AllocateZeroPool(5); + device_name[4] = (__typeof__(device_name[4]))AllocateZeroPool(5); CopyMem(device_name[4], dsdt+i, 4); DBG("found HDA device NAME(_ADR,0x%08x) And Name is %a\n", HDAADR1, device_name[4]); @@ -3822,7 +3822,7 @@ UINT32 AddHDEF (UINT8 *dsdt, UINT32 len, CHAR8* OSVersion) */ } aml_calculate_size(root); - hdef = AllocateZeroPool(root->Size); + hdef = (__typeof__(hdef))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, hdef, 0); aml_destroy_node(root); @@ -3895,7 +3895,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - USBDATA1 = AllocateZeroPool(root->Size); + USBDATA1 = (__typeof__(USBDATA1))AllocateZeroPool(root->Size); size1 = root->Size; // DBG("USB1 code size = 0x%08x\n", size1); aml_write_node(root, USBDATA1, 0); @@ -3968,7 +3968,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root1); - USBDATA2 = AllocateZeroPool(root1->Size); + USBDATA2 = (__typeof__(USBDATA2))AllocateZeroPool(root1->Size); size2 = root1->Size; // DBG("USB2 code size = 0x%08x\n", size2); aml_write_node(root1, USBDATA2, 0); @@ -3976,7 +3976,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len) //NFORCE_USB_START -- already done Intel or NForce same USBDATA2 /* aml_calculate_size(root1); - USBDATA4 = AllocateZeroPool(root1->Size); + USBDATA4 = (__typeof__(USBDATA4))AllocateZeroPool(root1->Size); size4 = root1->Size; DBG("USB OHCI code size = 0x%08x\n", size4); aml_write_node(root1, USBDATA4, 0); @@ -4017,7 +4017,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root1); - USBDATA3 = AllocateZeroPool(root1->Size); + USBDATA3 = (__typeof__(USBDATA3))AllocateZeroPool(root1->Size); size3 = root1->Size; // DBG("USB3 code size = 0x%08x\n", size3); aml_write_node(root1, USBDATA3, 0); @@ -4032,7 +4032,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len) for (j = 0x20; len >= 4 && j < len - 4; j++) { if (CmpAdr(dsdt, j, USBADR[i])) { //j+4 -> _ADR XhciName = FALSE; - UsbName[i] = AllocateZeroPool(5); + UsbName[i] = (__typeof__(UsbName[i]))AllocateZeroPool(5); // DBG("found USB at 0x%x\n", j); adr1 = devFind(dsdt, j + 2); if (!adr1) { @@ -4049,7 +4049,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len) continue; } - device_name[10] = AllocateZeroPool(5); + device_name[10] = (__typeof__(device_name[10]))AllocateZeroPool(5); CopyMem(device_name[10], dsdt+k, 4); DBG("found USB device [%08x:%x] at %x and Name was %a ->", USBADR[i], USBADR2[i], k, device_name[10]); @@ -4169,7 +4169,7 @@ UINT32 FIXUSB (UINT8 *dsdt, UINT32 len) } //NFORCE_USB_START else if (CmpAdr(dsdt, j, USBADR3[i])) { - UsbName[i] = AllocateZeroPool(5); + UsbName[i] = (__typeof__(UsbName[i]))AllocateZeroPool(5); CopyMem(UsbName[i], dsdt+j, 4); adr1 = devFind(dsdt, j); @@ -4374,7 +4374,7 @@ UINT32 FIXIDE (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - ide = AllocateZeroPool(root->Size); + ide = (__typeof__(ide))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, ide, 0); aml_destroy_node(root); @@ -4484,7 +4484,7 @@ UINT32 FIXSATAAHCI (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - sata = AllocateZeroPool(root->Size); + sata = (__typeof__(sata))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, sata, 0); aml_destroy_node(root); @@ -4580,7 +4580,7 @@ UINT32 FIXSATA (UINT8 *dsdt, UINT32 len) // finish Method(_DSM,4,NotSerialized) aml_calculate_size(root); - sata = AllocateZeroPool(root->Size); + sata = (__typeof__(sata))AllocateZeroPool(root->Size); sizeoffset = root->Size; aml_write_node(root, sata, 0); aml_destroy_node(root); @@ -4923,7 +4923,7 @@ UINT32 FIXOTHER (UINT8 *dsdt, UINT32 len) for (i=0; inext = gRegions; @@ -5234,7 +5234,7 @@ BOOLEAN CmpFullName(UINT8* Table, UINTN Len, ACPI_NAME_LIST *Bridge) if (NameLen < 4) { return FALSE; } - Name = AllocateCopyPool(NameLen + 1, Table); + Name = (__typeof__(Name))AllocateCopyPool(NameLen + 1, Table); Name[NameLen] = '\0'; i = NameLen - 4; while (Bridge && (i >= 0)) { diff --git a/rEFIt_UEFI/Platform/HdaCodecDump.c b/rEFIt_UEFI/Platform/HdaCodecDump.c index 721f5e0bc..97ca48aec 100644 --- a/rEFIt_UEFI/Platform/HdaCodecDump.c +++ b/rEFIt_UEFI/Platform/HdaCodecDump.c @@ -420,7 +420,7 @@ EFI_STATUS SaveHdaDumpBin() { HdaCodec.WidgetCount = AudioFuncGroup->WidgetsCount; // Allocate space for codec data - HdaCodecData = AllocateZeroPool(HdaCodecDataSize); + HdaCodecData = (__typeof__(HdaCodecData))AllocateZeroPool(HdaCodecDataSize); HdaCodecDataPtr = HdaCodecData; if (!HdaCodecData) diff --git a/rEFIt_UEFI/Platform/Hibernate.c b/rEFIt_UEFI/Platform/Hibernate.c index 6148108d4..6b61ab329 100644 --- a/rEFIt_UEFI/Platform/Hibernate.c +++ b/rEFIt_UEFI/Platform/Hibernate.c @@ -423,7 +423,7 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume, if (VolNameEnd) { VolNameSize = (VolNameEnd - VolNameStart + 1) * sizeof(CHAR16); if (VolNameSize > 0) { - VolName = AllocateZeroPool(VolNameSize); + VolName = (__typeof__(VolName))AllocateZeroPool(VolNameSize); } } } @@ -523,7 +523,7 @@ GetSleepImagePosition (IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume) // We want to read the first 512 bytes from sleepimage BufferSize = 512; - Buffer = AllocatePool(BufferSize); + Buffer = (__typeof__(Buffer))AllocatePool(BufferSize); if (Buffer == NULL) { DBG(" could not allocate buffer for sleepimage\n"); return 0; @@ -611,7 +611,7 @@ IsSleepImageValidBySleepTime (IN REFIT_VOLUME *Volume) // use 4KB aligned page to avoid possible issues with BlockIo buffer alignment BlockIo = Volume->BlockIO; Pages = EFI_SIZE_TO_PAGES(BlockIo->Media->BlockSize); - Buffer = AllocatePages(Pages); + Buffer = (__typeof__(Buffer))AllocatePages(Pages); if (Buffer == NULL) { return FALSE; } diff --git a/rEFIt_UEFI/Platform/Injectors.c b/rEFIt_UEFI/Platform/Injectors.c index f29317ca2..90a550a9f 100644 --- a/rEFIt_UEFI/Platform/Injectors.c +++ b/rEFIt_UEFI/Platform/Injectors.c @@ -250,7 +250,7 @@ OSInfoOSNameImpl ( // for future developers // this variable can be used at OnExitBoootServices, // as it will be set by boot.efi - BootOSName = AllocateCopyPool(AsciiStrLen(OSName) + 1, (VOID*)OSName); + BootOSName = (__typeof__(BootOSName))AllocateCopyPool(AsciiStrLen(OSName) + 1, (VOID*)OSName); EfiNamedEventSignal (&gAppleOsLoadedNamedEventGuid); } diff --git a/rEFIt_UEFI/Platform/LegacyBoot.c b/rEFIt_UEFI/Platform/LegacyBoot.c index 4a5322af9..4f76a6bba 100644 --- a/rEFIt_UEFI/Platform/LegacyBoot.c +++ b/rEFIt_UEFI/Platform/LegacyBoot.c @@ -238,7 +238,7 @@ EFI_STATUS GetBiosDriveCRC32(UINT8 DriveNum, // read first 2 sectors Status = BiosReadSectorsFromDrive(DriveNum, 0, 2, Dap, Buffer); if (!EFI_ERROR(Status)) { - *DriveCRC32 = GetCrc32(Buffer, 2 * 512); + *DriveCRC32 = GetCrc32((UINT8*)Buffer, 2 * 512); //gBS->CalculateCrc32(Buffer, 2 * 512, DriveCRC32); DBG("Bios drive CRC32 = 0x%x\n", *DriveCRC32); } @@ -310,7 +310,7 @@ EFI_STATUS bootElTorito(REFIT_VOLUME* volume) IA32_REGISTER_SET Regs; //UINTN LogSize; - sectorBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (2048), 64); + sectorBuffer = (__typeof__(sectorBuffer))AllocateAlignedPages (EFI_SIZE_TO_PAGES (2048), 64); krnMemoryTop = addrRealFromSegOfs(0xA000, 0x0000); addrEnablePaging(0); @@ -650,7 +650,7 @@ EFI_STATUS bootPBRtest(REFIT_VOLUME* volume) return Status; } - mBootSector = AllocateAlignedPages(1, 16); + mBootSector = (__typeof__(mBootSector))AllocateAlignedPages(1, 16); Status = pDisk->ReadBlocks(pDisk, pDisk->Media->MediaId, 0, 2*512, mBootSector); CopyMem(pBootSector, mBootSector, 1024); DBG("PBR after readDisk:\n"); @@ -900,7 +900,7 @@ EFI_STATUS bootPBR(REFIT_VOLUME* volume, BOOLEAN SataReset) // // read partition boot record and copy it to BIOS boot area 0000:07C00 // - mBootSector = AllocatePages(1); + mBootSector = (__typeof__(mBootSector))AllocatePages(1); Status = pDisk->ReadBlocks(pDisk, pDisk->Media->MediaId, 0, 1*512, mBootSector); CopyMem(pBootSector, mBootSector, 1*512); DBG("PBR:\n"); diff --git a/rEFIt_UEFI/Platform/Nvram.c b/rEFIt_UEFI/Platform/Nvram.c index 693f727d4..29a65e7d2 100644 --- a/rEFIt_UEFI/Platform/Nvram.c +++ b/rEFIt_UEFI/Platform/Nvram.c @@ -112,7 +112,7 @@ VOID *GetNvramVariable ( // // Allocate the buffer to return // - Data = AllocateZeroPool (IntDataSize + 1); + Data = (__typeof__(Data))AllocateZeroPool (IntDataSize + 1); if (Data != NULL) { // // Read variable into the allocated buffer. @@ -135,11 +135,11 @@ VOID *GetNvramVariable ( /** Sets NVRAM variable. Does nothing if variable with the same data and attributes already exists. */ EFI_STATUS SetNvramVariable ( - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN CONST VOID *Data ) { //EFI_STATUS Status; @@ -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); @@ -174,7 +174,7 @@ SetNvramVariable ( //DBG (" -> writing new (%r)\n", Status); //return Status; - return gRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data); + return gRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, (VOID*)Data); // CONST missing in EFI_SET_VARIABLE->SetVariable } @@ -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 @@ -285,7 +285,7 @@ ResetNativeNvram () //DbgHeader("ResetNativeNvram: cleanup NVRAM variables"); NameSize = sizeof (CHAR16); - Name = AllocateZeroPool (NameSize); + Name = (__typeof__(Name))AllocateZeroPool (NameSize); if (Name == NULL) { return Status; } @@ -300,7 +300,7 @@ ResetNativeNvram () NewNameSize = NameSize; Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid); if (Status == EFI_BUFFER_TOO_SMALL) { - Name = ReallocatePool (NameSize, NewNameSize, Name); + Name = (__typeof__(Name))ReallocatePool (NameSize, NewNameSize, Name); if (Name == NULL) { return Status; } @@ -414,7 +414,7 @@ GetSmcKeys (BOOLEAN WriteToSMC) NameSize = sizeof (CHAR16); - Name = AllocateZeroPool (NameSize); + Name = (__typeof__(Name))AllocateZeroPool (NameSize); if (Name == NULL) { return; } @@ -431,7 +431,7 @@ GetSmcKeys (BOOLEAN WriteToSMC) NewNameSize = NameSize; Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid); if (Status == EFI_BUFFER_TOO_SMALL) { - Name = ReallocatePool (NameSize, NewNameSize, Name); + Name = (__typeof__(Name))ReallocatePool (NameSize, NewNameSize, Name); if (Name == NULL) { return; //if something wrong then just do nothing } @@ -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) { @@ -782,7 +782,7 @@ GetEfiBootDeviceFromNvram () gEfiBootLoaderPath = NULL; FileDevPath = (FILEPATH_DEVICE_PATH *)FindDevicePathNodeWithType (gEfiBootVolume, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP); if (FileDevPath != NULL) { - gEfiBootLoaderPath = AllocateCopyPool (StrSize(FileDevPath->PathName), FileDevPath->PathName); + gEfiBootLoaderPath = (__typeof__(gEfiBootLoaderPath))AllocateCopyPool (StrSize(FileDevPath->PathName), FileDevPath->PathName); // copy DevPath and write end of path node after in place of file path node gEfiBootVolume = DuplicateDevicePath (gEfiBootVolume); FileDevPath = (FILEPATH_DEVICE_PATH *)FindDevicePathNodeWithType (gEfiBootVolume, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP); @@ -799,7 +799,7 @@ GetEfiBootDeviceFromNvram () // Guid = FindGPTPartitionGuidInDevicePath (gEfiBootVolume); if (Guid != NULL) { - gEfiBootDeviceGuid = AllocatePool (sizeof(EFI_GUID)); + gEfiBootDeviceGuid = (__typeof__(gEfiBootDeviceGuid))AllocatePool (sizeof(EFI_GUID)); if (gEfiBootDeviceGuid != NULL) { CopyMem (gEfiBootDeviceGuid, Guid, sizeof(EFI_GUID)); DBG (" - Guid = %g\n", gEfiBootDeviceGuid); @@ -1034,7 +1034,7 @@ PutNvramPlistToRtVars () // element Value = ValTag->string; - Size = AsciiStrLen (Value); + Size = AsciiStrLen((CONST CHAR8*)Value); if (!GlobalConfig.DebugLog) { DBG ("String: Size = %d, Val = '%a'\n", Size, Value); } @@ -1377,7 +1377,7 @@ EFI_STATUS SetStartupDiskVolume ( ""; Size = AsciiStrLen (EfiBootDeviceTmpl) + 36; - EfiBootDevice = AllocateZeroPool(AsciiStrLen (EfiBootDeviceTmpl) + 36); + EfiBootDevice = (__typeof__(EfiBootDevice))AllocateZeroPool(AsciiStrLen (EfiBootDeviceTmpl) + 36); AsciiSPrint (EfiBootDevice, Size, EfiBootDeviceTmpl, Guid); Size = AsciiStrLen (EfiBootDevice); DBG (" * efi-boot-device: %a\n", EfiBootDevice); diff --git a/rEFIt_UEFI/Platform/Platform.h b/rEFIt_UEFI/Platform/Platform.h index b73734d3e..9c2f23ec6 100644 --- a/rEFIt_UEFI/Platform/Platform.h +++ b/rEFIt_UEFI/Platform/Platform.h @@ -713,15 +713,15 @@ struct Symbol { typedef struct Symbol Symbol, *SymbolPtr; -typedef struct { +typedef struct TagStruct { UINTN type; CHAR8 *string; UINT8 *data; UINTN dataLen; UINTN offset; - VOID *tag; - VOID *tagNext; + struct TagStruct *tag; + struct TagStruct *tagNext; } TagStruct, *TagPtr; @@ -1950,11 +1950,11 @@ AddNvramVariable ( EFI_STATUS SetNvramVariable ( - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN CONST VOID *Data ); EFI_STATUS diff --git a/rEFIt_UEFI/Platform/Settings.c b/rEFIt_UEFI/Platform/Settings.c index 102da1d28..ee8fcf332 100644 --- a/rEFIt_UEFI/Platform/Settings.c +++ b/rEFIt_UEFI/Platform/Settings.c @@ -309,9 +309,9 @@ ParseACPIName(CHAR8 *String) //Parse forward but put in stack LIFO "_SB.PCI0.RP02.PXSX" -1,3,8,13,18 pos0 = -1; while (pos0 < Len) { - List = AllocateZeroPool(sizeof(ACPI_NAME_LIST)); + List = (__typeof__(List))AllocateZeroPool(sizeof(ACPI_NAME_LIST)); List->Next = Next; - List->Name = AllocateZeroPool(5); + List->Name = (__typeof__(List->Name))AllocateZeroPool(5); pos1 = pos0 + 1; while ((pos1 < Len) && String[pos1] != '.') pos1++; // 3,8,13,18 // if ((pos1 == Len) || (String[pos1] == ',')) { //always @@ -405,10 +405,10 @@ ParseLoadOptions ( return; } - AsciiConf = AllocateCopyPool (TailSize + 1, Start); + AsciiConf = (__typeof__(AsciiConf))AllocateCopyPool (TailSize + 1, Start); if (AsciiConf != NULL) { *(AsciiConf + TailSize) = '\0'; - *Conf = AllocateZeroPool ((TailSize + 1) * sizeof (CHAR16)); + *Conf = (__typeof__(*Conf))AllocateZeroPool ((TailSize + 1) * sizeof (CHAR16)); AsciiStrToUnicodeStrS (AsciiConf, *Conf, TailSize); FreePool (AsciiConf); } @@ -421,7 +421,7 @@ ParseLoadOptions ( VOID GetBootFromOption(VOID) { - UINT8 *Data = SelfLoadedImage->LoadOptions; + UINT8 *Data = (UINT8*)SelfLoadedImage->LoadOptions; UINTN Len = SelfLoadedImage->LoadOptionsSize; UINTN NameSize, Name2Size; @@ -429,12 +429,12 @@ GetBootFromOption(VOID) NameSize = *(UINT16*)Data; Data += 2; // pointer to Volume name - gSettings.DefaultVolume = AllocateCopyPool(NameSize, Data); + gSettings.DefaultVolume = (__typeof__(gSettings.DefaultVolume))AllocateCopyPool(NameSize, Data); Data += NameSize; Name2Size = Len - NameSize; if (Name2Size != 0) { - gSettings.DefaultLoader = AllocateCopyPool(Name2Size, Data); + gSettings.DefaultLoader = (__typeof__(gSettings.DefaultLoader))AllocateCopyPool(Name2Size, Data); } DBG("Clover started with option to boot %s from %s\n", @@ -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; } @@ -525,7 +525,7 @@ SetBootCurrent(REFIT_MENU_ENTRY *LoadedEntry) } } if (BootIndex != 0) { - BootOrderNew = AllocatePool(BootOrderSize); + BootOrderNew = (__typeof__(BootOrderNew))AllocatePool(BootOrderSize); Ptr = BootOrderNew; for (Index = 0; Index < (INTN)VarSize - BootIndex; Index++) { *Ptr++ = BootOrder[Index + BootIndex]; @@ -557,7 +557,7 @@ SetBootCurrent(REFIT_MENU_ENTRY *LoadedEntry) // data can be specified in base64 encoded // or in hex encoded // -VOID +UINT8 *GetDataSetting ( IN TagPtr Dict, IN CHAR8 *PropName, @@ -573,7 +573,7 @@ VOID if (Prop != NULL) { if (Prop->data != NULL /*&& Prop->dataLen > 0*/) { //rehabman: allow zero length data // data property - Data = AllocateZeroPool (Prop->dataLen); + Data = (__typeof__(Data))AllocateZeroPool (Prop->dataLen); CopyMem (Data, Prop->data, Prop->dataLen); if (DataLen != NULL) { @@ -589,7 +589,7 @@ VOID } else { // assume data in hex encoded string property Len = (UINT32)AsciiStrLen (Prop->string) >> 1; // number of hex digits - Data = AllocateZeroPool(Len); // 2 chars per byte, one more byte for odd number + Data = (__typeof__(Data))AllocateZeroPool(Len); // 2 chars per byte, one more byte for odd number Len = hex2bin (Prop->string, Data, Len); if (DataLen != NULL) { @@ -769,13 +769,13 @@ CopyKernelAndKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Dst, (Src->KPATIConnectorsData != NULL) && (Src->KPATIConnectorsPatch != NULL)) { Dst->KPATIConnectorsDataLen = Src->KPATIConnectorsDataLen; - Dst->KPATIConnectorsData = AllocateCopyPool (Src->KPATIConnectorsDataLen, Src->KPATIConnectorsData); - Dst->KPATIConnectorsPatch = AllocateCopyPool (Src->KPATIConnectorsDataLen, Src->KPATIConnectorsPatch); + Dst->KPATIConnectorsData = (__typeof__(Dst->KPATIConnectorsData))AllocateCopyPool (Src->KPATIConnectorsDataLen, Src->KPATIConnectorsData); + Dst->KPATIConnectorsPatch = (__typeof__(Dst->KPATIConnectorsPatch))AllocateCopyPool (Src->KPATIConnectorsDataLen, Src->KPATIConnectorsPatch); } if ((Src->NrForceKexts > 0) && (Src->ForceKexts != NULL)) { INTN i; - Dst->ForceKexts = AllocatePool (Src->NrForceKexts * sizeof(CHAR16 *)); + Dst->ForceKexts = (__typeof__(Dst->ForceKexts))AllocatePool (Src->NrForceKexts * sizeof(CHAR16 *)); for (i = 0; i < Src->NrForceKexts; i++) { Dst->ForceKexts[Dst->NrForceKexts++] = EfiStrDuplicate (Src->ForceKexts[i]); @@ -784,7 +784,7 @@ CopyKernelAndKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Dst, if ((Src->NrKexts > 0) && (Src->KextPatches != NULL)) { INTN i; - Dst->KextPatches = AllocatePool (Src->NrKexts * sizeof(KEXT_PATCH)); + Dst->KextPatches = (__typeof__(Dst->KextPatches))AllocatePool (Src->NrKexts * sizeof(KEXT_PATCH)); for (i = 0; i < Src->NrKexts; i++) { @@ -805,17 +805,17 @@ CopyKernelAndKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Dst, Dst->KextPatches[Dst->NrKexts].MenuItem.BValue = Src->KextPatches[i].MenuItem.BValue; Dst->KextPatches[Dst->NrKexts].IsPlistPatch = Src->KextPatches[i].IsPlistPatch; Dst->KextPatches[Dst->NrKexts].DataLen = Src->KextPatches[i].DataLen; - Dst->KextPatches[Dst->NrKexts].Data = AllocateCopyPool (Src->KextPatches[i].DataLen, Src->KextPatches[i].Data); - Dst->KextPatches[Dst->NrKexts].Patch = AllocateCopyPool (Src->KextPatches[i].DataLen, Src->KextPatches[i].Patch); - Dst->KextPatches[Dst->NrKexts].MatchOS = AllocateCopyPool (AsciiStrSize(Src->KextPatches[i].MatchOS), Src->KextPatches[i].MatchOS); - Dst->KextPatches[Dst->NrKexts].MatchBuild = AllocateCopyPool (AsciiStrSize(Src->KextPatches[i].MatchBuild), Src->KextPatches[i].MatchBuild); + Dst->KextPatches[Dst->NrKexts].Data = (__typeof__(Dst->KextPatches[Dst->NrKexts].Data))AllocateCopyPool (Src->KextPatches[i].DataLen, Src->KextPatches[i].Data); + Dst->KextPatches[Dst->NrKexts].Patch = (__typeof__(Dst->KextPatches[Dst->NrKexts].Patch))AllocateCopyPool (Src->KextPatches[i].DataLen, Src->KextPatches[i].Patch); + Dst->KextPatches[Dst->NrKexts].MatchOS = (__typeof__(Dst->KextPatches[Dst->NrKexts].MatchOS))AllocateCopyPool (AsciiStrSize(Src->KextPatches[i].MatchOS), Src->KextPatches[i].MatchOS); + Dst->KextPatches[Dst->NrKexts].MatchBuild = (__typeof__(Dst->KextPatches[Dst->NrKexts].MatchBuild))AllocateCopyPool (AsciiStrSize(Src->KextPatches[i].MatchBuild), Src->KextPatches[i].MatchBuild); ++(Dst->NrKexts); } } if ((Src->NrKernels > 0) && (Src->KernelPatches != NULL)) { INTN i; - Dst->KernelPatches = AllocatePool (Src->NrKernels * sizeof(KERNEL_PATCH)); + Dst->KernelPatches = (__typeof__(Dst->KernelPatches))AllocatePool (Src->NrKernels * sizeof(KERNEL_PATCH)); for (i = 0; i < Src->NrKernels; i++) { @@ -831,18 +831,18 @@ CopyKernelAndKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Dst, Dst->KernelPatches[Dst->NrKernels].MenuItem.BValue = Src->KernelPatches[i].MenuItem.BValue; Dst->KernelPatches[Dst->NrKernels].DataLen = Src->KernelPatches[i].DataLen; - Dst->KernelPatches[Dst->NrKernels].Data = AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].Data); - Dst->KernelPatches[Dst->NrKernels].Patch = AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].Patch); + Dst->KernelPatches[Dst->NrKernels].Data = (__typeof__(Dst->KernelPatches[Dst->NrKernels].Data))AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].Data); + Dst->KernelPatches[Dst->NrKernels].Patch = (__typeof__(Dst->KernelPatches[Dst->NrKernels].Patch))AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].Patch); Dst->KernelPatches[Dst->NrKernels].Count = Src->KernelPatches[i].Count; - Dst->KernelPatches[Dst->NrKernels].MatchOS = AllocateCopyPool (AsciiStrSize(Src->KernelPatches[i].MatchOS), Src->KernelPatches[i].MatchOS); - Dst->KernelPatches[Dst->NrKernels].MatchBuild = AllocateCopyPool (AsciiStrSize(Src->KernelPatches[i].MatchBuild), Src->KernelPatches[i].MatchBuild); + Dst->KernelPatches[Dst->NrKernels].MatchOS = (__typeof__(Dst->KernelPatches[Dst->NrKernels].MatchOS))AllocateCopyPool (AsciiStrSize(Src->KernelPatches[i].MatchOS), Src->KernelPatches[i].MatchOS); + Dst->KernelPatches[Dst->NrKernels].MatchBuild = (__typeof__(Dst->KernelPatches[Dst->NrKernels].MatchBuild))AllocateCopyPool (AsciiStrSize(Src->KernelPatches[i].MatchBuild), Src->KernelPatches[i].MatchBuild); if (Src->KernelPatches[i].MaskFind != NULL) { - Dst->KernelPatches[Dst->NrKernels].MaskFind = AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].MaskFind); + Dst->KernelPatches[Dst->NrKernels].MaskFind = (__typeof__(Dst->KernelPatches[Dst->NrKernels].MaskFind))AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].MaskFind); } else { Dst->KernelPatches[Dst->NrKernels].MaskFind = NULL; } if (Src->KernelPatches[i].MaskReplace != NULL) { - Dst->KernelPatches[Dst->NrKernels].MaskReplace = AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].MaskReplace); + Dst->KernelPatches[Dst->NrKernels].MaskReplace = (__typeof__(Dst->KernelPatches[Dst->NrKernels].MaskReplace))AllocateCopyPool (Src->KernelPatches[i].DataLen, Src->KernelPatches[i].MaskReplace); } else { Dst->KernelPatches[Dst->NrKernels].MaskReplace = NULL; } @@ -896,7 +896,7 @@ CUSTOM_LOADER_ENTRY } if (Entry->BootBgColor) { - DuplicateEntry->BootBgColor = AllocateCopyPool (sizeof(EG_PIXEL), Entry->BootBgColor); + DuplicateEntry->BootBgColor = (__typeof__(DuplicateEntry->BootBgColor))AllocateCopyPool (sizeof(EG_PIXEL), Entry->BootBgColor); } DuplicateEntry->Image = Entry->Image; @@ -997,7 +997,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, UINTN len = 0, i=0; // ATIConnectors patch - Patches->KPATIConnectorsController = AllocateZeroPool (AsciiStrSize(Prop->string) * sizeof(CHAR16)); + Patches->KPATIConnectorsController = (__typeof__(Patches->KPATIConnectorsController))AllocateZeroPool (AsciiStrSize(Prop->string) * sizeof(CHAR16)); AsciiStrToUnicodeStrS (Prop->string, Patches->KPATIConnectorsController, AsciiStrSize(Prop->string)); Patches->KPATIConnectorsData = GetDataSetting (DictPointer, "ATIConnectorsData", &len); @@ -1035,7 +1035,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, INTN i, Count = GetTagCount (Prop); if (Count > 0) { TagPtr Prop2 = NULL; - CHAR16 **newForceKexts = AllocateZeroPool ((Patches->NrForceKexts + Count) * sizeof(CHAR16 *)); + CHAR16 **newForceKexts = (__typeof__(newForceKexts))AllocateZeroPool ((Patches->NrForceKexts + Count) * sizeof(CHAR16 *)); if (Patches->ForceKexts != NULL) { CopyMem (newForceKexts, Patches->ForceKexts, (Patches->NrForceKexts * sizeof(CHAR16 *))); @@ -1062,7 +1062,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, } if (AsciiStrSize(Prop2->string) > 1) { - Patches->ForceKexts[Patches->NrForceKexts] = AllocateZeroPool (AsciiStrSize(Prop2->string) * sizeof(CHAR16)); + Patches->ForceKexts[Patches->NrForceKexts] = (__typeof__(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; @@ -1109,7 +1109,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, } if (Count > 0) { TagPtr Prop2 = NULL, Dict = NULL; - KEXT_PATCH *newPatches = AllocateZeroPool (Count * sizeof(KEXT_PATCH)); + KEXT_PATCH *newPatches = (__typeof__(newPatches))AllocateZeroPool (Count * sizeof(KEXT_PATCH)); Patches->KextPatches = newPatches; DBG ("KextsToPatch: %d requested\n", Count); @@ -1134,8 +1134,8 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, continue; } - KextPatchesName = AllocateCopyPool (255, Dict->string); - KextPatchesLabel = AllocateCopyPool (255, KextPatchesName); + KextPatchesName = (__typeof__(KextPatchesName))AllocateCopyPool (255, Dict->string); + KextPatchesLabel = (__typeof__(KextPatchesLabel))AllocateCopyPool (255, KextPatchesName); Dict = GetProperty (Prop2, "Comment"); if (Dict != NULL) { @@ -1165,7 +1165,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, continue; } - Patches->KextPatches[Patches->NrKexts].Data = AllocateCopyPool (FindLen, TmpData); + Patches->KextPatches[Patches->NrKexts].Data = (__typeof__(Patches->KextPatches[Patches->NrKexts].Data))AllocateCopyPool (FindLen, TmpData); Patches->KextPatches[Patches->NrKexts].DataLen = FindLen; FreePool(TmpData); TmpData = GetDataSetting (Prop2, "MaskFind", &MaskLen); @@ -1174,12 +1174,12 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, if (TmpData == NULL || MaskLen == 0) { Patches->KextPatches[Patches->NrKexts].MaskFind = NULL; } else { - Patches->KextPatches[Patches->NrKexts].MaskFind = AllocatePool (FindLen); + Patches->KextPatches[Patches->NrKexts].MaskFind = (__typeof__(Patches->KextPatches[Patches->NrKexts].MaskFind))AllocatePool (FindLen); SetMem(Patches->KextPatches[Patches->NrKexts].MaskFind, FindLen, 0xFF); CopyMem(Patches->KextPatches[Patches->NrKexts].MaskFind, TmpData, MaskLen); } FreePool(TmpData); - Patches->KextPatches[Patches->NrKexts].Patch = AllocateCopyPool (FindLen, TmpPatch); + Patches->KextPatches[Patches->NrKexts].Patch = (__typeof__(Patches->KextPatches[Patches->NrKexts].Patch))AllocateCopyPool (FindLen, TmpPatch); FreePool(TmpPatch); MaskLen = 0; TmpData = GetDataSetting (Prop2, "MaskReplace", &MaskLen); @@ -1188,27 +1188,27 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, if (TmpData == NULL || MaskLen == 0) { Patches->KextPatches[Patches->NrKexts].MaskReplace = NULL; } else { - Patches->KextPatches[Patches->NrKexts].MaskReplace = AllocateZeroPool (FindLen); + Patches->KextPatches[Patches->NrKexts].MaskReplace = (__typeof__(Patches->KextPatches[Patches->NrKexts].MaskReplace))AllocateZeroPool (FindLen); CopyMem(Patches->KextPatches[Patches->NrKexts].MaskReplace, TmpData, MaskLen); } FreePool(TmpData); Patches->KextPatches[Patches->NrKexts].MatchOS = NULL; Patches->KextPatches[Patches->NrKexts].MatchBuild = NULL; - Patches->KextPatches[Patches->NrKexts].Name = AllocateCopyPool (AsciiStrSize(KextPatchesName), KextPatchesName); + Patches->KextPatches[Patches->NrKexts].Name = (__typeof__(Patches->KextPatches[Patches->NrKexts].Name))AllocateCopyPool (AsciiStrSize(KextPatchesName), KextPatchesName); FreePool(KextPatchesName); - Patches->KextPatches[Patches->NrKexts].Label = AllocateCopyPool (AsciiStrSize(KextPatchesLabel), KextPatchesLabel); + Patches->KextPatches[Patches->NrKexts].Label = (__typeof__(Patches->KextPatches[Patches->NrKexts].Label))AllocateCopyPool (AsciiStrSize(KextPatchesLabel), KextPatchesLabel); FreePool(KextPatchesLabel); // check enable/disabled patch (OS based) by Micky1979 Dict = GetProperty (Prop2, "MatchOS"); if ((Dict != NULL) && (Dict->type == kTagTypeString)) { - Patches->KextPatches[Patches->NrKexts].MatchOS = AllocateCopyPool (AsciiStrSize(Dict->string), Dict->string); + Patches->KextPatches[Patches->NrKexts].MatchOS = (__typeof__(Patches->KextPatches[Patches->NrKexts].MatchOS))AllocateCopyPool (AsciiStrSize(Dict->string), Dict->string); DBG(" :: MatchOS: %a", Patches->KextPatches[Patches->NrKexts].MatchOS); } Dict = GetProperty (Prop2, "MatchBuild"); if ((Dict != NULL) && (Dict->type == kTagTypeString)) { - Patches->KextPatches[Patches->NrKexts].MatchBuild = AllocateCopyPool (AsciiStrSize(Dict->string), Dict->string); + Patches->KextPatches[Patches->NrKexts].MatchBuild = (__typeof__(Patches->KextPatches[Patches->NrKexts].MatchBuild))AllocateCopyPool (AsciiStrSize(Dict->string), Dict->string); DBG(" :: MatchBuild: %a", Patches->KextPatches[Patches->NrKexts].MatchBuild); } @@ -1271,7 +1271,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, } if (Count > 0) { TagPtr Prop2 = NULL, Dict = NULL; - KERNEL_PATCH *newPatches = AllocateZeroPool (Count * sizeof(KERNEL_PATCH)); + KERNEL_PATCH *newPatches = (__typeof__(newPatches))AllocateZeroPool (Count * sizeof(KERNEL_PATCH)); Patches->KernelPatches = newPatches; DBG ("KernelToPatch: %d requested\n", Count); @@ -1292,9 +1292,9 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, Dict = GetProperty (Prop2, "Comment"); if (Dict != NULL) { - KernelPatchesLabel = AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); + KernelPatchesLabel = (__typeof__(KernelPatchesLabel))AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); } else { - KernelPatchesLabel = AllocateCopyPool (8, "NoLabel"); + KernelPatchesLabel = (__typeof__(KernelPatchesLabel))AllocateCopyPool (8, "NoLabel"); } DBG (" %a", KernelPatchesLabel); @@ -1309,7 +1309,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, continue; } - Patches->KernelPatches[Patches->NrKernels].Data = AllocateCopyPool (FindLen, TmpData); + Patches->KernelPatches[Patches->NrKernels].Data = (__typeof__(Patches->KernelPatches[Patches->NrKernels].Data))AllocateCopyPool (FindLen, TmpData); Patches->KernelPatches[Patches->NrKernels].DataLen = FindLen; FreePool(TmpData); TmpData = GetDataSetting (Prop2, "MaskFind", &MaskLen); @@ -1317,26 +1317,26 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, if (TmpData == NULL || MaskLen == 0) { Patches->KernelPatches[Patches->NrKexts].MaskFind = NULL; } else { - Patches->KernelPatches[Patches->NrKexts].MaskFind = AllocatePool (FindLen); + Patches->KernelPatches[Patches->NrKexts].MaskFind = (__typeof__(Patches->KernelPatches[Patches->NrKexts].MaskFind))AllocatePool (FindLen); SetMem(Patches->KernelPatches[Patches->NrKexts].MaskFind, FindLen, 0xFF); CopyMem(Patches->KernelPatches[Patches->NrKexts].MaskFind, TmpData, MaskLen); } FreePool(TmpData); - Patches->KernelPatches[Patches->NrKernels].Patch = AllocateCopyPool (FindLen, TmpPatch); + Patches->KernelPatches[Patches->NrKernels].Patch = (__typeof__(Patches->KernelPatches[Patches->NrKernels].Patch))AllocateCopyPool (FindLen, TmpPatch); FreePool(TmpPatch); TmpData = GetDataSetting (Prop2, "MaskReplace", &MaskLen); MaskLen = (MaskLen > FindLen)? FindLen : MaskLen; if (TmpData == NULL || MaskLen == 0) { Patches->KernelPatches[Patches->NrKexts].MaskReplace = NULL; } else { - Patches->KernelPatches[Patches->NrKexts].MaskReplace = AllocateZeroPool (FindLen); + Patches->KernelPatches[Patches->NrKexts].MaskReplace = (__typeof__(Patches->KernelPatches[Patches->NrKexts].MaskReplace))AllocateZeroPool (FindLen); CopyMem(Patches->KernelPatches[Patches->NrKexts].MaskReplace, TmpData, MaskLen); } FreePool(TmpData); Patches->KernelPatches[Patches->NrKernels].Count = 0; Patches->KernelPatches[Patches->NrKernels].MatchOS = NULL; Patches->KernelPatches[Patches->NrKernels].MatchBuild = NULL; - Patches->KernelPatches[Patches->NrKernels].Label = AllocateCopyPool (AsciiStrSize (KernelPatchesLabel), KernelPatchesLabel); + Patches->KernelPatches[Patches->NrKernels].Label = (__typeof__(Patches->KernelPatches[Patches->NrKernels].Label))AllocateCopyPool (AsciiStrSize (KernelPatchesLabel), KernelPatchesLabel); Dict = GetProperty (Prop2, "Count"); if (Dict != NULL) { @@ -1347,13 +1347,13 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, // check enable/disabled patch (OS based) by Micky1979 Dict = GetProperty (Prop2, "MatchOS"); if ((Dict != NULL) && (Dict->type == kTagTypeString)) { - Patches->KernelPatches[Patches->NrKernels].MatchOS = AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); + Patches->KernelPatches[Patches->NrKernels].MatchOS = (__typeof__(Patches->KernelPatches[Patches->NrKernels].MatchOS))AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); DBG(" :: MatchOS: %a", Patches->KernelPatches[Patches->NrKernels].MatchOS); } Dict = GetProperty (Prop2, "MatchBuild"); if ((Dict != NULL) && (Dict->type == kTagTypeString)) { - Patches->KernelPatches[Patches->NrKernels].MatchBuild = AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); + Patches->KernelPatches[Patches->NrKernels].MatchBuild = (__typeof__(Patches->KernelPatches[Patches->NrKernels].MatchBuild))AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); DBG(" :: MatchBuild: %a", Patches->KernelPatches[Patches->NrKernels].MatchBuild); } DBG (" :: data len: %d\n", Patches->KernelPatches[Patches->NrKernels].DataLen); @@ -1396,7 +1396,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, } if (Count > 0) { TagPtr Prop2 = NULL, Dict = NULL; - KERNEL_PATCH *newPatches = AllocateZeroPool (Count * sizeof(KERNEL_PATCH)); + KERNEL_PATCH *newPatches = (__typeof__(newPatches))AllocateZeroPool (Count * sizeof(KERNEL_PATCH)); Patches->BootPatches = newPatches; DBG ("BootPatches: %d requested\n", Count); @@ -1416,9 +1416,9 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, Dict = GetProperty (Prop2, "Comment"); if (Dict != NULL) { - BootPatchesLabel = AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); + BootPatchesLabel = (__typeof__(BootPatchesLabel))AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); } else { - BootPatchesLabel = AllocateCopyPool (8, "NoLabel"); + BootPatchesLabel = (__typeof__(BootPatchesLabel))AllocateCopyPool (8, "NoLabel"); } DBG (" %a", BootPatchesLabel); @@ -1434,7 +1434,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, continue; } - Patches->BootPatches[Patches->NrBoots].Data = AllocateCopyPool (FindLen, TmpData); + Patches->BootPatches[Patches->NrBoots].Data = (__typeof__(Patches->BootPatches[Patches->NrBoots].Data))AllocateCopyPool (FindLen, TmpData); Patches->BootPatches[Patches->NrBoots].DataLen = FindLen; FreePool(TmpData); TmpData = GetDataSetting (Prop2, "MaskFind", &MaskLen); @@ -1442,26 +1442,26 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, if (TmpData == NULL || MaskLen == 0) { Patches->BootPatches[Patches->NrKexts].MaskFind = NULL; } else { - Patches->BootPatches[Patches->NrKexts].MaskFind = AllocatePool (FindLen); + Patches->BootPatches[Patches->NrKexts].MaskFind = (__typeof__(Patches->BootPatches[Patches->NrKexts].MaskFind))AllocatePool (FindLen); SetMem(Patches->BootPatches[Patches->NrKexts].MaskFind, FindLen, 0xFF); CopyMem(Patches->BootPatches[Patches->NrKexts].MaskFind, TmpData, MaskLen); } FreePool(TmpData); - Patches->BootPatches[Patches->NrBoots].Patch = AllocateCopyPool (FindLen, TmpPatch); + Patches->BootPatches[Patches->NrBoots].Patch = (__typeof__(Patches->BootPatches[Patches->NrBoots].Patch))AllocateCopyPool (FindLen, TmpPatch); FreePool(TmpPatch); TmpData = GetDataSetting (Prop2, "MaskReplace", &MaskLen); MaskLen = (MaskLen > FindLen)? FindLen : MaskLen; if (TmpData == NULL || MaskLen == 0) { Patches->BootPatches[Patches->NrKexts].MaskReplace = NULL; } else { - Patches->BootPatches[Patches->NrKexts].MaskReplace = AllocateZeroPool (FindLen); + Patches->BootPatches[Patches->NrKexts].MaskReplace = (__typeof__(Patches->BootPatches[Patches->NrKexts].MaskReplace))AllocateZeroPool (FindLen); CopyMem(Patches->BootPatches[Patches->NrKexts].MaskReplace, TmpData, MaskLen); } FreePool(TmpData); Patches->BootPatches[Patches->NrBoots].Count = 0; Patches->BootPatches[Patches->NrBoots].MatchOS = NULL; Patches->BootPatches[Patches->NrBoots].MatchBuild = NULL; - Patches->BootPatches[Patches->NrBoots].Label = AllocateCopyPool (AsciiStrSize (BootPatchesLabel), BootPatchesLabel); + Patches->BootPatches[Patches->NrBoots].Label = (__typeof__(Patches->BootPatches[Patches->NrBoots].Label))AllocateCopyPool (AsciiStrSize (BootPatchesLabel), BootPatchesLabel); Dict = GetProperty (Prop2, "Count"); if (Dict != NULL) { @@ -1471,13 +1471,13 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, Dict = GetProperty (Prop2, "MatchOS"); if ((Dict != NULL) && (Dict->type == kTagTypeString)) { - Patches->BootPatches[Patches->NrBoots].MatchOS = AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); + Patches->BootPatches[Patches->NrBoots].MatchOS = (__typeof__(Patches->BootPatches[Patches->NrBoots].MatchOS))AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); DBG(" :: MatchOS: %a", Patches->BootPatches[Patches->NrBoots].MatchOS); } Dict = GetProperty (Prop2, "MatchBuild"); if ((Dict != NULL) && (Dict->type == kTagTypeString)) { - Patches->BootPatches[Patches->NrBoots].MatchBuild = AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); + Patches->BootPatches[Patches->NrBoots].MatchBuild = (__typeof__(Patches->BootPatches[Patches->NrBoots].MatchBuild))AllocateCopyPool (AsciiStrSize (Dict->string), Dict->string); DBG(" :: MatchBuild: %a", Patches->BootPatches[Patches->NrBoots].MatchBuild); } @@ -1496,7 +1496,7 @@ IsPatchEnabled (CHAR8 *MatchOSEntry, CHAR8 *CurrOS) { INTN i; BOOLEAN ret = FALSE; - struct MatchOSes *mos; // = AllocatePool(sizeof(struct MatchOSes)); + struct MatchOSes *mos; // = (__typeof__(mos))AllocatePool(sizeof(struct MatchOSes)); if (!MatchOSEntry || !CurrOS) { return TRUE; //undefined matched corresponds to old behavior @@ -1536,7 +1536,7 @@ MatchOSes *GetStrArraySeparatedByChar(CHAR8 *str, CHAR8 sep) // CHAR8 *comp = NULL; //unused CHAR8 doubleSep[2]; - mo = AllocatePool(sizeof(struct MatchOSes)); + mo = (__typeof__(mo))AllocatePool(sizeof(struct MatchOSes)); if (!mo) { return NULL; } @@ -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] = AllocateCopyPool(newLen, str + startLocation); + mo->array[i] = (__typeof__(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] = AllocateCopyPool(AsciiStrLen(str)+1, str); + mo->array[0] = (__typeof__(mo->array[0]))AllocateCopyPool(AsciiStrLen(str)+1, str); } return mo; } @@ -1620,7 +1620,7 @@ TrimString(CHAR8* String) } *(End + 1) = '\0'; - TrimmedString = AllocateCopyPool(AsciiStrSize(TempString), TempString); + TrimmedString = (__typeof__(TrimmedString))AllocateCopyPool(AsciiStrSize(TempString), TempString); FreePool(String); return TrimmedString; } @@ -1995,7 +1995,7 @@ FillinCustomEntry ( if (Prop != NULL && Prop->type == kTagTypeString) { UINTN Color; Color = AsciiStrHexToUintn (Prop->string); - Entry->BootBgColor = AllocateZeroPool (sizeof(EG_PIXEL)); + Entry->BootBgColor = (__typeof__(Entry->BootBgColor))AllocateZeroPool (sizeof(EG_PIXEL)); Entry->BootBgColor->r = (Color >> 24) & 0xFF; Entry->BootBgColor->g = (Color >> 16) & 0xFF; Entry->BootBgColor->b = (Color >> 8) & 0xFF; @@ -2590,7 +2590,7 @@ GetEarlyUserSettings ( if (AsciiStriCmp (Prop->string, "LastBootedVolume") == 0) { gSettings.LastBootedVolume = TRUE; } else { - gSettings.DefaultVolume = AllocateZeroPool (Size * sizeof(CHAR16)); + gSettings.DefaultVolume = (__typeof__(gSettings.DefaultVolume))AllocateZeroPool (Size * sizeof(CHAR16)); AsciiStrToUnicodeStrS(Prop->string, gSettings.DefaultVolume, Size); } } @@ -2598,7 +2598,7 @@ GetEarlyUserSettings ( Prop = GetProperty (DictPointer, "DefaultLoader"); if (Prop != NULL) { - gSettings.DefaultLoader = AllocateZeroPool (AsciiStrSize (Prop->string) * sizeof(CHAR16)); + gSettings.DefaultLoader = (__typeof__(gSettings.DefaultLoader))AllocateZeroPool (AsciiStrSize (Prop->string) * sizeof(CHAR16)); AsciiStrToUnicodeStrS (Prop->string, gSettings.DefaultLoader, AsciiStrSize (Prop->string)); } @@ -2680,7 +2680,7 @@ GetEarlyUserSettings ( INTN i, Count = GetTagCount (Prop); if (Count > 0) { gSettings.SecureBootWhiteListCount = 0; - gSettings.SecureBootWhiteList = AllocateZeroPool (Count * sizeof(CHAR16 *)); + gSettings.SecureBootWhiteList = (__typeof__(gSettings.SecureBootWhiteList))AllocateZeroPool (Count * sizeof(CHAR16 *)); if (gSettings.SecureBootWhiteList) { for (i = 0; i < Count; i++) { if (EFI_ERROR (GetElement (Prop, i, &Dict2))) { @@ -2704,7 +2704,7 @@ GetEarlyUserSettings ( INTN i, Count = GetTagCount (Prop); if (Count > 0) { gSettings.SecureBootBlackListCount = 0; - gSettings.SecureBootBlackList = AllocateZeroPool (Count * sizeof(CHAR16 *)); + gSettings.SecureBootBlackList = (__typeof__(gSettings.SecureBootBlackList))AllocateZeroPool (Count * sizeof(CHAR16 *)); if (gSettings.SecureBootBlackList) { for (i = 0; i < Count; i++) { if (EFI_ERROR (GetElement (Prop, i, &Dict2))) { @@ -3033,7 +3033,7 @@ GetEarlyUserSettings ( INTN i, Count = GetTagCount (Prop); if (Count > 0) { gSettings.HVCount = 0; - gSettings.HVHideStrings = AllocateZeroPool (Count * sizeof(CHAR16 *)); + gSettings.HVHideStrings = (__typeof__(gSettings.HVHideStrings))AllocateZeroPool (Count * sizeof(CHAR16 *)); if (gSettings.HVHideStrings) { for (i = 0; i < Count; i++) { if (EFI_ERROR (GetElement (Prop, i, &Dict2))) { @@ -3214,7 +3214,7 @@ GetEarlyUserSettings ( BOOLEAN Valid; // alloc space for up to 16 entries - gSettings.PatchVBiosBytes = AllocateZeroPool (Count * sizeof(VBIOS_PATCH_BYTES)); + gSettings.PatchVBiosBytes = (__typeof__(gSettings.PatchVBiosBytes))AllocateZeroPool (Count * sizeof(VBIOS_PATCH_BYTES)); // get all entries for (i = 0; i < Count; i++) { @@ -3281,7 +3281,7 @@ GetEarlyUserSettings ( INTN i, Count = GetTagCount (DictPointer); if (Count > 0) { gSettings.BlackListCount = 0; - gSettings.BlackList = AllocateZeroPool (Count * sizeof(CHAR16 *)); + gSettings.BlackList = (__typeof__(gSettings.BlackList))AllocateZeroPool (Count * sizeof(CHAR16 *)); for (i = 0; i < Count; i++) { if (!EFI_ERROR (GetElement (DictPointer, i, &Prop)) && @@ -3409,7 +3409,7 @@ GetListOfACPI () UnicodeSPrint(FullName, 512, L"%s\\%s", AcpiPath, DirEntry->FileName); if (FileExists(SelfRootDir, FullName)) { BOOLEAN ACPIDisabled = FALSE; - ACPIPatchedAMLTmp = AllocateZeroPool (sizeof(ACPI_PATCHED_AML)); + ACPIPatchedAMLTmp = (__typeof__(ACPIPatchedAMLTmp))AllocateZeroPool (sizeof(ACPI_PATCHED_AML)); ACPIPatchedAMLTmp->FileName = PoolPrint(L"%s", DirEntry->FileName); for (i = 0; i < Count; i++) { @@ -3492,7 +3492,7 @@ VOID GetListOfInjectKext(CHAR16 *KextDirNameUnderOEMPath) */ FullName = PoolPrint(L"%s\\%s", FullPath, DirEntry->FileName); - mKext = AllocateZeroPool (sizeof(SIDELOAD_KEXT)); + mKext = (__typeof__(mKext))AllocateZeroPool (sizeof(SIDELOAD_KEXT)); mKext->FileName = PoolPrint(L"%s", DirEntry->FileName); mKext->MenuItem.BValue = Blocked; mKext->KextDirNameUnderOEMPath = PoolPrint(L"%s", KextDirNameUnderOEMPath); @@ -3511,7 +3511,7 @@ VOID GetListOfInjectKext(CHAR16 *KextDirNameUnderOEMPath) continue; } PlugInsName = PoolPrint(L"%s\\%s", PlugInsPath, PlugInEntry->FileName); - mPlugInKext = AllocateZeroPool(sizeof(SIDELOAD_KEXT)); + mPlugInKext = (__typeof__(mPlugInKext))AllocateZeroPool(sizeof(SIDELOAD_KEXT)); mPlugInKext->FileName = PoolPrint(L"%s", PlugInEntry->FileName); mPlugInKext->MenuItem.BValue = Blocked; mPlugInKext->KextDirNameUnderOEMPath = PoolPrint(L"%s", KextDirNameUnderOEMPath); @@ -3992,7 +3992,7 @@ GetThemeTagSettings ( break; } - Anime = AllocateZeroPool (sizeof(GUI_ANIME)); + Anime = (__typeof__(Anime))AllocateZeroPool (sizeof(GUI_ANIME)); if (Anime == NULL) { break; } @@ -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; @@ -4438,7 +4438,9 @@ ParseSMBIOSSettings( TagPtr DictPointer ) { - CHAR8 *i, *j, *Res1 = AllocateZeroPool(9), *Res2 = AllocateZeroPool(11); + CHAR8 *i, *j; + CHAR8 *Res1 = (__typeof__(Res1))AllocateZeroPool(9); + CHAR8 *Res2 = (__typeof__(Res2))AllocateZeroPool(11); CHAR16 UStr[64]; TagPtr Prop, Prop1; BOOLEAN Default = FALSE; @@ -4995,7 +4997,7 @@ GetUserSettings( EFI_PHYSICAL_ADDRESS BufferPtr = EFI_SYSTEM_TABLE_MAX_ADDRESS; //0xFE000000; UINTN strlength = AsciiStrLen(Prop->string); - cDeviceProperties = AllocateZeroPool(strlength + 1); + cDeviceProperties = (__typeof__(cDeviceProperties))AllocateZeroPool(strlength + 1); AsciiStrCpyS(cDeviceProperties, strlength + 1, Prop->string); //------- Status = gBS->AllocatePages ( @@ -5016,7 +5018,7 @@ GetUserSettings( else if (Prop->type == kTagTypeDict) { //analyze dict-array INTN i, Count = GetTagCount(Prop); - gSettings.AddProperties = AllocateZeroPool(Count * sizeof(DEV_PROPERTY)); + gSettings.AddProperties = (__typeof__(gSettings.AddProperties))AllocateZeroPool(Count * sizeof(DEV_PROPERTY)); DEV_PROPERTY *DevPropDevice; DEV_PROPERTY *DevProps; DEV_PROPERTY **Child; @@ -5048,12 +5050,12 @@ GetUserSettings( else continue; //Create Device node DevPropDevice = gSettings.ArbProperties; - gSettings.ArbProperties = AllocateZeroPool(sizeof(DEV_PROPERTY)); + gSettings.ArbProperties = (__typeof__(gSettings.ArbProperties))AllocateZeroPool(sizeof(DEV_PROPERTY)); gSettings.ArbProperties->Next = DevPropDevice; //next device gSettings.ArbProperties->Child = NULL; gSettings.ArbProperties->Device = 0; //to differ from arbitrary gSettings.ArbProperties->DevicePath = DevicePath; //this is pointer - gSettings.ArbProperties->Label = AllocateCopyPool(AsciiStrSize(Prop2->string), Prop2->string); + gSettings.ArbProperties->Label = (__typeof__(gSettings.ArbProperties->Label))AllocateCopyPool(AsciiStrSize(Prop2->string), Prop2->string); Child = &(gSettings.ArbProperties->Child); Prop2 = Prop2->tag; //take a for this device @@ -5064,7 +5066,7 @@ GetUserSettings( for (j = 0; j < PropCount; j++) { Prop3 = NULL; DevProps = *Child; - *Child = AllocateZeroPool(sizeof(DEV_PROPERTY)); + *Child = (__typeof__(*Child))AllocateZeroPool(sizeof(DEV_PROPERTY)); (*Child)->Next = DevProps; if (EFI_ERROR(GetElement(Prop2, j, &Prop3))) { // Prop3 -> @@ -5075,35 +5077,35 @@ GetUserSettings( ) { if (Prop3->string[0] != '#') { (*Child)->MenuItem.BValue = TRUE; - (*Child)->Key = AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); + (*Child)->Key = (__typeof__((*Child)->Key))AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); } else { (*Child)->MenuItem.BValue = FALSE; - (*Child)->Key = AllocateCopyPool(AsciiStrSize(Prop3->string) - 1, Prop3->string + 1); + (*Child)->Key = (__typeof__((*Child)->Key))AllocateCopyPool(AsciiStrSize(Prop3->string) - 1, Prop3->string + 1); } Prop3 = Prop3->tag; //expected value // DBG("%a\n type %d\n", (*Child)->Key, Prop3->type); if (Prop3 && (Prop3->type == kTagTypeString) && Prop3->string) { //first suppose it is Ascii string - (*Child)->Value = AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); + (*Child)->Value = (__typeof__((*Child)->Value))AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); (*Child)->ValueLen = AsciiStrLen(Prop3->string) + 1; (*Child)->ValueType = kTagTypeString; } else if (Prop3 && (Prop3->type == kTagTypeInteger)) { - (*Child)->Value = AllocatePool(4); + (*Child)->Value = (__typeof__((*Child)->Value))AllocatePool(4); CopyMem((*Child)->Value, &(Prop3->string), 4); (*Child)->ValueLen = 4; (*Child)->ValueType = kTagTypeInteger; } else if (Prop3 && (Prop3->type == kTagTypeTrue)) { - (*Child)->Value = AllocateZeroPool(4); + (*Child)->Value = (__typeof__((*Child)->Value))AllocateZeroPool(4); (*Child)->Value[0] = TRUE; (*Child)->ValueLen = 1; (*Child)->ValueType = kTagTypeTrue; } else if (Prop3 && (Prop3->type == kTagTypeFalse)) { - (*Child)->Value = AllocateZeroPool(4); + (*Child)->Value = (__typeof__((*Child)->Value))AllocateZeroPool(4); //(*Child)->Value[0] = FALSE; (*Child)->ValueLen = 1; (*Child)->ValueType = kTagTypeFalse; @@ -5111,7 +5113,7 @@ GetUserSettings( else if (Prop3 && (Prop3->type == kTagTypeData)) { UINTN Size = Prop3->dataLen; // (*Child)->Value = GetDataSetting(Prop3, "Value", &Size); //TODO - UINT8* Data = AllocateZeroPool(Size); + UINT8* Data = (__typeof__(Data))AllocateZeroPool(Size); CopyMem(Data, Prop3->data, Size); (*Child)->Value = Data; (*Child)->ValueLen = Size; @@ -5159,7 +5161,7 @@ GetUserSettings( DBG(" wrong PciAddr string: %a\n", Str); continue; } - Label = AllocatePool(64); + Label = (__typeof__(Label))AllocatePool(64); Bus = hexstrtouint8(Str); Dev = hexstrtouint8(&Str[3]); Func = hexstrtouint8(&Str[6]); @@ -5187,38 +5189,38 @@ GetUserSettings( if (!EFI_ERROR(GetElement(Dict2, PropIndex, &Dict3))) { DevProp = gSettings.ArbProperties; - gSettings.ArbProperties = AllocateZeroPool(sizeof(DEV_PROPERTY)); + gSettings.ArbProperties = (__typeof__(gSettings.ArbProperties))AllocateZeroPool(sizeof(DEV_PROPERTY)); gSettings.ArbProperties->Next = DevProp; gSettings.ArbProperties->Device = (UINT32)DeviceAddr; - gSettings.ArbProperties->Label = AllocateCopyPool(AsciiStrSize(Label), Label); + gSettings.ArbProperties->Label = (__typeof__(gSettings.ArbProperties->Label))AllocateCopyPool(AsciiStrSize(Label), Label); Prop3 = GetProperty (Dict3, "Disabled"); gSettings.ArbProperties->MenuItem.BValue = !IsPropertyTrue(Prop3); Prop3 = GetProperty (Dict3, "Key"); if (Prop3 && (Prop3->type == kTagTypeString) && Prop3->string) { - gSettings.ArbProperties->Key = AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); + gSettings.ArbProperties->Key = (__typeof__(gSettings.ArbProperties->Key))AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); } Prop3 = GetProperty (Dict3, "Value"); if (Prop3 && (Prop3->type == kTagTypeString) && Prop3->string) { //first suppose it is Ascii string - gSettings.ArbProperties->Value = AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); + gSettings.ArbProperties->Value = (__typeof__(gSettings.ArbProperties->Value))AllocateCopyPool(AsciiStrSize(Prop3->string), Prop3->string); gSettings.ArbProperties->ValueLen = AsciiStrLen(Prop3->string) + 1; gSettings.ArbProperties->ValueType = kTagTypeString; } else if (Prop3 && (Prop3->type == kTagTypeInteger)) { - gSettings.ArbProperties->Value = AllocatePool(4); + gSettings.ArbProperties->Value = (__typeof__(gSettings.ArbProperties->Value))AllocatePool(4); CopyMem (gSettings.ArbProperties->Value, &(Prop3->string), 4); gSettings.ArbProperties->ValueLen = 4; gSettings.ArbProperties->ValueType = kTagTypeInteger; } else if (Prop3 && (Prop3->type == kTagTypeTrue)) { - gSettings.ArbProperties->Value = AllocateZeroPool(4); + gSettings.ArbProperties->Value = (__typeof__(gSettings.ArbProperties->Value))AllocateZeroPool(4); gSettings.ArbProperties->Value[0] = TRUE; gSettings.ArbProperties->ValueLen = 1; gSettings.ArbProperties->ValueType = kTagTypeTrue; } else if (Prop3 && (Prop3->type == kTagTypeFalse)) { - gSettings.ArbProperties->Value = AllocateZeroPool(4); + gSettings.ArbProperties->Value = (__typeof__(gSettings.ArbProperties->Value))AllocateZeroPool(4); //gSettings.ArbProperties->Value[0] = FALSE; gSettings.ArbProperties->ValueLen = 1; gSettings.ArbProperties->ValueType = kTagTypeFalse; @@ -5249,7 +5251,7 @@ GetUserSettings( if (Count > 0) { DBG ("Add %d properties:\n", Count); - gSettings.AddProperties = AllocateZeroPool (Count * sizeof(DEV_PROPERTY)); + gSettings.AddProperties = (__typeof__(gSettings.AddProperties))AllocateZeroPool (Count * sizeof(DEV_PROPERTY)); for (i = 0; i < Count; i++) { UINTN Size = 0; @@ -5307,16 +5309,16 @@ GetUserSettings( Prop2 = GetProperty (Dict2, "Key"); if (Prop2 && (Prop2->type == kTagTypeString) && Prop2->string) { - gSettings.AddProperties[Index].Key = AllocateCopyPool (AsciiStrSize (Prop2->string), Prop2->string); + gSettings.AddProperties[Index].Key = (__typeof__(gSettings.AddProperties[Index].Key))AllocateCopyPool (AsciiStrSize (Prop2->string), Prop2->string); } Prop2 = GetProperty (Dict2, "Value"); if (Prop2 && (Prop2->type == kTagTypeString) && Prop2->string) { //first suppose it is Ascii string - gSettings.AddProperties[Index].Value = AllocateCopyPool (AsciiStrSize (Prop2->string), Prop2->string); + gSettings.AddProperties[Index].Value = (__typeof__(gSettings.AddProperties[Index].Value))AllocateCopyPool (AsciiStrSize (Prop2->string), Prop2->string); gSettings.AddProperties[Index].ValueLen = AsciiStrLen (Prop2->string) + 1; } else if (Prop2 && (Prop2->type == kTagTypeInteger)) { - gSettings.AddProperties[Index].Value = AllocatePool (4); + gSettings.AddProperties[Index].Value = (__typeof__(gSettings.AddProperties[Index].Value))AllocatePool (4); CopyMem (gSettings.AddProperties[Index].Value, &(Prop2->string), 4); gSettings.AddProperties[Index].ValueLen = 4; } else { @@ -5607,13 +5609,13 @@ GetUserSettings( INTN i, Count = GetTagCount (Prop); if (Count > 0) { gSettings.PatchDsdtNum = (UINT32)Count; - gSettings.PatchDsdtFind = AllocateZeroPool (Count * sizeof(UINT8*)); - gSettings.PatchDsdtReplace = AllocateZeroPool (Count * sizeof(UINT8*)); - gSettings.PatchDsdtTgt = AllocateZeroPool (Count * sizeof(UINT8*)); - gSettings.LenToFind = AllocateZeroPool (Count * sizeof(UINT32)); - gSettings.LenToReplace = AllocateZeroPool (Count * sizeof(UINT32)); - gSettings.PatchDsdtLabel = AllocateZeroPool (Count * sizeof(UINT8*)); - gSettings.PatchDsdtMenuItem = AllocateZeroPool (Count * sizeof(INPUT_ITEM)); + gSettings.PatchDsdtFind = (__typeof__(gSettings.PatchDsdtFind))AllocateZeroPool (Count * sizeof(UINT8*)); + gSettings.PatchDsdtReplace = (__typeof__(gSettings.PatchDsdtReplace))AllocateZeroPool (Count * sizeof(UINT8*)); + gSettings.PatchDsdtTgt = (__typeof__(gSettings.PatchDsdtTgt))AllocateZeroPool (Count * sizeof(UINT8*)); + gSettings.LenToFind = (__typeof__(gSettings.LenToFind))AllocateZeroPool (Count * sizeof(UINT32)); + gSettings.LenToReplace = (__typeof__(gSettings.LenToReplace))AllocateZeroPool (Count * sizeof(UINT32)); + gSettings.PatchDsdtLabel = (__typeof__(gSettings.PatchDsdtLabel))AllocateZeroPool (Count * sizeof(UINT8*)); + gSettings.PatchDsdtMenuItem = (__typeof__(gSettings.PatchDsdtMenuItem))AllocateZeroPool (Count * sizeof(INPUT_ITEM)); DBG ("PatchesDSDT: %d requested\n", Count); for (i = 0; i < Count; i++) { @@ -5630,7 +5632,7 @@ GetUserSettings( } DBG(" - [%02d]:", i); - DSDTPatchesLabel = AllocateZeroPool(256); + DSDTPatchesLabel = (__typeof__(DSDTPatchesLabel))AllocateZeroPool(256); Prop3 = GetProperty (Prop2, "Comment"); if (Prop3 != NULL && (Prop3->type == kTagTypeString) && Prop3->string) { @@ -5638,7 +5640,7 @@ GetUserSettings( } else { AsciiSPrint(DSDTPatchesLabel, 255, " (NoLabel)"); } - gSettings.PatchDsdtLabel[i] = AllocateZeroPool(256); + gSettings.PatchDsdtLabel[i] = (__typeof__(gSettings.PatchDsdtLabel[i]))AllocateZeroPool(256); AsciiSPrint(gSettings.PatchDsdtLabel[i], 255, "%a", DSDTPatchesLabel); DBG(" (%a)", gSettings.PatchDsdtLabel[i]); @@ -5654,7 +5656,7 @@ GetUserSettings( gSettings.PatchDsdtReplace[i] = GetDataSetting (Prop2, "Replace", &Size); DBG (", lenToReplace: %d", Size); gSettings.LenToReplace[i] = (UINT32)Size; - gSettings.PatchDsdtTgt[i] = GetDataSetting (Prop2, "TgtBridge", &Size); + gSettings.PatchDsdtTgt[i] = (CHAR8*)GetDataSetting (Prop2, "TgtBridge", &Size); DBG (", Target Bridge: %a\n", gSettings.PatchDsdtTgt[i]); if (!gSettings.PatchDsdtMenuItem[i].BValue) { DBG(" patch disabled at config\n"); @@ -5917,7 +5919,7 @@ GetUserSettings( Prop2 = NULL; if (Count > 0) { gSettings.SortedACPICount = 0; - gSettings.SortedACPI = AllocateZeroPool (Count * sizeof(CHAR16 *)); + gSettings.SortedACPI = (__typeof__(gSettings.SortedACPI))AllocateZeroPool (Count * sizeof(CHAR16 *)); for (i = 0; i < Count; i++) { if (!EFI_ERROR (GetElement (Prop, i, &Prop2)) && @@ -5937,7 +5939,7 @@ GetUserSettings( Prop2 = NULL; if (Count > 0) { gSettings.DisabledAMLCount = 0; - gSettings.DisabledAML = AllocateZeroPool (Count * sizeof(CHAR16 *)); + gSettings.DisabledAML = (__typeof__(gSettings.DisabledAML))AllocateZeroPool (Count * sizeof(CHAR16 *)); if (gSettings.DisabledAML) { for (i = 0; i < Count; i++) { @@ -5957,7 +5959,7 @@ GetUserSettings( INTN i, Count = GetTagCount(Prop); if (Count > 0) { gSettings.DeviceRenameCount = 0; - gSettings.DeviceRename = AllocateZeroPool(Count * sizeof(ACPI_NAME_LIST)); + gSettings.DeviceRename = (__typeof__(gSettings.DeviceRename))AllocateZeroPool(Count * sizeof(ACPI_NAME_LIST)); DBG("Devices to rename %d\n", Count); for (i = 0; i < Count; i++) { Prop2 = NULL; @@ -5972,7 +5974,7 @@ GetUserSettings( } Prop2 = Prop2->tag; if (Prop2->type == kTagTypeString) { - gSettings.DeviceRename[gSettings.DeviceRenameCount++].Name = AllocateCopyPool(5, Prop2->string); + gSettings.DeviceRename[gSettings.DeviceRenameCount++].Name = (__typeof__(gSettings.DeviceRename[gSettings.DeviceRenameCount++].Name))AllocateCopyPool(5, Prop2->string); DBG("->will be renamed to %a\n", Prop2->string); } } @@ -6311,7 +6313,7 @@ GetUserSettings( // MLB: some value Prop = GetProperty (DictPointer, "MLB"); if (Prop != NULL && AsciiStrLen (Prop->string) > 0) { - gSettings.RtMLB = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + gSettings.RtMLB = (__typeof__(gSettings.RtMLB))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } // CsrActiveConfig Prop = GetProperty (DictPointer, "CsrActiveConfig"); @@ -6331,7 +6333,7 @@ GetUserSettings( INTN i, Count = GetTagCount (Prop); CHAR16 UStr[64]; RtVariablesNum = 0; - RtVariables = AllocateZeroPool(Count * sizeof(RT_VARIABLES)); + RtVariables = (__typeof__(RtVariables))AllocateZeroPool(Count * sizeof(RT_VARIABLES)); for (i = 0; i < Count; i++) { Status = GetElement (Prop, i, &Dict); if (!EFI_ERROR(Status)) { @@ -6359,7 +6361,7 @@ GetUserSettings( RtVariables[RtVariablesNum].Name = NULL; if (Prop2 != NULL && AsciiStrLen(Prop2->string) > 0) { AsciiStrToUnicodeStrS(Prop2->string, (CHAR16*)&UStr[0], 64); - // RtVariables[RtVariablesNum].Name = AllocateCopyPool(128, UStr); + // RtVariables[RtVariablesNum].Name = (__typeof__(RtVariables[RtVariablesNum].Name))AllocateCopyPool(128, UStr); StrCpyS(RtVariables[RtVariablesNum].Name, 64, UStr); } RtVariablesNum++; @@ -6550,11 +6552,11 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) if (!EFI_ERROR (Status) && PlistBuffer != NULL && ParseXML (PlistBuffer, &Dict, 0) == EFI_SUCCESS) { Prop = GetProperty (Dict, "ProductVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - OSVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } Prop = GetProperty (Dict, "ProductBuildVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } } } @@ -6581,11 +6583,11 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) if (!EFI_ERROR (Status) && PlistBuffer != NULL && ParseXML (PlistBuffer, &Dict, 0) == EFI_SUCCESS) { Prop = GetProperty (Dict, "ProductVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - OSVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } Prop = GetProperty (Dict, "ProductBuildVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } } } @@ -6600,23 +6602,23 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) Prop = GetProperty (Dict, "Kernel Flags"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { if (AsciiStrStr (Prop->string, "Install%20OS%20X%20Mavericks.app")) { - OSVersion = AllocateCopyPool (5, "10.9"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (5, "10.9"); } else if (AsciiStrStr (Prop->string, "Install%20macOS%20Catalina") || AsciiStrStr (Prop->string, "Install%20macOS%2010.15")) { - OSVersion = AllocateCopyPool (6, "10.15"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (6, "10.15"); } else if (AsciiStrStr (Prop->string, "Install%20macOS%20Mojave") || AsciiStrStr (Prop->string, "Install%20macOS%2010.14")) { - OSVersion = AllocateCopyPool (6, "10.14"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (6, "10.14"); } else if (AsciiStrStr (Prop->string, "Install%20macOS%20High%20Sierra") || AsciiStrStr (Prop->string, "Install%20macOS%2010.13")) { - OSVersion = AllocateCopyPool (6, "10.13"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (6, "10.13"); } else if (AsciiStrStr (Prop->string, "Install%20macOS%20Sierra") || AsciiStrStr (Prop->string, "Install%20OS%20X%2010.12")) { - OSVersion = AllocateCopyPool (6, "10.12"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (6, "10.12"); } else if (AsciiStrStr (Prop->string, "Install%20OS%20X%20El%20Capitan") || AsciiStrStr (Prop->string, "Install%20OS%20X%2010.11")) { - OSVersion = AllocateCopyPool (6, "10.11"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (6, "10.11"); } else if (AsciiStrStr (Prop->string, "Install%20OS%20X%20Yosemite") || AsciiStrStr (Prop->string, "Install%20OS%20X%2010.10")) { - OSVersion = AllocateCopyPool (6, "10.10"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (6, "10.10"); } else if (AsciiStrStr (Prop->string, "Install%20OS%20X%20Mountain%20Lion")) { - OSVersion = AllocateCopyPool (5, "10.8"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (5, "10.8"); } else if (AsciiStrStr (Prop->string, "Install%20Mac%20OS%20X%20Lion")) { - OSVersion = AllocateCopyPool (5, "10.7"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (5, "10.7"); } } } @@ -6650,11 +6652,11 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) if (!EFI_ERROR (Status) && PlistBuffer != NULL && ParseXML (PlistBuffer, &Dict, 0) == EFI_SUCCESS) { Prop = GetProperty (Dict, "ProductVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - OSVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } Prop = GetProperty (Dict, "ProductBuildVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } // In InstallInfo.plist, there is no a version key only when updating from AppStore in 10.13+ // If use the startosinstall in 10.13+, this version key exists in InstallInfo.plist @@ -6662,7 +6664,7 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) if (DictPointer != NULL) { Prop = GetProperty (DictPointer, "version"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - OSVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } } } @@ -6674,7 +6676,10 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) // Implemented by Sherlocks if (OSVersion == NULL) { CHAR8 *s, *fileBuffer, *targetString; - CHAR8 *Res5 = AllocateZeroPool(5), *Res6 = AllocateZeroPool(6), *Res7 = AllocateZeroPool(7), *Res8 = AllocateZeroPool(8); + CHAR8 *Res5 = (__typeof__(Res5))AllocateZeroPool(5); + CHAR8 *Res6 = (__typeof__(Res6))AllocateZeroPool(6); + CHAR8 *Res7 = (__typeof__(Res7))AllocateZeroPool(7); + CHAR8 *Res8 = (__typeof__(Res8))AllocateZeroPool(8); UINTN fileLen = 0; CHAR16 *InstallerLog = L"\\Mac OS X Install Data\\ia.log"; // 10.7 if (!FileExists (Entry->Volume->RootDir, InstallerLog)) { @@ -6691,49 +6696,49 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) s = SearchString(targetString, fileLen, "Running OS Build: Mac OS X ", 27); if (s[31] == ' ') { AsciiSPrint (Res5, 5, "%c%c.%c\n", s[27], s[28], s[30]); - OSVersion = AllocateCopyPool (AsciiStrSize (Res5), Res5); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res5), Res5); if (s[38] == ')') { AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[33], s[34], s[35], s[36], s[37]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res6), Res6); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); } else if (s[39] == ')') { AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[33], s[34], s[35], s[36], s[37], s[38]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res7), Res7); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); } } else if (s[31] == '.') { AsciiSPrint (Res7, 7, "%c%c.%c.%c\n", s[27], s[28], s[30], s[32]); - OSVersion = AllocateCopyPool (AsciiStrSize (Res7), Res7); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); if (s[40] == ')') { AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[35], s[36], s[37], s[38], s[39]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res6), Res6); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); } else if (s[41] == ')') { AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[35], s[36], s[37], s[38], s[39], s[40]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res7), Res7); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); } } else if (s[32] == ' ') { AsciiSPrint (Res6, 6, "%c%c.%c%c\n", s[27], s[28], s[30], s[31]); - OSVersion = AllocateCopyPool (AsciiStrSize (Res6), Res6); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); if (s[39] == ')') { AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res6), Res6); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); } else if (s[40] == ')') { AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38], s[39]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res7), Res7); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); } else if (s[41] == ')') { AsciiSPrint (Res8, 8, "%c%c%c%c%c%c%c\n", s[34], s[35], s[36], s[37], s[38], s[39], s[40]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res8), Res8); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8); } } else if (s[32] == '.') { AsciiSPrint (Res8, 8, "%c%c.%c%c.%c\n", s[27], s[28], s[30], s[31], s[33]); - OSVersion = AllocateCopyPool (AsciiStrSize (Res8), Res8); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8); if (s[41] == ')') { AsciiSPrint (Res6, 6, "%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res6), Res6); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res6), Res6); } else if (s[42] == ')') { AsciiSPrint (Res7, 7, "%c%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40], s[41]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res7), Res7); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res7), Res7); } else if (s[43] == ')') { AsciiSPrint (Res8, 8, "%c%c%c%c%c%c%c\n", s[36], s[37], s[38], s[39], s[40], s[41], s[42]); - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Res8), Res8); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Res8), Res8); } } FreePool(fileBuffer); @@ -6755,11 +6760,11 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) if (!EFI_ERROR (Status) && PlistBuffer != NULL && ParseXML (PlistBuffer, &Dict, 0) == EFI_SUCCESS) { Prop = GetProperty (Dict, "ProductVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - OSVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } Prop = GetProperty (Dict, "ProductBuildVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } } } @@ -6778,16 +6783,16 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) if (!EFI_ERROR (Status) && PlistBuffer != NULL && ParseXML (PlistBuffer, &Dict, 0) == EFI_SUCCESS) { Prop = GetProperty (Dict, "ProductVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - OSVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } Prop = GetProperty (Dict, "ProductBuildVersion"); if (Prop != NULL && Prop->string != NULL && Prop->string[0] != '\0') { - Entry->BuildVersion = AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); + Entry->BuildVersion = (__typeof__(Entry->BuildVersion))AllocateCopyPool (AsciiStrSize (Prop->string), Prop->string); } } } else if (FileExists (Entry->Volume->RootDir, L"\\com.apple.recovery.boot\\boot.efi")) { // Special case - com.apple.recovery.boot/boot.efi exists but SystemVersion.plist doesn't --> 10.9 recovery - OSVersion = AllocateCopyPool (5, "10.9"); + OSVersion = (__typeof__(OSVersion))AllocateCopyPool (5, "10.9"); } } @@ -8144,7 +8149,7 @@ SetDevices (LOADER_ENTRY *Entry) EFI_PHYSICAL_ADDRESS BufferPtr = EFI_SYSTEM_TABLE_MAX_ADDRESS; //0xFE000000; device_inject_stringlength = device_inject_string->length * 2; DBG ("stringlength = %d\n", device_inject_stringlength); - // gDeviceProperties = AllocateAlignedPages EFI_SIZE_TO_PAGES (device_inject_stringlength + 1), 64); + // gDeviceProperties = (__typeof__(gDeviceProperties))AllocateAlignedPages EFI_SIZE_TO_PAGES (device_inject_stringlength + 1), 64); Status = gBS->AllocatePages ( AllocateMaxAddress, @@ -8155,7 +8160,7 @@ SetDevices (LOADER_ENTRY *Entry) if (!EFI_ERROR (Status)) { mProperties = (UINT8*)(UINTN)BufferPtr; - gDeviceProperties = (VOID*)devprop_generate_string (device_inject_string); + gDeviceProperties = devprop_generate_string (device_inject_string); gDeviceProperties[device_inject_stringlength] = 0; // DBG (gDeviceProperties); // DBG ("\n"); diff --git a/rEFIt_UEFI/Platform/StartupSound.c b/rEFIt_UEFI/Platform/StartupSound.c index 7bdc1b56e..f0cf5f8f0 100644 --- a/rEFIt_UEFI/Platform/StartupSound.c +++ b/rEFIt_UEFI/Platform/StartupSound.c @@ -165,7 +165,7 @@ StartupSoundPlay(EFI_FILE *Dir, CHAR16* SoundFile) DBG("not found wave data\n"); goto DONE_ERROR; } - TempData = AllocateZeroPool(Len * sizeof(INT16)); + TempData = (__typeof__(TempData))AllocateZeroPool(Len * sizeof(INT16)); Tmp = *(Ptr++); for (Ind = 0; Ind < WaveData.SamplesLength / 2 - 1; Ind++) { Next = *(Ptr++); @@ -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; diff --git a/rEFIt_UEFI/Platform/StateGenerator.c b/rEFIt_UEFI/Platform/StateGenerator.c index 0876724ed..f35f61721 100644 --- a/rEFIt_UEFI/Platform/StateGenerator.c +++ b/rEFIt_UEFI/Platform/StateGenerator.c @@ -421,7 +421,7 @@ SSDT_TABLE *generate_pss_ssdt(UINTN Number) aml_calculate_size(root); ssdt = (SSDT_TABLE *)AllocateZeroPool(root->Size); - aml_write_node(root, (VOID*)ssdt, 0); + aml_write_node(root, (CHAR8*)ssdt, 0); ssdt->Length = root->Size; FixChecksum(ssdt); //ssdt->Checksum = 0; @@ -641,7 +641,7 @@ SSDT_TABLE *generate_cst_ssdt(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE* fadt, U ssdt = (SSDT_TABLE *)AllocateZeroPool(root->Size); - aml_write_node(root, (VOID*)ssdt, 0); + aml_write_node(root, (CHAR8*)ssdt, 0); ssdt->Length = root->Size; FixChecksum(ssdt); diff --git a/rEFIt_UEFI/Platform/ati.c b/rEFIt_UEFI/Platform/ati.c index b802b3794..5adb58b93 100644 --- a/rEFIt_UEFI/Platform/ati.c +++ b/rEFIt_UEFI/Platform/ati.c @@ -1226,7 +1226,7 @@ BOOLEAN get_bootdisplay_val(value_t *val, INTN index, BOOLEAN Sier) v = 1; val->type = kCst; val->size = 4; - val->data = AllocatePool(4); + val->data = (__typeof__(val->data))AllocatePool(4); *(val->data) = (UINT8)v; return TRUE; } @@ -1248,7 +1248,7 @@ BOOLEAN get_dual_link_val(value_t *val, INTN index, BOOLEAN Sier) val->type = kCst; val->size = 4; - val->data = AllocatePool(4); + val->data = (__typeof__(val->data))AllocatePool(4); *(val->data) = (UINT8)v; return TRUE; } @@ -1276,7 +1276,7 @@ BOOLEAN get_edid_val(value_t *val, INTN index, BOOLEAN Sier) v = 1; val->type = kPtr; val->size = 128; - val->data = AllocateCopyPool(val->size, gSettings.CustomEDID); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, gSettings.CustomEDID); return TRUE; } @@ -1292,7 +1292,7 @@ BOOLEAN get_display_type(value_t *val, INTN index, BOOLEAN Sier) } val->type = kStr; val->size = (UINT32)AsciiStrSize(dtyp[dti]); - val->data = AllocateCopyPool(val->size, (UINT8 *)dtyp[dti]); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)dtyp[dti]); return TRUE; } @@ -1301,7 +1301,7 @@ BOOLEAN get_name_val(value_t *val, INTN index, BOOLEAN Sier) { val->type = aty_name.type; val->size = aty_name.size; - val->data = AllocateCopyPool(aty_name.size, (UINT8 *)aty_name.data); + val->data = (__typeof__(val->data))AllocateCopyPool(aty_name.size, (UINT8 *)aty_name.data); return TRUE; } @@ -1309,14 +1309,14 @@ BOOLEAN get_nameparent_val(value_t *val, INTN index, BOOLEAN Sier) { val->type = aty_nameparent.type; val->size = aty_nameparent.size; - val->data = AllocateCopyPool(aty_nameparent.size, (UINT8 *)aty_nameparent.data); + val->data = (__typeof__(val->data))AllocateCopyPool(aty_nameparent.size, (UINT8 *)aty_nameparent.data); return TRUE; } //static CHAR8 pciName[15]; BOOLEAN get_name_pci_val(value_t *val, INTN index, BOOLEAN Sier) { - CHAR8* pciName = AllocateZeroPool(15); + CHAR8* pciName = (__typeof__(pciName))AllocateZeroPool(15); if (!card->info->model_name || !gSettings.FakeATI) { return FALSE; @@ -1333,14 +1333,14 @@ BOOLEAN get_name_pci_val(value_t *val, INTN index, BOOLEAN Sier) CONST CHAR8* NamePolaris = "AMD Radeon %a"; BOOLEAN get_model_val(value_t *val, INTN index, BOOLEAN Sier) { - CHAR8 *ModelName = AllocateZeroPool(35); + CHAR8 *ModelName = (__typeof__(ModelName))AllocateZeroPool(35); if (!card->info->model_name) { return FALSE; } val->type = kStr; if (card->pci_dev->device_id != 0x67DF) { val->size = (UINT32)AsciiStrLen(card->info->model_name); - val->data = AllocateCopyPool(val->size, (UINT8 *)card->info->model_name); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)card->info->model_name); } else { switch (card->pci_dev->revision) { case 0xC4: @@ -1366,7 +1366,7 @@ BOOLEAN get_model_val(value_t *val, INTN index, BOOLEAN Sier) break; } val->size = (UINT32)AsciiStrLen(ModelName); - val->data = AllocateCopyPool(val->size, ModelName); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, ModelName); } FreePool(ModelName); return TRUE; @@ -1403,7 +1403,7 @@ BOOLEAN get_conntype_val(value_t *val, INTN index, BOOLEAN Sier) val->type = kCst; val->size = 4; - val->data = AllocateCopyPool(val->size, (UINT8 *)&ct[index * Len]); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)&ct[index * Len]); // cti++; // if(cti > 3) cti = 0; @@ -1423,7 +1423,7 @@ BOOLEAN get_vrammemsize_val(value_t *val, INTN index, BOOLEAN Sier) } val->type = kCst; val->size = 8; - val->data = AllocateCopyPool(val->size, (UINT8 *)&memsize); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)&memsize); return TRUE; } @@ -1434,7 +1434,7 @@ BOOLEAN get_binimage_val(value_t *val, INTN index, BOOLEAN Sier) } val->type = kPtr; val->size = card->rom_size; - val->data = AllocateCopyPool(val->size, (UINT8 *)card->rom); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)card->rom); return TRUE; } @@ -1445,7 +1445,7 @@ BOOLEAN get_binimage_owr(value_t *val, INTN index, BOOLEAN Sier) } val->type = kCst; val->size = 4; - val->data = AllocatePool(4); + val->data = (__typeof__(val->data))AllocatePool(4); *(val->data) = 1; return TRUE; } @@ -1457,7 +1457,7 @@ BOOLEAN get_romrevision_val(value_t *val, INTN index, BOOLEAN Sier) if (!card->rom){ val->type = kPtr; val->size = 13; - val->data = AllocateCopyPool(val->size, cRev); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, cRev); return TRUE; } @@ -1469,7 +1469,7 @@ BOOLEAN get_romrevision_val(value_t *val, INTN index, BOOLEAN Sier) rev = (UINT8 *)cRev; val->size = 13; } - val->data = AllocateCopyPool(val->size, rev); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, rev); return TRUE; } @@ -1477,7 +1477,7 @@ BOOLEAN get_deviceid_val(value_t *val, INTN index, BOOLEAN Sier) { val->type = kCst; val->size = 2; - val->data = AllocateCopyPool(val->size, (UINT8 *)&card->pci_dev->device_id); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)&card->pci_dev->device_id); return TRUE; } @@ -1499,13 +1499,13 @@ BOOLEAN get_refclk_val(value_t *val, INTN index, BOOLEAN Sier) // val->type = kCst; val->size = 4; - val->data = AllocateCopyPool(val->size, (UINT8 *)&gSettings.RefCLK); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)&gSettings.RefCLK); return TRUE; } BOOLEAN get_platforminfo_val(value_t *val, INTN index, BOOLEAN Sier) { - val->data = AllocateZeroPool(0x80); + val->data = (__typeof__(val->data))AllocateZeroPool(0x80); if (!val->data) return FALSE; @@ -1522,7 +1522,7 @@ BOOLEAN get_vramtotalsize_val(value_t *val, INTN index, BOOLEAN Sier) val->type = kCst; val->size = 4; - val->data = AllocateCopyPool(val->size, (UINT8 *)&card->vram_size); + val->data = (__typeof__(val->data))AllocateCopyPool(val->size, (UINT8 *)&card->vram_size); return TRUE; } @@ -1548,7 +1548,7 @@ VOID devprop_add_list(AtiDevProp devprop_list[], CHAR8 *OSVersion) { INTN i, pnum; BOOLEAN Sier; - value_t *val = AllocateZeroPool(sizeof(value_t)); + value_t *val = (__typeof__(val))AllocateZeroPool(sizeof(value_t)); Sier = (AsciiOSVersionToUint64(OSVersion) >= AsciiOSVersionToUint64("10.12")); @@ -1647,7 +1647,7 @@ BOOLEAN load_vbios_file(UINT16 vendor_id, UINT16 device_id) } DBG("Loaded ROM len=%d\n", bufferLen); card->rom_size = (UINT32)bufferLen; - card->rom = AllocateZeroPool(bufferLen); + card->rom = (__typeof__(card->rom))AllocateZeroPool(bufferLen); if (!card->rom) { return FALSE; } @@ -1728,7 +1728,7 @@ BOOLEAN read_vbios(BOOLEAN from_pci) return FALSE; } - card->rom = AllocateZeroPool(card->rom_size); + card->rom = (__typeof__(card->rom))AllocateZeroPool(card->rom_size); if (!card->rom) { return FALSE; } @@ -1897,7 +1897,7 @@ BOOLEAN devprop_add_pci_config_space(VOID) { int offset; - UINT8 *config_space = AllocateZeroPool(0x100); + UINT8 *config_space = (__typeof__(config_space))AllocateZeroPool(0x100); if (!config_space) return FALSE; @@ -1924,7 +1924,7 @@ static BOOLEAN init_card(pci_dt_t *pci_dev) UINTN ExpansionRom = 0; UINTN Reg1, Reg3, Reg5; - card = AllocateZeroPool(sizeof(card_t)); + card = (__typeof__(card))AllocateZeroPool(sizeof(card_t)); if (!card) { return FALSE; } @@ -1934,7 +1934,7 @@ static BOOLEAN init_card(pci_dt_t *pci_dev) if (radeon_cards[i].device_id != pci_dev->device_id) { continue; } - card->info = AllocateCopyPool(sizeof(radeon_card_info_t), &radeon_cards[i]); + card->info = (__typeof__(card->info))AllocateCopyPool(sizeof(radeon_card_info_t), &radeon_cards[i]); if (!card->info->cfg_name) { card->info->cfg_name = kRadeon; } @@ -1957,7 +1957,7 @@ static BOOLEAN init_card(pci_dt_t *pci_dev) DBG("search for brothers family\n"); for (i = 0; radeon_cards[i].device_id ; i++) { if ((radeon_cards[i].device_id & ~0xf) == (pci_dev->device_id & ~0xf)) { - card->info = AllocateCopyPool(sizeof(radeon_card_info_t), &radeon_cards[i]); + card->info = (__typeof__(card->info))AllocateCopyPool(sizeof(radeon_card_info_t), &radeon_cards[i]); break; } } @@ -2019,7 +2019,7 @@ static BOOLEAN init_card(pci_dt_t *pci_dev) NameLen = StrLen(gSettings.FBName); if (NameLen > 2) { //fool proof: cfg_name is 3 character or more. - CfgName = AllocateZeroPool(NameLen); + CfgName = (__typeof__(CfgName))AllocateZeroPool(NameLen); UnicodeStrToAsciiStrS((CHAR16*)&gSettings.FBName[0], CfgName, 16); DBG("Users config name %a\n", CfgName); card->cfg_name = CfgName; @@ -2057,13 +2057,13 @@ static BOOLEAN init_card(pci_dt_t *pci_dev) DBG("Nr of ports set to min: %d\n", card->ports); } // - name = AllocateZeroPool(24); + name = (__typeof__(name))AllocateZeroPool(24); AsciiSPrint(name, 24, "ATY,%a", card->cfg_name); aty_name.type = kStr; aty_name.size = (UINT32)AsciiStrLen(name); aty_name.data = (UINT8 *)name; - name_parent = AllocateZeroPool(24); + name_parent = (__typeof__(name_parent))AllocateZeroPool(24); AsciiSPrint(name_parent, 24, "ATY,%aParent", card->cfg_name); aty_nameparent.type = kStr; aty_nameparent.size = (UINT32)AsciiStrLen(name_parent); diff --git a/rEFIt_UEFI/Platform/b64cdecode.c b/rEFIt_UEFI/Platform/b64cdecode.c index 2efa73da0..91fc81ca1 100644 --- a/rEFIt_UEFI/Platform/b64cdecode.c +++ b/rEFIt_UEFI/Platform/b64cdecode.c @@ -107,7 +107,7 @@ UINT8 *Base64DecodeClover(IN CHAR8 *EncodedData, OUT UINTN *DecodedSize) return NULL; } // to simplify, we'll allocate the same size, although smaller size is needed - DecodedData = AllocateZeroPool(EncodedSize); + DecodedData = (__typeof__(DecodedData))AllocateZeroPool(EncodedSize); base64_init_decodestate(&state_in); DecodedSizeInternal = base64_decode_block(EncodedData, (const int)EncodedSize, (char*) DecodedData, &state_in); diff --git a/rEFIt_UEFI/Platform/card_vlist.c b/rEFIt_UEFI/Platform/card_vlist.c index 54e520a45..c65e2533c 100644 --- a/rEFIt_UEFI/Platform/card_vlist.c +++ b/rEFIt_UEFI/Platform/card_vlist.c @@ -70,7 +70,7 @@ LIST_ENTRY gCardList = INITIALIZE_LIST_HEAD_VARIABLE (gCardList); VOID AddCard(CONST CHAR8* Model, UINT32 Id, UINT32 SubId, UINT64 VideoRam, UINTN VideoPorts, BOOLEAN LoadVBios) { CARDLIST* new_card; - new_card = AllocateZeroPool(sizeof(CARDLIST)); + new_card = (__typeof__(new_card))AllocateZeroPool(sizeof(CARDLIST)); if (new_card) { new_card->Signature = CARDLIST_SIGNATURE; new_card->Id = Id; diff --git a/rEFIt_UEFI/Platform/device_inject.c b/rEFIt_UEFI/Platform/device_inject.c index d8449f872..79a9b5d84 100644 --- a/rEFIt_UEFI/Platform/device_inject.c +++ b/rEFIt_UEFI/Platform/device_inject.c @@ -74,7 +74,7 @@ CHAR8 *get_pci_dev_path(pci_dt_t *PciDt) return NULL; devpathstr = FileDevicePathToStr(DevicePath); Size = StrLen(devpathstr) + 1; - tmp = AllocateZeroPool(Size); + tmp = (__typeof__(tmp))AllocateZeroPool(Size); UnicodeStrToAsciiStrS(devpathstr, tmp, Size); return tmp; @@ -137,7 +137,7 @@ DevPropDevice *devprop_add_device_pci(DevPropString *StringBuf, pci_dt_t *PciDt, if (!DevicePath) return NULL; - device = AllocateZeroPool(sizeof(DevPropDevice)); + device = (__typeof__(device))AllocateZeroPool(sizeof(DevPropDevice)); if (!device) { return NULL; } diff --git a/rEFIt_UEFI/Platform/kernel_patcher.c b/rEFIt_UEFI/Platform/kernel_patcher.c index 4b62c6e64..8f117b900 100644 --- a/rEFIt_UEFI/Platform/kernel_patcher.c +++ b/rEFIt_UEFI/Platform/kernel_patcher.c @@ -31,7 +31,7 @@ BootArgs1 *bootArgs1 = NULL; BootArgs2 *bootArgs2 = NULL; CHAR8 *dtRoot = NULL; UINT32 *dtLength; -VOID *KernelData = NULL; +UINT8 *KernelData = NULL; UINT32 KernelSlide = 0; BOOLEAN isKernelcache = FALSE; BOOLEAN is64BitKernel = FALSE; @@ -1831,9 +1831,9 @@ KernelAndKextPatcherInit(IN LOADER_ENTRY *Entry) UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion); if (os_version < AsciiOSVersionToUint64("10.6")) { - KernelData = (VOID*)(UINTN)(KernelSlide + KernelRelocBase + 0x00111000); + KernelData = (UINT8*)(UINTN)(KernelSlide + KernelRelocBase + 0x00111000); } else { - KernelData = (VOID*)(UINTN)(KernelSlide + KernelRelocBase + 0x00200000); + KernelData = (UINT8*)(UINTN)(KernelSlide + KernelRelocBase + 0x00200000); } // check that it is Mach-O header and detect architecture diff --git a/rEFIt_UEFI/Platform/kernel_patcher.h b/rEFIt_UEFI/Platform/kernel_patcher.h index c61e0f886..03f6f41a7 100644 --- a/rEFIt_UEFI/Platform/kernel_patcher.h +++ b/rEFIt_UEFI/Platform/kernel_patcher.h @@ -77,7 +77,7 @@ extern BootArgs1 *bootArgs1; extern BootArgs2 *bootArgs2; extern CHAR8 *dtRoot; extern UINT32 *dtLength; -extern VOID *KernelData; +extern UINT8 *KernelData; extern UINT32 KernelSlide; extern BOOLEAN isKernelcache; extern BOOLEAN is64BitKernel; diff --git a/rEFIt_UEFI/Platform/kext_inject.c b/rEFIt_UEFI/Platform/kext_inject.c index cd2c31d0e..81e94cbcb 100644 --- a/rEFIt_UEFI/Platform/kext_inject.c +++ b/rEFIt_UEFI/Platform/kext_inject.c @@ -194,7 +194,7 @@ EFI_STATUS EFIAPI LoadKext(IN LOADER_ENTRY *Entry, IN EFI_FILE *RootDir, IN CHAR } } bundlePathBufferLength = StrLen(FileName) + 1; - bundlePathBuffer = AllocateZeroPool(bundlePathBufferLength); + bundlePathBuffer = (__typeof__(bundlePathBuffer))AllocateZeroPool(bundlePathBufferLength); UnicodeStrToAsciiStrS(FileName, bundlePathBuffer, bundlePathBufferLength); kext->length = (UINT32)(sizeof(_BooterKextFileInfo) + infoDictBufferLength + executableBufferLength + bundlePathBufferLength); @@ -221,7 +221,7 @@ EFI_STATUS EFIAPI AddKext(IN LOADER_ENTRY *Entry, IN EFI_FILE *RootDir, IN CHAR1 EFI_STATUS Status; KEXT_ENTRY *KextEntry; - KextEntry = AllocatePool (sizeof(KEXT_ENTRY)); + KextEntry = (__typeof__(KextEntry))AllocatePool (sizeof(KEXT_ENTRY)); KextEntry->Signature = KEXT_SIGNATURE; Status = LoadKext(Entry, RootDir, FileName, archCpuType, &KextEntry->kext); if(EFI_ERROR(Status)) { @@ -540,10 +540,10 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry) // reserve space in the device tree if (GetKextCount() > 0) { mm_extra_size = GetKextCount() * (sizeof(DeviceTreeNodeProperty) + sizeof(_DeviceTreeBuffer)); - mm_extra = AllocateZeroPool(mm_extra_size - sizeof(DeviceTreeNodeProperty)); + mm_extra = (__typeof__(mm_extra))AllocateZeroPool(mm_extra_size - sizeof(DeviceTreeNodeProperty)); /*Status = */LogDataHub(&gEfiMiscSubClassGuid, L"mm_extra", mm_extra, (UINT32)(mm_extra_size - sizeof(DeviceTreeNodeProperty))); extra_size = GetKextsSize(); - extra = AllocateZeroPool(extra_size - sizeof(DeviceTreeNodeProperty) + EFI_PAGE_SIZE); + extra = (__typeof__(extra))AllocateZeroPool(extra_size - sizeof(DeviceTreeNodeProperty) + EFI_PAGE_SIZE); /*Status = */LogDataHub(&gEfiMiscSubClassGuid, L"extra", extra, (UINT32)(extra_size - sizeof(DeviceTreeNodeProperty) + EFI_PAGE_SIZE)); // MsgLog("count: %d \n", GetKextCount()); // MsgLog("mm_extra_size: %d \n", mm_extra_size); @@ -721,7 +721,7 @@ EFI_STATUS InjectKexts(/*IN EFI_MEMORY_DESCRIPTOR *Desc*/ IN UINT32 deviceTreeP, } } - if (Entry->KernelAndKextPatches->KPDebug) { + if (Entry->KernelAndKextPatches->KPDebug) { DBG_RT(Entry, "Done.\n"); gBS->Stall(5000000); } diff --git a/rEFIt_UEFI/Platform/nvidia.c b/rEFIt_UEFI/Platform/nvidia.c index 35432ddd7..c2bc71fb0 100644 --- a/rEFIt_UEFI/Platform/nvidia.c +++ b/rEFIt_UEFI/Platform/nvidia.c @@ -2289,7 +2289,7 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) } if (EFI_ERROR(Status)) { - rom = AllocateZeroPool(NVIDIA_ROM_SIZE+1); + rom = (__typeof__(rom))AllocateZeroPool(NVIDIA_ROM_SIZE+1); // PRAMIN first read_nVidia_PRAMIN(nvda_dev, rom, nvCardType); @@ -2316,7 +2316,7 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) if (buffer[i] == 0x55 && buffer[i+1] == 0xaa) { DBG(" header found at: %d\n", i); bufferLen -= i; - rom = AllocateZeroPool(bufferLen); + rom = (__typeof__(rom))AllocateZeroPool(bufferLen); for (j = 0; j < bufferLen; j++) { rom[j] = buffer[i+j]; } diff --git a/rEFIt_UEFI/Platform/picopng.c b/rEFIt_UEFI/Platform/picopng.c index 77d94d084..ac369a0cf 100644 --- a/rEFIt_UEFI/Platform/picopng.c +++ b/rEFIt_UEFI/Platform/picopng.c @@ -86,7 +86,7 @@ void png_alloc_add_node(void *addr, UINT32 size) png_alloc_node_t *node; if (png_alloc_find_node(addr, size)) return; - node = AllocateZeroPool(sizeof (png_alloc_node_t)); + node = (__typeof__(node))AllocateZeroPool(sizeof (png_alloc_node_t)); node->addr = addr; node->size = size; node->prev = png_alloc_tail; @@ -114,7 +114,7 @@ void png_alloc_remove_node(png_alloc_node_t *node) void *png_alloc_malloc(UINT32 size) { - void *addr = AllocateZeroPool(size); + void *addr = (__typeof__(addr))AllocateZeroPool(size); png_alloc_add_node(addr, size); return addr; } @@ -127,7 +127,7 @@ void *png_alloc_realloc(void *addr, UINT32 oldSize, UINT32 newSize) if ( newSize > oldSize ) { png_alloc_node_t *old_node = png_alloc_find_node(addr, oldSize); if (old_node) { - void *new_addr = ReallocatePool(oldSize, newSize, addr); + void *new_addr = (__typeof__(new_addr))ReallocatePool(oldSize, newSize, addr); old_node->addr = new_addr; old_node->size = newSize; return new_addr; diff --git a/rEFIt_UEFI/Platform/platformdata.c b/rEFIt_UEFI/Platform/platformdata.c index 64f9343ce..d063c2720 100644 --- a/rEFIt_UEFI/Platform/platformdata.c +++ b/rEFIt_UEFI/Platform/platformdata.c @@ -541,7 +541,8 @@ PLATFORMDATA ApplePlatformData[] = VOID SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) { const CHAR8 *i; - CHAR8 *Res1 = AllocateZeroPool(9), *Res2 = AllocateZeroPool(11); + CHAR8 *Res1 = (__typeof__(Res1))AllocateZeroPool(9); + CHAR8 *Res2 = (__typeof__(Res2))AllocateZeroPool(11); AsciiStrCpyS (gSettings.VendorName, 64, BiosVendor); AsciiStrCpyS (gSettings.RomVersion, 64, ApplePlatformData[Model].firmwareVersion); @@ -1301,9 +1302,9 @@ VOID SetDMISettingsForModel(MACHINE_TYPES Model, BOOLEAN Redefine) MACHINE_TYPES GetModelFromString(CHAR8 *ProductName) { - UINTN i; + MACHINE_TYPES i; - for (i = 0; i < MaxMachineType; ++i) { + for (i = (MACHINE_TYPES)(0); i < MaxMachineType; i = (MACHINE_TYPES)(i + 1)) { if (AsciiStrCmp (ApplePlatformData[i].productName, ProductName) == 0) { return i; } @@ -1358,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); diff --git a/rEFIt_UEFI/Platform/plist.c b/rEFIt_UEFI/Platform/plist.c index 8044bf4a2..a832de092 100644 --- a/rEFIt_UEFI/Platform/plist.c +++ b/rEFIt_UEFI/Platform/plist.c @@ -94,7 +94,7 @@ XMLDecode(CHAR8* src) len = AsciiStrLen(src); #if 0 - out = AllocateZeroPool(len+1); + out = (__typeof__(out))AllocateZeroPool(len+1); if (!out) return 0; #else // unsafe @@ -213,7 +213,7 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagPtr * dict, UINT32 bufSize) return EFI_INVALID_PARAMETER; } - configBuffer = AllocateZeroPool(bufferSize+1); + configBuffer = (__typeof__(configBuffer))AllocateZeroPool(bufferSize+1); if(configBuffer == NULL) { return EFI_OUT_OF_RESOURCES; } diff --git a/rEFIt_UEFI/Platform/smbios.c b/rEFIt_UEFI/Platform/smbios.c index 0d077ff5d..c696617d4 100644 --- a/rEFIt_UEFI/Platform/smbios.c +++ b/rEFIt_UEFI/Platform/smbios.c @@ -180,16 +180,16 @@ VOID* GetSmbiosTablesFromHob (VOID) EFI_PHYSICAL_ADDRESS *Table; EFI_PEI_HOB_POINTERS GuidHob; - GuidHob.Raw = GetFirstGuidHob (&gEfiSmbiosTableGuid); + GuidHob.Raw = (__typeof(GuidHob.Raw))GetFirstGuidHob (&gEfiSmbiosTableGuid); if (GuidHob.Raw != NULL) { - Table = GET_GUID_HOB_DATA (GuidHob.Guid); + Table = (__typeof(Table))GET_GUID_HOB_DATA (GuidHob.Guid); if (Table != NULL) { return (VOID *)(UINTN)*Table; } } - GuidHob.Raw = GetFirstGuidHob (&gEfiSmbios3TableGuid); + GuidHob.Raw = (__typeof(GuidHob.Raw))GetFirstGuidHob (&gEfiSmbios3TableGuid); if (GuidHob.Raw != NULL) { - Table = GET_GUID_HOB_DATA (GuidHob.Guid); + Table = (__typeof(Table))GET_GUID_HOB_DATA (GuidHob.Guid); if (Table != NULL) { return (VOID *)(UINTN)*Table; } @@ -2022,8 +2022,8 @@ EFI_STATUS PrepatchSmbios() } //Create space for SPD - //gRAM = AllocateZeroPool(sizeof(MEM_STRUCTURE)); - //gDMI = AllocateZeroPool(sizeof(DMI)); + //gRAM = (__typeof__(gRAM))AllocateZeroPool(sizeof(MEM_STRUCTURE)); + //gDMI = (__typeof__(gDMI))AllocateZeroPool(sizeof(DMI)); //Collect information for use in menu GetTableType1(); @@ -2085,14 +2085,14 @@ VOID FinalizeSmbios() //continue BOOLEAN FoundTable3 = FALSE; // Get Hob List - HobStart.Raw = GetHobList (); + HobStart.Raw = (__typeof(HobStart.Raw))GetHobList(); if (HobStart.Raw != NULL) { // find SMBIOS in hob for (Index = 0; Index < sizeof (gTableGuidArray) / sizeof (*gTableGuidArray); ++Index) { - GuidHob.Raw = GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw); + GuidHob.Raw = (__typeof(HobStart.Raw))GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw); if (GuidHob.Raw != NULL) { - Table = GET_GUID_HOB_DATA (GuidHob.Guid); + Table = (__typeof(Table))GET_GUID_HOB_DATA (GuidHob.Guid); //TableLength = GET_GUID_HOB_DATA_SIZE (GuidHob); if (Table != NULL) { if (Index != 0) { diff --git a/rEFIt_UEFI/Platform/spd.c b/rEFIt_UEFI/Platform/spd.c index c4cd2f2f7..952ef3be9 100644 --- a/rEFIt_UEFI/Platform/spd.c +++ b/rEFIt_UEFI/Platform/spd.c @@ -540,7 +540,7 @@ UINT16 getDDRspeedMhz(UINT8 * spd) CHAR8* getDDRSerial(UINT8* spd) { CHAR8* asciiSerial; //[16]; - asciiSerial = AllocatePool(17); + asciiSerial = (__typeof__(asciiSerial))AllocatePool(17); if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR4) { // DDR4 AsciiSPrint(asciiSerial, 17, "%2X%2X%2X%2X%2X%2X%2X%2X", SMST(325) /*& 0x7*/, SLST(325), SMST(326), SLST(326), SMST(327), SLST(327), SMST(328), SLST(328)); } else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { // DDR3 @@ -560,7 +560,7 @@ CHAR8* getDDRPartNum(UINT8* spd, UINT32 base, UINT8 slot) { UINT16 i, start=0, index = 0; CHAR8 c; - CHAR8* asciiPartNo = AllocatePool(32); //[32]; + CHAR8* asciiPartNo = (__typeof__(asciiPartNo))AllocatePool(32); //[32]; if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR4) { start = 329; @@ -671,7 +671,7 @@ STATIC VOID read_smb(EFI_PCI_IO_PROTOCOL *PciIo, UINT16 vid, UINT16 did) // needed at least for laptops //fullBanks = (gDMI->MemoryModules == gDMI->CntMemorySlots); - spdbuf = AllocateZeroPool(MAX_SPD_SIZE); + spdbuf = (__typeof__(spdbuf))AllocateZeroPool(MAX_SPD_SIZE); // Search MAX_RAM_SLOTS slots //==> diff --git a/rEFIt_UEFI/entry_scan/common.c b/rEFIt_UEFI/entry_scan/common.c index 64b595e90..f4adf2682 100644 --- a/rEFIt_UEFI/entry_scan/common.c +++ b/rEFIt_UEFI/entry_scan/common.c @@ -147,7 +147,7 @@ LOADER_ENTRY * DuplicateLoaderEntry(IN LOADER_ENTRY *Entry) if(Entry == NULL) { return NULL; } - DuplicateEntry = AllocateZeroPool(sizeof(LOADER_ENTRY)); + DuplicateEntry = (__typeof__(DuplicateEntry))AllocateZeroPool(sizeof(LOADER_ENTRY)); if (DuplicateEntry) { DuplicateEntry->me.Tag = Entry->me.Tag; DuplicateEntry->me.AtClick = ActionEnter; @@ -226,7 +226,7 @@ CHAR16 *RemoveLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption) NewLoadOptions = EfiStrDuplicate(LoadOptions + OptionLength); } else { // The rest of LoadOptions is Length - OptionLength, but we may need additional space and ending 0 - NewLoadOptions = AllocateZeroPool((Length - OptionLength + 2) * sizeof(CHAR16)); + NewLoadOptions = (__typeof__(NewLoadOptions))AllocateZeroPool((Length - OptionLength + 2) * sizeof(CHAR16)); // Copy preceeding substring CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16)); if ((Offset + OptionLength) < Length) { diff --git a/rEFIt_UEFI/entry_scan/legacy.c b/rEFIt_UEFI/entry_scan/legacy.c index d29b41768..faf56ab69 100644 --- a/rEFIt_UEFI/entry_scan/legacy.c +++ b/rEFIt_UEFI/entry_scan/legacy.c @@ -52,7 +52,7 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *FullTitle, IN CHAR16 *LoaderTitl { LEGACY_ENTRY *Entry, *SubEntry; REFIT_MENU_SCREEN *SubScreen; - CHAR16 *VolDesc; + CONST CHAR16 *VolDesc; CHAR16 ShortcutLetter = 0; INTN i; @@ -115,7 +115,7 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *FullTitle, IN CHAR16 *LoaderTitl VolDesc = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : L"HD"; // prepare the menu entry - Entry = AllocateZeroPool(sizeof(LEGACY_ENTRY)); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LEGACY_ENTRY)); if (FullTitle) { Entry->me.Title = EfiStrDuplicate(FullTitle); } else { @@ -152,17 +152,16 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *FullTitle, IN CHAR16 *LoaderTitl Entry->Volume = Volume; Entry->DevicePathString = Volume->DevicePathString; - Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : - ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? L"USB" : L"HD"); + Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? L"USB" : L"HD"); // create the submenu - SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); + SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); SubScreen->Title = PoolPrint(L"Boot Options for %s on %s", LoaderTitle, VolDesc); SubScreen->TitleImage = Entry->me.Image; SubScreen->AnimeRun = GetAnime(SubScreen); // default entry - SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY)); + SubEntry = (__typeof__(SubEntry))AllocateZeroPool(sizeof(LEGACY_ENTRY)); SubEntry->me.Title = PoolPrint(L"Boot %s", LoaderTitle); SubEntry->me.Tag = TAG_LEGACY; SubEntry->Volume = Entry->Volume; diff --git a/rEFIt_UEFI/entry_scan/loader.c b/rEFIt_UEFI/entry_scan/loader.c index a68f7556b..6fab5b758 100644 --- a/rEFIt_UEFI/entry_scan/loader.c +++ b/rEFIt_UEFI/entry_scan/loader.c @@ -403,7 +403,7 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry) extern BOOLEAN CopyKernelAndKextPatches(IN OUT KERNEL_AND_KEXT_PATCHES *Dst, IN KERNEL_AND_KEXT_PATCHES *Src); STATIC LOADER_ENTRY *CreateLoaderEntry(IN CHAR16 *LoaderPath, - IN CHAR16 *LoaderOptions, + IN CONST CHAR16 *LoaderOptions, IN CHAR16 *FullTitle, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, @@ -554,7 +554,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CHAR16 *LoaderPath, } // prepare the menu entry - Entry = AllocateZeroPool(sizeof(LOADER_ENTRY)); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); Entry->me.Tag = TAG_LOADER; Entry->me.Row = 0; Entry->Volume = Volume; @@ -758,7 +758,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) FileName = Basename(Entry->LoaderPath); // create the submenu - SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); + SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); SubScreen->Title = PoolPrint(L"Options for %s", Entry->me.Title, Entry->VolName); SubScreen->TitleImage = Entry->me.Image; SubScreen->ID = Entry->LoaderType + 20; @@ -769,7 +769,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) AddMenuInfoLine(SubScreen, FileDevicePathToStr(Entry->DevicePath)); Guid = FindGPTPartitionGuidInDevicePath(Volume->DevicePath); if (Guid) { - CHAR8 *GuidStr = AllocateZeroPool(50); + CHAR8 *GuidStr = (__typeof__(GuidStr))AllocateZeroPool(50); AsciiSPrint(GuidStr, 50, "%g", Guid); AddMenuInfoLine(SubScreen, PoolPrint(L"UUID: %a", GuidStr)); FreePool(GuidStr); @@ -976,7 +976,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) // DBG(" Added '%s': OSType='%d', OSVersion='%a'\n", Entry->me.Title, Entry->LoaderType, Entry->OSVersion); } -STATIC BOOLEAN AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderOptions, +STATIC BOOLEAN AddLoaderEntry(IN CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN UINT8 OSType, IN UINT8 Flags) @@ -1970,7 +1970,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex, } else if (Custom->SubEntries != NULL) { UINTN CustomSubIndex = 0; // Add subscreen - REFIT_MENU_SCREEN *SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); + REFIT_MENU_SCREEN *SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); if (SubScreen) { SubScreen->Title = PoolPrint(L"Boot Options for %s on %s", (Custom->Title != NULL) ? Custom->Title : CustomPath, Entry->VolName); SubScreen->TitleImage = Entry->me.Image; @@ -1980,7 +1980,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex, AddMenuInfoLine(SubScreen, PoolPrint(L"Volume size: %dMb", VolumeSize)); AddMenuInfoLine(SubScreen, FileDevicePathToStr(Entry->DevicePath)); if (Guid) { - CHAR8 *GuidStr = AllocateZeroPool(50); + CHAR8 *GuidStr = (__typeof__(GuidStr))AllocateZeroPool(50); AsciiSPrint(GuidStr, 50, "%g", Guid); AddMenuInfoLine(SubScreen, PoolPrint(L"UUID: %a", GuidStr)); FreePool(GuidStr); diff --git a/rEFIt_UEFI/entry_scan/securehash.c b/rEFIt_UEFI/entry_scan/securehash.c index 4c4efe509..5e0264589 100644 --- a/rEFIt_UEFI/entry_scan/securehash.c +++ b/rEFIt_UEFI/entry_scan/securehash.c @@ -666,7 +666,7 @@ STATIC VOID *CreateImageSignatureDatabase(IN VOID *FileBuffer, SectionPtr = (EFI_IMAGE_SECTION_HEADER *)(ImageBase + PeHeaderOffset + sizeof(EFI_IMAGE_FILE_HEADER) + sizeof(UINT32) + PeHeader.Pe32->FileHeader.SizeOfOptionalHeader); // Allocate a new array for the image section headers - Sections = AllocateZeroPool(sizeof(EFI_IMAGE_SECTION_HEADER) * PeHeader.Pe32->FileHeader.NumberOfSections); + Sections = (__typeof__(Sections))AllocateZeroPool(sizeof(EFI_IMAGE_SECTION_HEADER) * PeHeader.Pe32->FileHeader.NumberOfSections); if (Sections == NULL) { goto Failed; } @@ -711,7 +711,7 @@ STATIC VOID *CreateImageSignatureDatabase(IN VOID *FileBuffer, } // Create the signature list Size = (sizeof(EFI_SIGNATURE_LIST) + sizeof(EFI_GUID) + 256); - Database = AllocateZeroPool(Size); + Database = (__typeof__(Database))AllocateZeroPool(Size); if (Database == NULL) { goto Failed; } diff --git a/rEFIt_UEFI/entry_scan/securemenu.c b/rEFIt_UEFI/entry_scan/securemenu.c index 02e1d53ea..6f0a6ca0c 100644 --- a/rEFIt_UEFI/entry_scan/securemenu.c +++ b/rEFIt_UEFI/entry_scan/securemenu.c @@ -64,7 +64,7 @@ VOID AddSecureBootTool(VOID) if (!gSettings.SecureBoot && !gSettings.SecureBootSetupMode) { return; } - Entry = AllocateZeroPool(sizeof(LOADER_ENTRY)); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); if (gSettings.SecureBoot) { Entry->me.Title = PoolPrint(L"Clover Secure Boot Configuration"); Entry->me.Tag = TAG_SECURE_BOOT_CONFIG; diff --git a/rEFIt_UEFI/entry_scan/securevars.c b/rEFIt_UEFI/entry_scan/securevars.c index 7a7314d00..b06d206b8 100644 --- a/rEFIt_UEFI/entry_scan/securevars.c +++ b/rEFIt_UEFI/entry_scan/securevars.c @@ -250,7 +250,7 @@ VOID *GetSignatureDatabase(IN CHAR16 *DatabaseName, return NULL; } // Allocate a buffer large enough to hold the database - Database = AllocateZeroPool(Size); + Database = (__typeof__(Database))AllocateZeroPool(Size); if (Database == NULL) { return NULL; } @@ -453,7 +453,7 @@ EFI_STATUS SetSignedVariable(IN CHAR16 *DatabaseName, EVP_PKEY_free(PrivateKey); DataSize = i2d_PKCS7(p7, NULL); - Data = AllocateZeroPool(DataSize); + Data = (__typeof__(Data))AllocateZeroPool(DataSize); i2d_PKCS7(p7, (unsigned char **)&Data); diff --git a/rEFIt_UEFI/entry_scan/tool.c b/rEFIt_UEFI/entry_scan/tool.c index 5eaac651b..de983ac43 100644 --- a/rEFIt_UEFI/entry_scan/tool.c +++ b/rEFIt_UEFI/entry_scan/tool.c @@ -81,7 +81,7 @@ STATIC BOOLEAN AddToolEntry(IN CHAR16 *LoaderPath, IN CHAR16 *FullTitle, IN CHAR return FALSE; } // Allocate the entry - Entry = AllocateZeroPool(sizeof(LOADER_ENTRY)); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); if (Entry == NULL) { return FALSE; } @@ -117,7 +117,7 @@ STATIC VOID AddCloverEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REF // EFI_STATUS Status; // prepare the menu entry - Entry = AllocateZeroPool(sizeof(LOADER_ENTRY)); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); Entry->me.Title = LoaderTitle; Entry->me.Tag = TAG_CLOVER; Entry->me.Row = 1; @@ -138,7 +138,7 @@ STATIC VOID AddCloverEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REF Entry->me.AtRightClick = ActionDetails; // create the submenu - SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); + SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); SubScreen->Title = EfiStrDuplicate(LoaderTitle); SubScreen->TitleImage = Entry->me.Image; SubScreen->ID = SCREEN_BOOT; diff --git a/rEFIt_UEFI/libeg/BmLib.c b/rEFIt_UEFI/libeg/BmLib.c index f3074772c..12e56b34c 100644 --- a/rEFIt_UEFI/libeg/BmLib.c +++ b/rEFIt_UEFI/libeg/BmLib.c @@ -114,7 +114,7 @@ EfiLibFileSystemVolumeLabelInfo ( if (Status == EFI_BUFFER_TOO_SMALL) { // inc size by 2 because some drivers (HFSPlus.efi) do not count 0 at the end of file name Size += 2; - VolumeInfo = AllocateZeroPool (Size); + VolumeInfo = (__typeof__(VolumeInfo))AllocateZeroPool (Size); Status = FHand->GetInfo (FHand, &gEfiFileSystemVolumeLabelInfoIdGuid, &Size, VolumeInfo); // Check to make sure this isn't actually EFI_FILE_SYSTEM_INFO if (!EFI_ERROR(Status)) @@ -148,14 +148,14 @@ EfiLibFileSystemVolumeLabelInfo ( **/ CHAR16 * EfiStrDuplicate ( - IN CHAR16 *Src + IN CONST CHAR16 *Src ) { CHAR16 *Dest; UINTN Size; Size = StrSize (Src); //at least 2bytes - Dest = AllocatePool (Size); + Dest = (__typeof__(Dest))AllocatePool (Size); // ASSERT (Dest != NULL); if (Dest != NULL) { CopyMem (Dest, Src, Size); @@ -242,7 +242,7 @@ EfiLibFileInfo ( if (Status == EFI_BUFFER_TOO_SMALL) { // inc size by 2 because some drivers (HFSPlus.efi) do not count 0 at the end of file name Size += 2; - FileInfo = AllocateZeroPool (Size); + FileInfo = (__typeof__(FileInfo))AllocateZeroPool (Size); Status = FHand->GetInfo (FHand, &gEfiFileInfoGuid, &Size, FileInfo); } @@ -262,7 +262,7 @@ EfiLibFileSystemInfo ( if (Status == EFI_BUFFER_TOO_SMALL) { // inc size by 2 because some drivers (HFSPlus.efi) do not count 0 at the end of file name Size += 2; - FileSystemInfo = AllocateZeroPool (Size); + FileSystemInfo = (__typeof__(FileSystemInfo))AllocateZeroPool (Size); Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo); } @@ -319,7 +319,7 @@ EfiReallocatePool ( NewPool = NULL; if (NewSize != 0) { - NewPool = AllocateZeroPool (NewSize); + NewPool = (__typeof__(NewPool))AllocateZeroPool (NewSize); } if (OldPool != NULL) { diff --git a/rEFIt_UEFI/libeg/FloatLib.c b/rEFIt_UEFI/libeg/FloatLib.c index 4140d60c3..7a4b9c77a 100644 --- a/rEFIt_UEFI/libeg/FloatLib.c +++ b/rEFIt_UEFI/libeg/FloatLib.c @@ -320,7 +320,7 @@ VOID QuickSort(VOID* Array, INTN Low, INTN High, INTN Size, INTN (*compare)(CONS INTN i = Low, j = High; VOID *Med, *Temp; Med = Array + ((Low + High) / 2) * Size; // Central element, just pointer - Temp = AllocatePool(Size); + Temp = (__typeof__(Temp))AllocatePool(Size); // Sort around center while (i <= j) { diff --git a/rEFIt_UEFI/libeg/VectorGraphics.c b/rEFIt_UEFI/libeg/VectorGraphics.c index 633da296e..5f8c42adb 100644 --- a/rEFIt_UEFI/libeg/VectorGraphics.c +++ b/rEFIt_UEFI/libeg/VectorGraphics.c @@ -39,7 +39,6 @@ extern void DumpFloat2 (char* s, float* t, int N); extern EG_IMAGE *BackgroundImage; extern EG_IMAGE *Banner; extern EG_IMAGE *BigBack; -extern VOID *fontsDB; extern INTN BanHeight; extern INTN row0TileSize; extern INTN row1TileSize; @@ -327,7 +326,7 @@ EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize) } // DBG("next icon=%s Len=%d\n", ptr, StrLen(ptr)); UINTN Size = StrLen(ptr)+1; - IconName = AllocateZeroPool(Size); + IconName = (__typeof__(IconName))AllocateZeroPool(Size); UnicodeStrToAsciiStrS(ptr, IconName, Size); // DBG("search for icon name %a\n", IconName); CHAR8 IconNight[64]; @@ -396,7 +395,7 @@ EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize) } //banner animation - GUI_ANIME *Anime = AllocateZeroPool (sizeof(GUI_ANIME)); + GUI_ANIME *Anime = (__typeof__(Anime))AllocateZeroPool (sizeof(GUI_ANIME)); Anime->ID = 1; //main screen //there is no Anime->Path in vectors Anime->Frames = NumFrames; @@ -410,7 +409,7 @@ EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize) nsvgDeleteRasterizer(rast); - *dict = AllocateZeroPool(sizeof(TagStruct)); + *dict = (__typeof__(*dict))AllocateZeroPool(sizeof(TagStruct)); (*dict)->type = kTagTypeNone; GlobalConfig.TypeSVG = TRUE; GlobalConfig.ThemeDesignHeight = (int)SVGimage->height; diff --git a/rEFIt_UEFI/libeg/image.c b/rEFIt_UEFI/libeg/image.c index c34d4c5e8..ca5d84f3d 100644 --- a/rEFIt_UEFI/libeg/image.c +++ b/rEFIt_UEFI/libeg/image.c @@ -318,7 +318,7 @@ VOID egFreeImage(IN EG_IMAGE *Image) // // Basic file operations // -EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, +EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, OUT UINT8 **FileData, OUT UINTN *FileDataLength) { EFI_STATUS Status = EFI_NOT_FOUND; @@ -332,7 +332,7 @@ EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, goto Error; } - Status = BaseDir->Open(BaseDir, &FileHandle, FileName, EFI_FILE_MODE_READ, 0); + Status = BaseDir->Open(BaseDir, &FileHandle, (CHAR16*)FileName, EFI_FILE_MODE_READ, 0); // const missing in EFI_FILE_HANDLE->Open if (EFI_ERROR(Status) || !FileHandle) { goto Error; } @@ -398,7 +398,7 @@ EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir) } //if (NULL, ...) then save to EFI partition EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *FileName, - IN UINT8 *FileData, IN UINTN FileDataLength) + IN CONST VOID *FileData, IN UINTN FileDataLength) { EFI_STATUS Status; EFI_FILE_HANDLE FileHandle; @@ -473,7 +473,7 @@ EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *FileName, } BufferSize = FileDataLength; - Status = FileHandle->Write(FileHandle, &BufferSize, FileData); + Status = FileHandle->Write(FileHandle, &BufferSize, (VOID*)FileData); // CONST missing in EFI_FILE_HANDLE->write FileHandle->Close(FileHandle); // DBG("not written %r\n", Status); return Status; @@ -510,7 +510,7 @@ EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName) } //caller is responsible for free image -EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN BOOLEAN WantAlpha) +EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN BOOLEAN WantAlpha) { EFI_STATUS Status; UINT8 *FileData = NULL; @@ -564,7 +564,7 @@ EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN } CHAR16 *ptr2 = StrStr(ptr, L"."); Size = ptr2 - ptr + 2; - IconName = AllocateZeroPool(Size); + IconName = (__typeof__(IconName))AllocateZeroPool(Size); UnicodeStrToAsciiStrS(ptr, IconName, Size - 1); while (OSIconsTable[i].name) { diff --git a/rEFIt_UEFI/libeg/libeg.h b/rEFIt_UEFI/libeg/libeg.h index 43f0e0436..735b2f214 100644 --- a/rEFIt_UEFI/libeg/libeg.h +++ b/rEFIt_UEFI/libeg/libeg.h @@ -222,15 +222,15 @@ EG_IMAGE * egCopyScaledImage(IN EG_IMAGE *Image, IN INTN Ratio); VOID egFreeImage(IN EG_IMAGE *Image); VOID ScaleImage(OUT EG_IMAGE *NewImage, IN EG_IMAGE *OldImage); -EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN BOOLEAN WantAlpha); +EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN BOOLEAN WantAlpha); EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN IconSize); EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color); -EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, +EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, OUT UINT8 **FileData, OUT UINTN *FileDataLength); EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *FileName, - IN UINT8 *FileData, IN UINTN FileDataLength); + IN CONST VOID *FileData, IN UINTN FileDataLength); EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName); EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir); diff --git a/rEFIt_UEFI/libeg/lodepng.c b/rEFIt_UEFI/libeg/lodepng.c index 6654fec23..aaa9eadfe 100644 --- a/rEFIt_UEFI/libeg/lodepng.c +++ b/rEFIt_UEFI/libeg/lodepng.c @@ -54,7 +54,7 @@ extern void qsort(void *a, size_t n, size_t es, int (*cmp)(const void *, const v // rewrite by RehabMan void* lodepng_malloc(size_t size) { - size_t* p = AllocateZeroPool(size+sizeof(size_t)); + size_t* p = (__typeof__(p))AllocateZeroPool(size+sizeof(size_t)); if (!p) { return NULL; } @@ -75,7 +75,7 @@ void* lodepng_realloc(void* ptr, size_t new_size) return lodepng_malloc(new_size); } size_t* old_p = (size_t*)ptr-1; - size_t* new_p = ReallocatePool(*old_p, new_size+sizeof(size_t), old_p); + size_t* new_p = (__typeof__(new_p))ReallocatePool(*old_p, new_size+sizeof(size_t), old_p); if (!new_p) { return NULL; } diff --git a/rEFIt_UEFI/libeg/nanosvg.c b/rEFIt_UEFI/libeg/nanosvg.c index ca9e2217a..2bb76c254 100644 --- a/rEFIt_UEFI/libeg/nanosvg.c +++ b/rEFIt_UEFI/libeg/nanosvg.c @@ -51,7 +51,6 @@ #endif typedef UINTN size_t; -extern VOID *fontsDB; #define NSVG_PI (3.14159265358979323846264338327f) #define NSVG_PI_DEG (0.01745329251994f) @@ -2861,7 +2860,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict) if (!p1) { DBG("font %a not parsed\n", text->fontFace->fontFamily); } else { - fontSVG = AllocateCopyPool(sizeof(NSVGfont), p1->font); + fontSVG = (__typeof__(fontSVG))AllocateCopyPool(sizeof(NSVGfont), p1->font); // DBG("font family %a parsed\n", fontSVG->fontFamily); fontSVG->next = fontsDB; fontsDB = fontSVG; @@ -3202,7 +3201,7 @@ static void parsePattern(NSVGparser* p, const char** dict) } } - pt = AllocateZeroPool(sizeof(NSVGpattern)); + pt = (__typeof__(pt))AllocateZeroPool(sizeof(NSVGpattern)); AsciiStrCpyS(pt->id, 64, attr->id); pt->width = w; pt->height = h; diff --git a/rEFIt_UEFI/libeg/nanosvg.h b/rEFIt_UEFI/libeg/nanosvg.h index ff730e077..f42a2a5ee 100644 --- a/rEFIt_UEFI/libeg/nanosvg.h +++ b/rEFIt_UEFI/libeg/nanosvg.h @@ -58,9 +58,6 @@ #define strlen(s) AsciiStrLen(s) #define strncpy(a,b,n) AsciiSPrint(a,n,"%a",b) -extern VOID *fontsDB; -extern struct NSVGparser *mainParser; - enum NSVGpaintType { NSVG_PAINT_NONE = 0, NSVG_PAINT_COLOR = 1, @@ -571,4 +568,7 @@ struct NSVGrasterizer int width, height, stride; }; +extern NSVGfont *fontsDB; +extern struct NSVGparser *mainParser; + #endif diff --git a/rEFIt_UEFI/libeg/nanosvgrast.c b/rEFIt_UEFI/libeg/nanosvgrast.c index 07c724ae1..d256e94a5 100644 --- a/rEFIt_UEFI/libeg/nanosvgrast.c +++ b/rEFIt_UEFI/libeg/nanosvgrast.c @@ -92,7 +92,7 @@ void nsvg_qsort(NSVGedge* Array, int Low, int High) int Imed; Imed = (Low + High) / 2; // Central element, just pointer float med = Array[Imed].y0; - // Temp = AllocatePool(sizeof(NSVGedge)); + // Temp = (__typeof__(Temp))AllocatePool(sizeof(NSVGedge)); // Sort around center while (i <= j) { while (Array[i].y0 < med) i++; diff --git a/rEFIt_UEFI/libeg/text.c b/rEFIt_UEFI/libeg/text.c index 8db10577e..dfba90687 100644 --- a/rEFIt_UEFI/libeg/text.c +++ b/rEFIt_UEFI/libeg/text.c @@ -36,6 +36,7 @@ //Slice 2011 - 2016 numerous improvements #include "libegint.h" +#include "nanosvg.h" //#include "egemb_font.h" //#define FONT_CELL_WIDTH (7) @@ -58,7 +59,7 @@ EG_IMAGE *FontImage = NULL; INTN FontWidth = 9; INTN FontHeight = 18; INTN TextHeight = 19; -VOID *fontsDB = NULL; +NSVGfont *fontsDB = NULL; CONST EG_PIXEL SemiWhitePixel = {255, 255, 255, 210}; //semitransparent diff --git a/rEFIt_UEFI/refit/IO.c b/rEFIt_UEFI/refit/IO.c index 7079df6a3..2535d4fc6 100644 --- a/rEFIt_UEFI/refit/IO.c +++ b/rEFIt_UEFI/refit/IO.c @@ -32,7 +32,7 @@ typedef struct { BOOLEAN Ascii; UINTN Index; union { - CHAR16 *pw; + CONST CHAR16 *pw; CHAR8 *pc; } u; } POINTER; @@ -109,8 +109,8 @@ _PPrint ( EFI_STATUS EFIAPI _SPrint ( - IN VOID *Context, - IN CHAR16 *Buffer + IN POOL_PRINT *Context, + IN CHAR16 *Buffer ); UINTN @@ -127,14 +127,14 @@ _IPrint ( VOID EFIAPI _PoolCatPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, IN VA_LIST args, IN OUT POOL_PRINT *spc, IN EFI_STATUS (EFIAPI *Output) ( - VOID *context, + POOL_PRINT *context, CHAR16 *str ) ); @@ -142,8 +142,8 @@ _PoolCatPrint ( EFI_STATUS EFIAPI _PoolPrint ( - IN VOID *Context, - IN CHAR16 *Buffer + IN POOL_PRINT *Context, + IN CHAR16 *Buffer ); VOID @@ -205,7 +205,7 @@ _DbgOut ( EFI_STATUS EFIAPI _SPrint ( - IN VOID *Context, + IN POOL_PRINT *Context, IN CHAR16 *Buffer ) /*++ @@ -261,14 +261,14 @@ Returns: VOID EFIAPI _PoolCatPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, IN VA_LIST args, IN OUT POOL_PRINT *spc, IN EFI_STATUS (EFIAPI *Output) ( - VOID *context, + POOL_PRINT *context, CHAR16 *str ) ) @@ -291,7 +291,7 @@ Returns: PRINT_STATE ps; SetMem (&ps, sizeof (ps), 0); - ps.Output = Output; + ps.Output = (IN EFI_STATUS (EFIAPI *)(VOID *context, CHAR16 *str))Output; ps.Context = spc; ps.fmt.u.pw = fmt; //ps.args = args; @@ -303,7 +303,7 @@ Returns: CHAR16 * EFIAPI PoolPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ) /*++ @@ -770,12 +770,12 @@ Returns: return 0; } - Item.Scratch = AllocateZeroPool (sizeof (CHAR16) * PRINT_ITEM_BUFFER_LEN); + Item.Scratch = (__typeof__(Item.Scratch))AllocateZeroPool (sizeof (CHAR16) * PRINT_ITEM_BUFFER_LEN); if (NULL == Item.Scratch) { return EFI_OUT_OF_RESOURCES; } - Buffer = AllocateZeroPool (sizeof (CHAR16) * PRINT_STRING_LEN); + Buffer = (__typeof__(Buffer))AllocateZeroPool (sizeof (CHAR16) * PRINT_STRING_LEN); if (NULL == Buffer) { FreePool (Item.Scratch); return EFI_OUT_OF_RESOURCES; @@ -820,9 +820,9 @@ Returns: // // %% -> % // + Item.Scratch[0] = '%'; + Item.Scratch[1] = 0; Item.Item.u.pw = Item.Scratch; - Item.Item.u.pw[0] = '%'; - Item.Item.u.pw[1] = 0; break; case '0': @@ -882,9 +882,9 @@ Returns: break; case 'c': + Item.Scratch[0] = (CHAR16) VA_ARG (ps->args, UINTN); + Item.Scratch[1] = 0; Item.Item.u.pw = Item.Scratch; - Item.Item.u.pw[0] = (CHAR16) VA_ARG (ps->args, UINTN); - Item.Item.u.pw[1] = 0; break; case 'l': @@ -896,13 +896,13 @@ Returns: Item.Pad = '0'; case 'x': - Item.Item.u.pw = Item.Scratch; //SPrint(Buffer, 64, L"EFI Error №%r", (UINTN)Status); // ValueToHex ( UnicodeSPrint( - Item.Item.u.pw, 64, L"%x", + Item.Scratch, 64, L"%x", Item.Long ? VA_ARG (ps->args, UINT64) : VA_ARG (ps->args, UINTN) ); + Item.Item.u.pw = Item.Scratch; break; /* @@ -915,13 +915,13 @@ Returns: break; */ case 'd': - Item.Item.u.pw = Item.Scratch; // ValueToString ( UnicodeSPrint( - Item.Item.u.pw, 64, L"%d", + Item.Scratch, 64, L"%d", // Item.Comma, Item.Long ? VA_ARG (ps->args, UINT64) : VA_ARG (ps->args, INTN) ); + Item.Item.u.pw = Item.Scratch; break; /* case 't': @@ -930,9 +930,9 @@ Returns: break; */ case 'r': - Item.Item.u.pw = Item.Scratch; // StatusToString - UnicodeSPrint(Item.Item.u.pw, 64, L"%r", VA_ARG (ps->args, EFI_STATUS)); + UnicodeSPrint(Item.Scratch, 64, L"%r", VA_ARG (ps->args, EFI_STATUS)); + Item.Item.u.pw = Item.Scratch; break; case 'n': @@ -976,9 +976,9 @@ Returns: break; default: + Item.Scratch[0] = '?'; + Item.Scratch[1] = 0; Item.Item.u.pw = Item.Scratch; - Item.Item.u.pw[0] = '?'; - Item.Item.u.pw[1] = 0; break; } // @@ -1266,8 +1266,8 @@ SetOutputPause ( EFI_STATUS EFIAPI _PoolPrint ( - IN VOID *Context, - IN CHAR16 *Buffer + IN POOL_PRINT *Context, + IN CHAR16 *Buffer ) /*++ @@ -1303,7 +1303,7 @@ Returns: // newlen += PRINT_STRING_LEN; spc->Maxlen = newlen; - spc->Str = EfiReallocatePool ( + spc->Str = (__typeof__(spc->Str))EfiReallocatePool ( spc->Str, spc->Len * sizeof (CHAR16), spc->Maxlen * sizeof (CHAR16) @@ -1926,7 +1926,7 @@ CHAR8* Bytes2HexStr(UINT8 *data, UINTN len) { UINTN i, j, b = 0; CHAR8 *result = (CHAR8*)AllocateZeroPool((len*2)+1); - //CHAR8 *buf = AllocateZeroPool(2); + //CHAR8 *buf = (__typeof__(buf))AllocateZeroPool(2); for (i = j = 0; i < len; i++) { b = data[i] >> 4; diff --git a/rEFIt_UEFI/refit/IO.h b/rEFIt_UEFI/refit/IO.h index d59a4be38..c8cad2b94 100644 --- a/rEFIt_UEFI/refit/IO.h +++ b/rEFIt_UEFI/refit/IO.h @@ -118,7 +118,7 @@ VSPrint ( CHAR16 * EFIAPI PoolPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ); /* diff --git a/rEFIt_UEFI/refit/lib.c b/rEFIt_UEFI/refit/lib.c index dca7116a8..de8bf7511 100644 --- a/rEFIt_UEFI/refit/lib.c +++ b/rEFIt_UEFI/refit/lib.c @@ -198,7 +198,7 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle) SelfDeviceHandle = SelfLoadedImage->DeviceHandle; TmpDevicePath = DevicePathFromHandle (SelfDeviceHandle); DevicePathSize = GetDevicePathSize (TmpDevicePath); - SelfDevicePath = AllocateAlignedPages(EFI_SIZE_TO_PAGES(DevicePathSize), 64); + SelfDevicePath = (__typeof__(SelfDevicePath))AllocateAlignedPages(EFI_SIZE_TO_PAGES(DevicePathSize), 64); CopyMem(SelfDevicePath, TmpDevicePath, DevicePathSize); DBG("SelfDevicePath=%s @%x\n", FileDevicePathToStr(SelfDevicePath), SelfDeviceHandle); @@ -215,7 +215,7 @@ EFI_STATUS InitRefitLib(IN EFI_HANDLE ImageHandle) FilePathAsString[1] = 0; } } else { - FilePathAsString = AllocateCopyPool(StrSize(L"\\"), L"\\"); + FilePathAsString = (__typeof__(FilePathAsString))AllocateCopyPool(StrSize(L"\\"), L"\\"); } SelfDirPath = FilePathAsString; @@ -342,7 +342,7 @@ VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialEl *ElementCount = InitialElementCount; if (*ElementCount > 0) { AllocateCount = (*ElementCount + 7) & ~7; // next multiple of 8 - *ListPtr = AllocatePool(sizeof(VOID *) * AllocateCount); + *ListPtr = (__typeof__(*ListPtr))AllocatePool(sizeof(VOID *) * AllocateCount); } else { *ListPtr = NULL; } @@ -355,9 +355,9 @@ VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID if ((*ElementCount & 7) == 0) { AllocateCount = *ElementCount + 8; if (*ElementCount == 0) - *ListPtr = AllocatePool(sizeof(VOID *) * AllocateCount); + *ListPtr = (__typeof__(*ListPtr))AllocatePool(sizeof(VOID *) * AllocateCount); else - *ListPtr = EfiReallocatePool((VOID *)*ListPtr, sizeof(VOID *) * (*ElementCount), sizeof(VOID *) * AllocateCount); + *ListPtr = (__typeof__(*ListPtr))EfiReallocatePool((VOID *)*ListPtr, sizeof(VOID *) * (*ElementCount), sizeof(VOID *) * AllocateCount); } (*ListPtr)[*ElementCount] = NewElement; (*ElementCount)++; @@ -484,7 +484,7 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl BlockSize = Volume->BlockIO->Media->BlockSize; if (BlockSize > 2048) return; // our buffer is too small... the bred of thieve of cable - SectorBuffer = AllocateAlignedPages(EFI_SIZE_TO_PAGES (2048), 16); //align to 16 byte?! Poher + SectorBuffer = (__typeof__(SectorBuffer))AllocateAlignedPages(EFI_SIZE_TO_PAGES (2048), 16); //align to 16 byte?! Poher ZeroMem((CHAR8*)&SectorBuffer[0], 2048); // look at the boot sector (this is used for both hard disks and El Torito images!) Status = Volume->BlockIO->ReadBlocks(Volume->BlockIO, Volume->BlockIO->Media->MediaId, @@ -720,7 +720,7 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl if (MbrTable[i].Flags != 0x00 && MbrTable[i].Flags != 0x80) MbrTableFound = FALSE; if (MbrTableFound) { - Volume->MbrPartitionTable = AllocatePool(4 * 16); + Volume->MbrPartitionTable = (__typeof__(Volume->MbrPartitionTable))AllocatePool(4 * 16); CopyMem(Volume->MbrPartitionTable, MbrTable, 4 * 16); Volume->BootType = BOOTING_BY_MBR; } @@ -751,7 +751,7 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume) // get device path DiskDevicePath = DevicePathFromHandle(Volume->DeviceHandle); DevicePathSize = GetDevicePathSize (DiskDevicePath); - Volume->DevicePath = AllocateAlignedPages(EFI_SIZE_TO_PAGES(DevicePathSize), 64); + Volume->DevicePath = (__typeof__(Volume->DevicePath))AllocateAlignedPages(EFI_SIZE_TO_PAGES(DevicePathSize), 64); CopyMem(Volume->DevicePath, DiskDevicePath, DevicePathSize); Volume->DevicePathString = FileDevicePathToStr(Volume->DevicePath); @@ -1034,7 +1034,7 @@ static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_I MBR_PARTITION_INFO *EMbrTable; ExtBase = MbrEntry->StartLBA; - SectorBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (512), WholeDiskVolume->BlockIO->Media->IoAlign); + SectorBuffer = (__typeof__(SectorBuffer))AllocateAlignedPages (EFI_SIZE_TO_PAGES (512), WholeDiskVolume->BlockIO->Media->IoAlign); for (ExtCurrent = ExtBase; ExtCurrent; ExtCurrent = NextExtCurrent) { // read current EMBR @@ -1060,7 +1060,7 @@ static VOID ScanExtendedPartition(REFIT_VOLUME *WholeDiskVolume, MBR_PARTITION_I } else { // found a logical partition - Volume = AllocateZeroPool(sizeof(REFIT_VOLUME)); + Volume = (__typeof__(Volume))AllocateZeroPool(sizeof(REFIT_VOLUME)); Volume->DiskKind = WholeDiskVolume->DiskKind; Volume->IsMbrPartition = TRUE; Volume->MbrPartitionIndex = LogicalPartitionIndex++; @@ -1110,8 +1110,8 @@ VOID ScanVolumes(VOID) // first pass: collect information about all handles for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { - Volume = AllocateZeroPool(sizeof(REFIT_VOLUME)); - Volume->LegacyOS = AllocateZeroPool(sizeof(LEGACY_OS)); + Volume = (__typeof__(Volume))AllocateZeroPool(sizeof(REFIT_VOLUME)); + Volume->LegacyOS = (__typeof__(Volume->LegacyOS))AllocateZeroPool(sizeof(LEGACY_OS)); Volume->DeviceHandle = Handles[HandleIndex]; if (Volume->DeviceHandle == SelfDeviceHandle) { SelfVolume = Volume; @@ -1155,7 +1155,7 @@ VOID ScanVolumes(VOID) // DBG("Found %d volumes\n", VolumesCount); if (SelfVolume == NULL){ DBG(" WARNING: SelfVolume not found"); //Slice - and what? - SelfVolume = AllocateZeroPool(sizeof(REFIT_VOLUME)); + SelfVolume = (__typeof__(SelfVolume))AllocateZeroPool(sizeof(REFIT_VOLUME)); SelfVolume->DeviceHandle = SelfDeviceHandle; SelfVolume->DevicePath = SelfDevicePath; SelfVolume->RootDir = SelfRootDir; @@ -1198,8 +1198,8 @@ VOID ScanVolumes(VOID) if (WholeDiskVolume != NULL && WholeDiskVolume->MbrPartitionTable != NULL) { // check if this volume is one of the partitions in the table MbrTable = WholeDiskVolume->MbrPartitionTable; - SectorBuffer1 = AllocateAlignedPages (EFI_SIZE_TO_PAGES (512), 16); - SectorBuffer2 = AllocateAlignedPages (EFI_SIZE_TO_PAGES (512), 16); + SectorBuffer1 = (__typeof__(SectorBuffer1))AllocateAlignedPages (EFI_SIZE_TO_PAGES (512), 16); + SectorBuffer2 = (__typeof__(SectorBuffer2))AllocateAlignedPages (EFI_SIZE_TO_PAGES (512), 16); for (PartitionIndex = 0; PartitionIndex < 4; PartitionIndex++) { // check size @@ -1308,7 +1308,7 @@ VOID ReinitVolumes(VOID) Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &RemainingDevicePath, &WholeDiskHandle); if (!EFI_ERROR(Status)) { - Volume->WholeDiskBlockIO = WholeDiskHandle; + Volume->WholeDiskBlockIO = (__typeof__(Volume->WholeDiskBlockIO))WholeDiskHandle; // get the BlockIO protocol Status = gBS->HandleProtocol(WholeDiskHandle, &gEfiBlockIoProtocolGuid, (VOID **) &Volume->WholeDiskBlockIO); if (EFI_ERROR(Status)) { @@ -1419,7 +1419,7 @@ EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, // read next directory entry LastBufferSize = BufferSize = 256; - Buffer = AllocateZeroPool (BufferSize); + Buffer = (__typeof__(Buffer))AllocateZeroPool (BufferSize); for (IterCount = 0; ; IterCount++) { Status = Directory->Read(Directory, &BufferSize, Buffer); if (Status != EFI_BUFFER_TOO_SMALL || IterCount >= 4) @@ -1432,7 +1432,7 @@ EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, DBG("Reallocating buffer from %d to %d\n", LastBufferSize, BufferSize); #endif } - Buffer = EfiReallocatePool(Buffer, LastBufferSize, BufferSize); + Buffer = (__typeof__(Buffer))EfiReallocatePool(Buffer, LastBufferSize, BufferSize); LastBufferSize = BufferSize; } if (EFI_ERROR(Status)) { @@ -1619,12 +1619,12 @@ CHAR16 * egFindExtension(IN CHAR16 *FileName) // memory string search // -INTN FindMem(IN VOID *Buffer, IN UINTN BufferLength, IN VOID *SearchString, IN UINTN SearchStringLength) +INTN FindMem(IN CONST VOID *Buffer, IN UINTN BufferLength, IN CONST VOID *SearchString, IN UINTN SearchStringLength) { - UINT8 *BufferPtr; + CONST UINT8 *BufferPtr; UINTN Offset; - BufferPtr = Buffer; + BufferPtr = (CONST UINT8 *)Buffer; BufferLength -= SearchStringLength; for (Offset = 0; Offset < BufferLength; Offset++, BufferPtr++) { if (CompareMem(BufferPtr, SearchString, SearchStringLength) == 0) @@ -1693,7 +1693,7 @@ BOOLEAN DumpVariable(CHAR16* Name, EFI_GUID* Guid, INTN DevicePathAt) Status = gRT->GetVariable (Name, Guid, NULL, &dataSize, data); if (Status == EFI_BUFFER_TOO_SMALL) { - data = AllocateZeroPool(dataSize); + data = (__typeof__(data))AllocateZeroPool(dataSize); Status = gRT->GetVariable (Name, Guid, NULL, &dataSize, data); if (EFI_ERROR(Status)) { DBG("Can't get %s, size=%d\n", Name, dataSize); diff --git a/rEFIt_UEFI/refit/lib.h b/rEFIt_UEFI/refit/lib.h index bf875b50b..1f0acf7ba 100644 --- a/rEFIt_UEFI/refit/lib.h +++ b/rEFIt_UEFI/refit/lib.h @@ -638,7 +638,7 @@ typedef struct { REFIT_MENU_ENTRY me; REFIT_VOLUME *Volume; CHAR16 *DevicePathString; - CHAR16 *LoadOptions; + CONST CHAR16 *LoadOptions; UINTN BootNum; CHAR16 *LoaderPath; //will be set to NULL } LEGACY_ENTRY; @@ -741,7 +741,7 @@ CHAR16 * Basename(IN CHAR16 *Path); VOID ReplaceExtension(IN OUT CHAR16 *Path, IN CHAR16 *Extension); CHAR16 * egFindExtension(IN CHAR16 *FileName); -INTN FindMem(IN VOID *Buffer, IN UINTN BufferLength, IN VOID *SearchString, IN UINTN SearchStringLength); +INTN FindMem(IN CONST VOID *Buffer, IN UINTN BufferLength, IN CONST VOID *SearchString, IN UINTN SearchStringLength); CHAR16 *FileDevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath); CHAR16 *FileDevicePathFileToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath); @@ -882,7 +882,7 @@ EG_IMAGE * GetSmallHover(IN UINTN Id); // menu module // -#define MENU_EXIT_ENTER (1) +#define MENU_EXIT_ENTER ((ACTION)(1)) #define MENU_EXIT_ESCAPE (2) #define MENU_EXIT_DETAILS (3) #define MENU_EXIT_TIMEOUT (4) @@ -952,7 +952,7 @@ EfiLibFileSystemVolumeLabelInfo ( ); extern CHAR16 * EfiStrDuplicate ( - IN CHAR16 *Src + IN CONST CHAR16 *Src ); extern INTN StriCmp ( diff --git a/rEFIt_UEFI/refit/list.c b/rEFIt_UEFI/refit/list.c index 760075bde..12db6fafa 100644 --- a/rEFIt_UEFI/refit/list.c +++ b/rEFIt_UEFI/refit/list.c @@ -146,7 +146,7 @@ Add_ListElement( // // Create a new list entry // - CurrentList = AllocateZeroPool (sizeof (REFIT_LIST)); + CurrentList = (__typeof__(CurrentList))AllocateZeroPool (sizeof (REFIT_LIST)); if (!CurrentList) { return EFI_OUT_OF_RESOURCES; diff --git a/rEFIt_UEFI/refit/main.c b/rEFIt_UEFI/refit/main.c index ae374720c..bc36f4043 100644 --- a/rEFIt_UEFI/refit/main.c +++ b/rEFIt_UEFI/refit/main.c @@ -89,6 +89,16 @@ EFI_HANDLE ConsoleInHandle; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* SimpleTextEx; EFI_KEY_DATA KeyData; +CHAR8* AudioOutputNames[] = { + "LineOut", + "Speaker", + "Headphones", + "SPDIF", + "Garniture", + "HDMI", + "Other" +}; + extern VOID HelpRefit(VOID); extern VOID AboutRefit(VOID); extern BOOLEAN BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize, LOADER_ENTRY *Entry); @@ -101,6 +111,7 @@ extern UINTN DsdtsNum; extern CHAR16 *DsdtsList[]; extern UINTN AudioNum; extern HDA_OUTPUTS AudioList[20]; +extern CHAR8 *AudioOutputNames[]; extern EFI_AUDIO_IO_PROTOCOL *AudioIo; @@ -459,7 +470,7 @@ VOID FilterBootPatches(IN LOADER_ENTRY *Entry) VOID ReadSIPCfg() { UINT32 csrCfg = gSettings.CsrActiveConfig & CSR_VALID_FLAGS; - CHAR16 *csrLog = AllocateZeroPool(SVALUE_MAX_SIZE); + CHAR16 *csrLog = (__typeof__(csrLog))AllocateZeroPool(SVALUE_MAX_SIZE); if (csrCfg & CSR_ALLOW_UNTRUSTED_KEXTS) StrCatS(csrLog, SVALUE_MAX_SIZE/2, L"CSR_ALLOW_UNTRUSTED_KEXTS"); @@ -628,7 +639,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) /* Start OSName Mac OS X 10.12 End OSName Start OSVendor Apple Inc. End */ - InstallerVersion = SearchString(LoadedImage->ImageBase, LoadedImage->ImageSize, "Mac OS X ", 9); + InstallerVersion = SearchString((CHAR8*)LoadedImage->ImageBase, LoadedImage->ImageSize, "Mac OS X ", 9); if (InstallerVersion != NULL) { // string was found InstallerVersion += 9; // advance to version location @@ -648,7 +659,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) if (Entry->OSVersion != NULL) { FreePool(Entry->OSVersion); } - Entry->OSVersion = AllocateCopyPool(AsciiStrLen(InstallerVersion)+1, InstallerVersion); + Entry->OSVersion = (__typeof__(Entry->OSVersion))AllocateCopyPool(AsciiStrLen(InstallerVersion)+1, InstallerVersion); Entry->OSVersion[AsciiStrLen(InstallerVersion)] = '\0'; // DBG("Corrected OSVersion: %a\n", Entry->OSVersion); } @@ -678,7 +689,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) FilterKextPatches(Entry); FilterKernelPatches(Entry); FilterBootPatches(Entry); - if (LoadedImage && !BooterPatch(LoadedImage->ImageBase, LoadedImage->ImageSize, Entry)) { + if (LoadedImage && !BooterPatch((UINT8*)LoadedImage->ImageBase, LoadedImage->ImageSize, Entry)) { DBG("Will not patch boot.efi\n"); } @@ -1202,10 +1213,10 @@ static VOID ScanDriverDir(IN CHAR16 *Path, OUT EFI_HANDLE **DriversToConnect, OU if (DriversArrSize == 0) { // new array DriversArrSize = 16; - DriversArr = AllocateZeroPool(sizeof(EFI_HANDLE) * DriversArrSize); + DriversArr = (__typeof__(DriversArr))AllocateZeroPool(sizeof(EFI_HANDLE) * DriversArrSize); } else if (DriversArrNum + 1 == DriversArrSize) { // extend array - DriversArr = ReallocatePool(DriversArrSize, DriversArrSize + 16, DriversArr); + DriversArr = (__typeof__(DriversArr))ReallocatePool(DriversArrSize, DriversArrSize + 16, DriversArr); DriversArrSize += 16; } DriversArr[DriversArrNum] = DriverHandle; @@ -1666,13 +1677,13 @@ 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 // DeleteNvramVariable(L"boot-args", &gEfiAppleBootGuid); Size = AsciiStrLen(tmpString); // some EFI implementations include '\0' in Size, and others don't, so update Size to string length - arg = AllocatePool(Size+1); + arg = (__typeof__(arg))AllocatePool(Size+1); /* if (AsciiStrStr(tmpString, "nvda_drv=1")) { //found substring gSettings.NvidiaWeb = TRUE; @@ -1728,7 +1739,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; } @@ -1869,7 +1880,7 @@ UINT8 *APFSContainer_Support(VOID) { EFI_GUID *TmpUUID = NULL; //Fill APFSUUIDBank - APFSUUIDBank = AllocateZeroPool(0x10*VolumesCount); + APFSUUIDBank = (__typeof__(APFSUUIDBank))AllocateZeroPool(0x10*VolumesCount); for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) { Volume = Volumes[VolumeIndex]; //Check that current volume - apfs partition @@ -1945,13 +1956,13 @@ VOID SystemVersionInit(VOID) /*Allocate Memory for systemplists, installplists and recoveryplists********************/ //Check apfs support if (APFSSupport == TRUE) { - SystemPlists = AllocateZeroPool((2*APFSUUIDBankCounter+3)*sizeof(CHAR16 *));//array of pointers - InstallPlists = AllocateZeroPool((APFSUUIDBankCounter+2)*sizeof(CHAR16 *));//array of pointers - RecoveryPlists = AllocateZeroPool((APFSUUIDBankCounter+2)*sizeof(CHAR16 *));//array of pointers + SystemPlists = (__typeof__(SystemPlists))AllocateZeroPool((2*APFSUUIDBankCounter+3)*sizeof(CHAR16 *));//array of pointers + InstallPlists = (__typeof__(InstallPlists))AllocateZeroPool((APFSUUIDBankCounter+2)*sizeof(CHAR16 *));//array of pointers + RecoveryPlists = (__typeof__(RecoveryPlists))AllocateZeroPool((APFSUUIDBankCounter+2)*sizeof(CHAR16 *));//array of pointers } else { - SystemPlists = AllocateZeroPool(sizeof(CHAR16 *)*3); - InstallPlists = AllocateZeroPool(sizeof(CHAR16 *)*2); - RecoveryPlists = AllocateZeroPool(sizeof(CHAR16 *)*2); + SystemPlists = (__typeof__(SystemPlists))AllocateZeroPool(sizeof(CHAR16 *)*3); + InstallPlists = (__typeof__(InstallPlists))AllocateZeroPool(sizeof(CHAR16 *)*2); + RecoveryPlists = (__typeof__(RecoveryPlists))AllocateZeroPool(sizeof(CHAR16 *)*2); } /* Fill it with standard paths*******************************************/ SystemPlists[0] = SystemVersionPlist; @@ -1967,10 +1978,10 @@ VOID SystemVersionInit(VOID) //Store UUID from bank CHAR16 *CurrentUUID = GuidLEToStr((EFI_GUID *)((UINT8 *)APFSUUIDBank+i*0x10)); //Init temp string with system/install/recovery APFS path - CHAR16 *TmpSysPlistPath = AllocateZeroPool(86*sizeof(CHAR16)); - CHAR16 *TmpServerPlistPath = AllocateZeroPool(86*sizeof(CHAR16)); - CHAR16 *TmpInsPlistPath = AllocateZeroPool(79*sizeof(CHAR16)); - CHAR16 *TmpRecPlistPath = AllocateZeroPool(58*sizeof(CHAR16)); + CHAR16 *TmpSysPlistPath = (__typeof__(TmpSysPlistPath))AllocateZeroPool(86*sizeof(CHAR16)); + 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); @@ -2485,11 +2496,18 @@ RefitMain (IN EFI_HANDLE ImageHandle, PutNvramPlistToRtVars(); } } - + + // log Audio devices in boot-log. Thisis for clients like Clover.app + GetOutputs(); + for (i = 0; i < AudioNum; i++) { + if (AudioList[i].Name) { + // Never change this log, otherwise clients will stop interprete the output. + MsgLog("Found Audio Device %s (%a) at index %d\n", AudioList[i].Name, AudioOutputNames[AudioList[i].Device], i); + } + } + if (!GlobalConfig.FastBoot) { - CHAR16 *TmpArgs; - GetOutputs(); if (gThemeNeedInit) { InitTheme(TRUE, &Now); gThemeNeedInit = FALSE; @@ -2828,7 +2846,7 @@ RefitMain (IN EFI_HANDLE ImageHandle, Description = PoolPrint(L"Clover start %s at %s", (LoaderName != NULL)?LoaderName:L"legacy", VolName); OptionalDataSize = NameSize + Name2Size + 4 + 2; //signature + VolNameSize - OptionalData = AllocateZeroPool(OptionalDataSize); + OptionalData = (__typeof__(OptionalData))AllocateZeroPool(OptionalDataSize); if (OptionalData == NULL) { break; } diff --git a/rEFIt_UEFI/refit/menu.c b/rEFIt_UEFI/refit/menu.c index c05b9ab03..3ca92daed 100644 --- a/rEFIt_UEFI/refit/menu.c +++ b/rEFIt_UEFI/refit/menu.c @@ -74,6 +74,7 @@ extern UINTN DsdtsNum; extern CHAR16 *DsdtsList[]; extern UINTN AudioNum; extern HDA_OUTPUTS AudioList[20]; +extern CHAR8 *AudioOutputNames[]; extern CHAR8 *NonDetected; extern BOOLEAN GetLegacyLanAddress; extern UINT8 gLanMac[4][6]; // their MAC addresses @@ -237,16 +238,6 @@ CHAR16* ArgOptional[NUM_OPT] = { L"nvda_drv=1" //19 }; -CHAR8* OutputNames[] = { - "LineOut", - "Speaker", - "Headphones", - "SPDIF", - "Garniture", - "HDMI", - "Other" -}; - UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC StyleFunc, IN OUT INTN *DefaultEntryIndex, OUT REFIT_MENU_ENTRY **ChosenEntry); @@ -260,23 +251,23 @@ VOID FillInputs(BOOLEAN New) InputItemsCount = 0; if (New) { - InputItems = AllocateZeroPool(130 * sizeof(INPUT_ITEM)); //XXX + InputItems = (__typeof__(InputItems))AllocateZeroPool(130 * sizeof(INPUT_ITEM)); //XXX } InputItems[InputItemsCount].ItemType = ASString; //0 //even though Ascii we will keep value as Unicode to convert later if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(SVALUE_MAX_SIZE); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(SVALUE_MAX_SIZE); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, SVALUE_MAX_SIZE, L"%a ", gSettings.BootArgs); InputItems[InputItemsCount].ItemType = UNIString; //1 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(32); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(32); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 32, L"%s", gSettings.DsdtName); // 1-> 2 InputItems[InputItemsCount].ItemType = UNIString; //2 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(63); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(63); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 63, L"%s", gSettings.BlockKexts); @@ -291,12 +282,12 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.SlpSmiEnable; InputItems[InputItemsCount].ItemType = Decimal; //7 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(8); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(8); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 8, L"%02d", gSettings.PLimitDict); InputItems[InputItemsCount].ItemType = Decimal; //8 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(8); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(8); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 8, L"%02d", gSettings.UnderVoltStep); InputItems[InputItemsCount].ItemType = BoolValue; //9 @@ -311,7 +302,7 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.EnableISS; InputItems[InputItemsCount].ItemType = Decimal; //14 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%06d", gSettings.QPI); InputItems[InputItemsCount].ItemType = BoolValue; //15 @@ -320,17 +311,17 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.PatchVBios; InputItems[InputItemsCount].ItemType = Decimal; //17 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(20); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(20); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"0x%x", gPlatformFeature); InputItems[InputItemsCount].ItemType = Hex; //18 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(36); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(36); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 36, L"0x%X", gSettings.BacklightLevel); InputItems[InputItemsCount].ItemType = Decimal; //19 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } if (gSettings.BusSpeed > 20000) { UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%06d", gSettings.BusSpeed); @@ -341,7 +332,7 @@ VOID FillInputs(BOOLEAN New) for (i=0; i 2) { //fool proof: cfg_name is 3 character or more. UnicodeSPrint(InputItems[InputItemsCount++].SValue, 20, L"%s", gSettings.FBName); @@ -365,7 +356,7 @@ VOID FillInputs(BOOLEAN New) AsciiSPrint((CHAR8*)&tmp[2*j], 3, "%02x", gSettings.Dcfg[j]); } if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(40); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(40); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 40, L"%a", tmp); @@ -375,7 +366,7 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.InjectIntel; InputItems[InputItemsCount].ItemType = Hex; //22+6i if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(20); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(20); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.IgPlatform); // InputItemsCount += 3; @@ -384,7 +375,7 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Decimal; //23+6i if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(8); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(8); } if (gSettings.VideoPorts > 0) { UnicodeSPrint(InputItems[InputItemsCount++].SValue, 8, L"%02d", gSettings.VideoPorts); @@ -398,13 +389,13 @@ VOID FillInputs(BOOLEAN New) AsciiSPrint((CHAR8*)&tmp[2*j], 3, "%02x", gSettings.NVCAP[j]); } if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(84); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(84); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 84, L"%a", tmp); } else { //ATI and others there will be connectors InputItems[InputItemsCount].ItemType = Hex; //24+6i if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(20); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(20); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 20, L"%08lx", gGraphics[i].Connectors); } @@ -430,13 +421,13 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Decimal; //50 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%06d", gSettings.RefCLK); InputItems[InputItemsCount].ItemType = ASString; //51 OS version if non-detected if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(SVALUE_MAX_SIZE); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(SVALUE_MAX_SIZE); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, SVALUE_MAX_SIZE, L"%a ", NonDetected); @@ -446,12 +437,12 @@ VOID FillInputs(BOOLEAN New) //VendorEDID & ProductEDID 53, 54 InputItems[InputItemsCount].ItemType = Decimal; //53 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"0x%04x", gSettings.VendorEDID); InputItems[InputItemsCount].ItemType = Decimal; //54 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"0x%04x", gSettings.ProductEDID); @@ -468,7 +459,7 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.HDAInjection; InputItems[InputItemsCount].ItemType = Decimal; // 60 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%d", gSettings.HDALayoutId); @@ -479,13 +470,13 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Hex; //62 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(24); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(24); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 24, L"0x%08x", gFwFeatures); InputItems[InputItemsCount].ItemType = Hex; //63 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(24); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(24); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 24, L"0x%08x", gFwFeaturesMask); @@ -510,12 +501,12 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Decimal; //70 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(8); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(8); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 8, L"%02d", gSettings.PointerSpeed); InputItems[InputItemsCount].ItemType = Decimal; //71 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%04d", gSettings.DoubleClickTime); InputItems[InputItemsCount].ItemType = BoolValue; //72 @@ -529,68 +520,68 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Hex; //75 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"0x%04x", gSettings.C3Latency); InputItems[InputItemsCount].ItemType = Decimal; //76 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%02d", gSettings.EnabledCores); InputItems[InputItemsCount].ItemType = Decimal; //77 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%02d", gSettings.SavingMode); InputItems[InputItemsCount].ItemType = ASString; //78 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.ProductName); InputItems[InputItemsCount].ItemType = ASString; //79 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.VersionNr); InputItems[InputItemsCount].ItemType = ASString; //80 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.SerialNr); InputItems[InputItemsCount].ItemType = ASString; //81 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.BoardNumber); InputItems[InputItemsCount].ItemType = ASString; //82 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.BoardSerialNumber); InputItems[InputItemsCount].ItemType = Decimal; //83 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%d", gSettings.BoardType); InputItems[InputItemsCount].ItemType = ASString; //84 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.BoardVersion); InputItems[InputItemsCount].ItemType = Decimal; //85 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%d", gSettings.ChassisType); InputItems[InputItemsCount].ItemType = ASString; //86 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.RomVersion); InputItems[InputItemsCount].ItemType = ASString; //87 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.ReleaseDate); @@ -611,38 +602,38 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Hex; //94 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeATI); InputItems[InputItemsCount].ItemType = Hex; //95 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeNVidia); InputItems[InputItemsCount].ItemType = Hex; //96 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeIntel); InputItems[InputItemsCount].ItemType = Hex; //97 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeLAN); InputItems[InputItemsCount].ItemType = Hex; //98 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeWIFI); InputItems[InputItemsCount].ItemType = Hex; //99 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeSATA); InputItems[InputItemsCount].ItemType = Hex; //100 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeXHCI); InputItems[InputItemsCount].ItemType = CheckBit; //101 @@ -652,12 +643,12 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount++].BValue = gSettings.DebugDSDT; InputItems[InputItemsCount].ItemType = Hex; //103 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.FakeIMEI); InputItems[InputItemsCount].ItemType = Hex; //104 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(26); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(26); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 26, L"0x%08X", gSettings.KernelAndKextPatches.FakeCPUID); @@ -674,7 +665,7 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Hex; //109 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%01x", gSettings.DualLink); @@ -685,7 +676,7 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = Hex; //112 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"0x%04x", gSettings.IntelMaxValue); @@ -700,12 +691,12 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount].ItemType = ASString; //117 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.EfiVersion); InputItems[InputItemsCount].ItemType = ASString; //118 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(64); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(64); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 64, L"%a", gSettings.BooterCfgStr); @@ -713,7 +704,7 @@ VOID FillInputs(BOOLEAN New) InputItems[InputItemsCount++].IValue = 119; InputItems[InputItemsCount].ItemType = Decimal; //120 if (New) { - InputItems[InputItemsCount].SValue = AllocateZeroPool(16); + InputItems[InputItemsCount].SValue = (__typeof__(InputItems[InputItemsCount].SValue))AllocateZeroPool(16); } UnicodeSPrint(InputItems[InputItemsCount++].SValue, 16, L"%04d", DefaultAudioVolume); @@ -1298,7 +1289,7 @@ VOID ApplyInputs(VOID) if (InputItems[i].Valid) { EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL; UINT8 TmpIndex = OldChosenAudio & 0xFF; - DBG("Chosen output %d:%s_%a\n", OldChosenAudio, AudioList[OldChosenAudio].Name, OutputNames[OldChosenAudio]); + DBG("Chosen output %d:%s_%a\n", OldChosenAudio, AudioList[OldChosenAudio].Name, AudioOutputNames[OldChosenAudio]); DevicePath = DevicePathFromHandle(AudioList[OldChosenAudio].Handle); if (DevicePath != NULL) { @@ -1339,7 +1330,7 @@ VOID AddMenuInfo(REFIT_MENU_SCREEN *SubScreen, CHAR16 *Line) { REFIT_INPUT_DIALOG *InputBootArgs; - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%s", Line); InputBootArgs->Entry.Tag = TAG_INFO; InputBootArgs->Item = NULL; @@ -2262,7 +2253,7 @@ static UINTN InputDialog(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Style (Item->ItemType != RadioSwitch) && (Item->ItemType != CheckBit)) { // Grow Item->SValue to SVALUE_MAX_SIZE if we want to edit a text field - Item->SValue = EfiReallocatePool(Item->SValue, StrSize(Item->SValue), SVALUE_MAX_SIZE); + Item->SValue = (__typeof__(Item->SValue))EfiReallocatePool(Item->SValue, StrSize(Item->SValue), SVALUE_MAX_SIZE); } Buffer = Item->SValue; @@ -3098,7 +3089,7 @@ VOID DrawBCSText(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) // if the text exceeds the given limit if (TextLen > MaxTextLen) { - BCSText = AllocatePool((sizeof(CHAR16) * MaxTextLen) + 1); + BCSText = (__typeof__(BCSText))AllocatePool((sizeof(CHAR16) * MaxTextLen) + 1); // error check, not enough memory if (!BCSText) { @@ -4014,8 +4005,8 @@ VOID MainMenuVerticalStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, textPosY = TimeoutPosY - (int)(GlobalConfig.TileYSpace * GlobalConfig.Scale) - MessageHeight; //message text row1PosY = textPosY - row1TileSize - (int)(GlobalConfig.TileYSpace * GlobalConfig.Scale) - LayoutTextOffset; if (!itemPosX) { - itemPosX = AllocatePool(sizeof(UINT64) * Screen->EntryCount); - itemPosY = AllocatePool(sizeof(UINT64) * Screen->EntryCount); + itemPosX = (__typeof__(itemPosX))AllocatePool(sizeof(UINT64) * Screen->EntryCount); + itemPosY = (__typeof__(itemPosY))AllocatePool(sizeof(UINT64) * Screen->EntryCount); } row0PosYRunning = row0PosY; row1PosXRunning = row1PosX; @@ -4187,7 +4178,7 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT FunctextPosY = row1PosY + row1TileSize + (INTN)((GlobalConfig.TileYSpace + LayoutTextOffset) * GlobalConfig.Scale); if (!itemPosX) { - itemPosX = AllocatePool(sizeof(UINT64) * Screen->EntryCount); + itemPosX = (__typeof__(itemPosX))AllocatePool(sizeof(UINT64) * Screen->EntryCount); } row0PosXRunning = row0PosX; @@ -4356,18 +4347,18 @@ 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 = AllocateZeroPool(sizeof(LOADER_ENTRY)); + *Entry = (__typeof__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); if (Title) { (*Entry)->Title = PoolPrint(L"%a", Title); } else { - (*Entry)->Title = AllocateZeroPool(128); + (*Entry)->Title = (__typeof__((*Entry)->Title))AllocateZeroPool(128); } (*Entry)->Image = OptionMenu.TitleImage; (*Entry)->Tag = TAG_OPTIONS; (*Entry)->AtClick = AtClick; // create the submenu - *SubScreen = AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); + *SubScreen = (__typeof__(*SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); (*SubScreen)->Title = (*Entry)->Title; (*SubScreen)->TitleImage = (*Entry)->Image; (*SubScreen)->ID = ID; @@ -4379,7 +4370,7 @@ VOID AddMenuCheck(REFIT_MENU_SCREEN *SubScreen, CONST CHAR8 *Text, UINTN Bit, IN { REFIT_INPUT_DIALOG *InputBootArgs; - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%a", Text); InputBootArgs->Entry.Tag = TAG_CHECKBIT; InputBootArgs->Entry.Row = Bit; @@ -4412,7 +4403,7 @@ VOID ModifyTitles(REFIT_MENU_ENTRY *ChosenEntry) VOID AddMenuItem(REFIT_MENU_SCREEN *SubScreen, INTN Inx, CONST CHAR8 *Title, UINTN Tag, BOOLEAN Cursor) { - REFIT_INPUT_DIALOG *InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + REFIT_INPUT_DIALOG *InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%a", Title); InputBootArgs->Entry.Tag = Tag; @@ -4605,7 +4596,7 @@ REFIT_MENU_ENTRY *SubMenuKextPatches() NewEntry(&Entry, &SubScreen, ActionEnter, SCREEN_KEXTS, "Custom kexts patches->"); for (Index = 0; Index < NrKexts; Index++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%30a", KextPatchesMenu[Index].Label); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -4645,7 +4636,7 @@ REFIT_MENU_ENTRY *SubMenuKextBlockInjection(CHAR16* UniSysVer) NewEntry(&Entry, &SubScreen, ActionEnter, SCREEN_KEXT_INJECT, sysVer); AddMenuInfoLine(SubScreen, PoolPrint(L"Choose/check kext to disable:")); } - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%s, v.%s", Kext->FileName, Kext->Version); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -4656,7 +4647,7 @@ REFIT_MENU_ENTRY *SubMenuKextBlockInjection(CHAR16* UniSysVer) SIDELOAD_KEXT *plugInKext = Kext->PlugInList; while (plugInKext) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L" |-- %s, v.%s", plugInKext->FileName, plugInKext->Version); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -4809,7 +4800,7 @@ REFIT_MENU_ENTRY *SubMenuKernelPatches() NewEntry(&Entry, &SubScreen, ActionEnter, SCREEN_KERNELS, "Custom kernel patches->"); for (Index = 0; Index < NrKernels; Index++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%30a", KernelPatchesMenu[Index].Label); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -4835,7 +4826,7 @@ REFIT_MENU_ENTRY *SubMenuBootPatches() NewEntry(&Entry, &SubScreen, ActionEnter, SCREEN_BOOTER, "Custom booter patches->"); for (Index = 0; Index < NrBoots; Index++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%30a", BootPatchesMenu[Index].Label); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -4906,7 +4897,7 @@ REFIT_MENU_ENTRY *SubMenuDropTables() // sign, DropTable->Signature, // OTID, DropTable->TableId, // DropTable->Length, DropTable->Length); - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"Drop \"%4.4a\" \"%8.8a\" %d", sign, OTID, DropTable->Length); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -4926,7 +4917,7 @@ REFIT_MENU_ENTRY *SubMenuDropTables() if (ACPIPatchedAML) { ACPI_PATCHED_AML *ACPIPatchedAMLTmp = ACPIPatchedAML; while (ACPIPatchedAMLTmp) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"Drop \"%s\"", ACPIPatchedAMLTmp->FileName); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -5068,7 +5059,7 @@ REFIT_MENU_ENTRY *SubMenuDSDTPatches() //yyyy NewEntry(&Entry, &SubScreen, ActionEnter, SCREEN_DSDT_PATCHES, "Custom DSDT patches->"); for (Index = 0; Index < PatchDsdtNum; Index++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%a", gSettings.PatchDsdtLabel[Index]); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -5095,7 +5086,7 @@ REFIT_MENU_ENTRY *SubMenuDsdts() AddMenuItem(SubScreen, 116, "BIOS.aml", TAG_SWITCH, FALSE); for (i = 0; i < DsdtsNum; i++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%s", DsdtsList[i]); InputBootArgs->Entry.Tag = TAG_SWITCH; InputBootArgs->Entry.Row = i + 1; @@ -5147,8 +5138,8 @@ REFIT_MENU_ENTRY *SubMenuAudioPort() AddMenuItem(SubScreen, 120, "Volume:", TAG_INPUT, TRUE); for (i = 0; i < AudioNum; i++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); - InputBootArgs->Entry.Title = PoolPrint(L"%s_%a", AudioList[i].Name, OutputNames[AudioList[i].Device]); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs->Entry.Title = PoolPrint(L"%s_%a", AudioList[i].Name, AudioOutputNames[AudioList[i].Device]); InputBootArgs->Entry.Tag = TAG_SWITCH; InputBootArgs->Entry.Row = i; InputBootArgs->Item = &InputItems[119]; @@ -5165,7 +5156,7 @@ VOID CreateMenuProps(REFIT_MENU_SCREEN *SubScreen, DEV_PROPERTY *Prop) { REFIT_INPUT_DIALOG *InputBootArgs; - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L" key: %a", Prop->Key); InputBootArgs->Entry.Tag = TAG_INPUT; InputBootArgs->Entry.Row = 0xFFFF; //cursor @@ -5277,7 +5268,7 @@ REFIT_MENU_ENTRY *SubMenuThemes() AddMenuItem(SubScreen, 3, "embedded", TAG_SWITCH, FALSE); for (i = 0; i < ThemesNum; i++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%s", ThemesList[i]); InputBootArgs->Entry.Tag = TAG_SWITCH; InputBootArgs->Entry.Row = i + 1; @@ -5412,7 +5403,7 @@ REFIT_MENU_ENTRY *SubMenuConfigs() AddMenuInfoLine(SubScreen, L"Select a config file:"); for (i = 0; i < ConfigsNum; i++) { - InputBootArgs = AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); + InputBootArgs = (__typeof__(InputBootArgs))AllocateZeroPool(sizeof(REFIT_INPUT_DIALOG)); InputBootArgs->Entry.Title = PoolPrint(L"%s", ConfigsList[i]); InputBootArgs->Entry.Tag = TAG_SWITCH; InputBootArgs->Entry.Row = i; diff --git a/rEFIt_UEFI/refit/screen.c b/rEFIt_UEFI/refit/screen.c index ccdf1c845..0d9bf744c 100644 --- a/rEFIt_UEFI/refit/screen.c +++ b/rEFIt_UEFI/refit/screen.c @@ -229,7 +229,7 @@ VOID TerminateScreen(VOID) static VOID DrawScreenHeader(IN CHAR16 *Title) { UINTN i; - CHAR16* BannerLine = AllocatePool((ConWidth + 1) * sizeof(CHAR16)); + CHAR16* BannerLine = (__typeof__(BannerLine))AllocatePool((ConWidth + 1) * sizeof(CHAR16)); BannerLine[ConWidth] = 0; // clear to black background @@ -1051,7 +1051,7 @@ VOID InitAnime(REFIT_MENU_SCREEN *Screen) // Copy some settings from Anime into Screen Screen->FrameTime = Anime->FrameTime; Screen->Once = Anime->Once; - Screen->Theme = AllocateCopyPool(StrSize(GlobalConfig.Theme), GlobalConfig.Theme); + Screen->Theme = (__typeof__(Screen->Theme))AllocateCopyPool(StrSize(GlobalConfig.Theme), GlobalConfig.Theme); } /*else { DBG("Film[0] == NULL\n"); } */ @@ -1146,7 +1146,7 @@ static VOID UpdateConsoleVars() } // make a buffer for a whole text line - BlankLine = AllocatePool((ConWidth + 1) * sizeof(CHAR16)); + BlankLine = (__typeof__(BlankLine))AllocatePool((ConWidth + 1) * sizeof(CHAR16)); for (i = 0; i < ConWidth; i++) { BlankLine[i] = ' ';