Skip to content

Commit

Permalink
Make GetSizeInBytes() in XImage public.
Browse files Browse the repository at this point in the history
Change ParseXML first parameter to UINT8 to avoid casts.
  • Loading branch information
jief committed Nov 7, 2023
1 parent c1ce6aa commit 0130602
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/Hibernate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,

if (!EFI_ERROR(Status)) {
TagDict* PrefDict;
Status = ParseXML((const CHAR8*)PrefBuffer, &PrefDict, PrefBufferLen);
Status = ParseXML(PrefBuffer, &PrefDict, PrefBufferLen);
if (!EFI_ERROR(Status)) {
const TagDict* dict = PrefDict->dictPropertyForKey("Custom Profile");
if (dict) {
Expand Down
6 changes: 3 additions & 3 deletions rEFIt_UEFI/Platform/KextList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ XStringW GetBundleVersion(const XStringW& pathUnderSelf)
EFI_STATUS Status;
XStringW CFBundleVersion;
XStringW InfoPlistPath;
CHAR8* InfoPlistPtr = NULL;
UINT8* InfoPlistPtr = NULL;
TagDict* InfoPlistDict = NULL;
const TagStruct* Prop = NULL;
UINTN Size;
InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Contents\\Info.plist");
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), (UINT8**)&InfoPlistPtr, &Size);
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
if (EFI_ERROR(Status)) {
InfoPlistPath = SWPrintf("%ls\\%ls", pathUnderSelf.wc_str(), L"Info.plist");
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), (UINT8**)&InfoPlistPtr, &Size);
Status = egLoadFile(&self.getCloverDir(), InfoPlistPath.wc_str(), &InfoPlistPtr, &Size);
}
if(!EFI_ERROR(Status)) {
//DBG("about to parse xml file %ls\n", InfoPlistPath.wc_str());
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/Platform/Nvram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ LoadNvramPlist(
)
{
EFI_STATUS Status;
CHAR8 *NvramPtr = NULL;
UINT8 *NvramPtr = NULL;
UINTN Size = 0;

DBG(" begin load gNvramDict=0x%llX\n", (uintptr_t)gNvramDict);
Expand All @@ -918,7 +918,7 @@ LoadNvramPlist(
//
// parse it into gNvramDict
//
Status = ParseXML((const CHAR8*)NvramPtr, &gNvramDict, Size);
Status = ParseXML(NvramPtr, &gNvramDict, Size);
if(Status != EFI_SUCCESS) {
DBG(" parsing error\n");
}
Expand Down
16 changes: 8 additions & 8 deletions rEFIt_UEFI/Platform/Volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ EFI_STATUS
GetRootUUID (IN REFIT_VOLUME *Volume)
{
EFI_STATUS Status;
CHAR8 *PlistBuffer;
UINT8 *PlistBuffer;
UINTN PlistLen;
TagDict* Dict;
const TagStruct* Prop;
Expand Down Expand Up @@ -62,25 +62,25 @@ GetRootUUID (IN REFIT_VOLUME *Volume)
// Playing Rock, Paper, Scissors to chose which settings to load.
if (HasRock && HasPaper && HasScissors) {
// Rock wins when all three are around
Status = egLoadFile(Volume->RootDir, SystemPlistR, (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, SystemPlistR, &PlistBuffer, &PlistLen);
} else if (HasRock && HasPaper) {
// Paper beats rock
Status = egLoadFile(Volume->RootDir, SystemPlistP, (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, SystemPlistP, &PlistBuffer, &PlistLen);
} else if (HasRock && HasScissors) {
// Rock beats scissors
Status = egLoadFile(Volume->RootDir, SystemPlistR, (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, SystemPlistR, &PlistBuffer, &PlistLen);
} else if (HasPaper && HasScissors) {
// Scissors beat paper
Status = egLoadFile(Volume->RootDir, SystemPlistS, (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, SystemPlistS, &PlistBuffer, &PlistLen);
} else if (HasPaper) {
// No match
Status = egLoadFile(Volume->RootDir, SystemPlistP, (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, SystemPlistP, &PlistBuffer, &PlistLen);
} else if (HasScissors) {
// No match
Status = egLoadFile(Volume->RootDir, SystemPlistS, (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, SystemPlistS, &PlistBuffer, &PlistLen);
} else {
// Rock wins by default
Status = egLoadFile(Volume->RootDir, SystemPlistR, (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, SystemPlistR, &PlistBuffer, &PlistLen);
}

if (!EFI_ERROR(Status)) {
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/kext_inject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ TagDict* LOADER_ENTRY::getInfoPlist(const EFI_FILE* Root, const XStringW& infoPl

Status = egLoadFile(Root, infoPlistPath.wc_str(), &infoDictBuffer, &infoDictBufferLength);
if (!EFI_ERROR(Status)) { //double check
if( ParseXML((CHAR8*)infoDictBuffer, &dict, infoDictBufferLength)!=0 ) {
if( ParseXML(infoDictBuffer, &dict, infoDictBufferLength)!=0 ) {
MsgLog("Failed to parse Info.plist: %ls\n", infoPlistPath.wc_str());
dict = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Platform/plist/TagDict.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TagDict : public TagStruct

EFI_STATUS
ParseXML(
CONST CHAR8 *buffer,
CONST UINT8 *buffer,
TagDict** dict,
size_t bufSize
);
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/Platform/plist/plist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ XBool TagStruct::isFalseOrNn() const
// tag pointer and returns the end of the dic, or returns ?? if not found.
//

EFI_STATUS ParseXML(const CHAR8* buffer, TagDict** dict, size_t bufSize)
EFI_STATUS ParseXML(const UINT8* buffer, TagDict** dict, size_t bufSize)
{
EFI_STATUS Status;
UINT32 length = 0;
Expand All @@ -147,7 +147,7 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagDict** dict, size_t bufSize)
if (bufSize) {
bufferSize = bufSize;
} else {
bufferSize = (UINT32)strlen(buffer);
bufferSize = (UINT32)strlen((CHAR8*)buffer);
}
DBG("buffer size=%ld\n", bufferSize);
if(dict == NULL) {
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/cpp_unit_test/plist_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,12 +911,12 @@ kk</string> \
int ParseXML_tests()
{
TagDict* dict = NULL;
EFI_STATUS Status = ParseXML(config_all, &dict, (UINT32)strlen(config_all));
EFI_STATUS Status = ParseXML((UINT8*)config_all, &dict, (UINT32)strlen(config_all));
if ( !EFI_ERROR(Status) ) {
XString8 s;
dict->sprintf(0, &s);
TagDict* dict2 = NULL;
Status = ParseXML(s.c_str(), &dict2, s.length());
Status = ParseXML((UINT8*)s.c_str(), &dict2, s.length());
if ( !EFI_ERROR(Status) ) {
if ( !(*dict).debugIsEqual(*dict2, "plist"_XS8) ) {
// printf("%s", s.c_str());
Expand Down
22 changes: 11 additions & 11 deletions rEFIt_UEFI/entry_scan/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
XString8 OSVersion;
XString8 BuildVersion;
EFI_STATUS Status = EFI_NOT_FOUND;
CHAR8* PlistBuffer = NULL;
UINT8* PlistBuffer = NULL;
UINTN PlistLen;
TagDict* Dict = NULL;
const TagDict* DictPointer = NULL;
Expand All @@ -479,7 +479,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
}

if ( plist.notEmpty() ) { // found macOS System
Status = egLoadFile(Volume->RootDir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) {
Expand Down Expand Up @@ -533,7 +533,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
}
}
if (FileExists (Volume->RootDir, InstallerPlist)) {
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) {
Expand Down Expand Up @@ -572,7 +572,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
if (OSVersion.isEmpty()) {
InstallerPlist = SWPrintf("\\.IABootFiles\\com.apple.Boot.plist"); // 10.9 - ...
if (FileExists (Volume->RootDir, InstallerPlist)) {
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("Kernel Flags");
if ( Prop != NULL ) {
Expand Down Expand Up @@ -637,7 +637,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
}
}
if (FileExists (Volume->RootDir, InstallerPlist)) {
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, InstallerPlist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) {
Expand Down Expand Up @@ -751,7 +751,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const

if ( plist.notEmpty() ) { // found macOS System

Status = egLoadFile(Volume->RootDir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) {
Expand Down Expand Up @@ -796,7 +796,7 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const

// Detect exact version for OS X Recovery
if ( plist.notEmpty() ) { // found macOS System
Status = egLoadFile(Volume->RootDir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
Status = egLoadFile(Volume->RootDir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) {
Expand Down Expand Up @@ -1717,12 +1717,12 @@ XString8 GetAuthRootDmg(const EFI_FILE& dir, const XStringW& path)
XStringW plist = SWPrintf("%ls\\com.apple.Boot.plist", path.wc_str());
if ( !FileExists(dir, plist) ) return NullXString8;

CHAR8* PlistBuffer = NULL;
UINT8* PlistBuffer = NULL;
UINTN PlistLen;
TagDict* Dict = NULL;
const TagStruct* Prop = NULL;

EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS)
{
Prop = Dict->propertyForKey("Kernel Flags");
Expand Down Expand Up @@ -1764,12 +1764,12 @@ MacOsVersion GetMacOSVersionFromFolder(const EFI_FILE& dir, const XStringW& path
}

if ( plist.notEmpty() ) { // found macOS System
CHAR8* PlistBuffer = NULL;
UINT8* PlistBuffer = NULL;
UINTN PlistLen;
TagDict* Dict = NULL;
const TagStruct* Prop = NULL;

EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen);
EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), &PlistBuffer, &PlistLen);
if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) {
Prop = Dict->propertyForKey("ProductVersion");
if ( Prop != NULL ) {
Expand Down
4 changes: 0 additions & 4 deletions rEFIt_UEFI/libeg/XImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ class XImage

XImage& operator= (const XImage& other);

protected:
UINTN GetSizeInBytes() const; //in bytes

public:

void setSizeInPixels(UINTN W, UINTN H);

const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& GetData() const;
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/libeg/XTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ TagDict* XTheme::LoadTheme(const XStringW& TestTheme)
DBG("Using vector theme '%ls' (%ls)\n", TestTheme.wc_str(), m_ThemePath.wc_str());
}
} else {
Status = egLoadFile(ThemeDir, CONFIG_THEME_FILENAME, (UINT8**)&ThemePtr, &Size);
Status = egLoadFile(ThemeDir, CONFIG_THEME_FILENAME, &ThemePtr, &Size);
if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) {
Status = ParseXML((CHAR8*)ThemePtr, &ThemeDict, 0);
Status = ParseXML(ThemePtr, &ThemeDict, 0);
if (EFI_ERROR(Status)) {
ThemeDict = NULL;
}
Expand Down

0 comments on commit 0130602

Please sign in to comment.