Re-comment unnecessary code. GuidLEToXString8 is replaced by toXString8.

This commit is contained in:
jief666 2022-05-14 21:54:27 +02:00
parent 826cf58775
commit f12fd7c9ca
5 changed files with 27 additions and 16 deletions

View File

@ -193,14 +193,14 @@ F0 00 00 00 | ....
// return returnValue;
//}
//
XString8 GuidLEToXString8(const EFI_GUID& Guid)
{
XString8 returnValue;
returnValue.S8Printf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
Guid.Data1, Guid.Data2, Guid.Data3, Guid.Data4[0], Guid.Data4[1],
Guid.Data4[2], Guid.Data4[3], Guid.Data4[4], Guid.Data4[5], Guid.Data4[6], Guid.Data4[7]);
return returnValue;
}
//XString8 GuidLEToXString8(const EFI_GUID& Guid)
//{
// XString8 returnValue;
// returnValue.S8Printf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
// Guid.Data1, Guid.Data2, Guid.Data3, Guid.Data4[0], Guid.Data4[1],
// Guid.Data4[2], Guid.Data4[3], Guid.Data4[4], Guid.Data4[5], Guid.Data4[6], Guid.Data4[7]);
// return returnValue;
//}

View File

@ -229,7 +229,7 @@ extern "C" {
//XString8 GuidBeToXString8(const EFI_GUID& Guid); // not used
//XStringW GuidBeToXStringW(const EFI_GUID& Guid); // not used
XString8 GuidLEToXString8(const EFI_GUID& Guid);
//XString8 GuidLEToXString8(const EFI_GUID& Guid);
//XStringW GuidLEToXStringW(const EFI_GUID& Guid);

View File

@ -518,11 +518,10 @@ EFI_GUID getSmUUIDFromSmbios()
EFI_GUID TmpGuid;
// XString8 g = GuidBeToXString8(SmbiosTable.Type1->Uuid); // should we use the "variant" field to know if it's LE or BE
XString8 g1 = GuidLEToXString8(SmbiosTable.Type1->Uuid); // This is the difference between PC and Mac. the UUID will be swapped (read as a LE, sent as a BE).
XString8 guidBE = SmbiosTable.Type1->Uuid.toXString8(true); // This is the difference between PC and Mac. the UUID will be swapped (read as a LE, sent as a BE).
DBG("got LE smUUID as:%s\n", g1.c_str());
TmpGuid.takeValueFromBE(g1);
return TmpGuid;
DBG("got BE smUUID as:%s\n", guidBE.c_str());
return GUID().takeValueFrom(guidBE);
}
void PatchTableType1(const SmbiosInjectedSettings& smbiosSettings)

View File

@ -178,6 +178,15 @@ int guid_tests()
constexpr EFI_GUID guidTest3 = {0x12345678, 0x4321, 0x8765, {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x89}};
if ( guidTest3 == guidTestRef1 ) return breakpoint(10);
}
{
EFI_GUID guidTest4(guidTestRef1); // copy ctor
if ( guidTest4 != guidTestRef1 ) return breakpoint(10);
}
{
EFI_GUID guidTest4;
guidTest4 = guidTestRef1; // assignment ctor
if ( guidTest4 != guidTestRef1 ) return breakpoint(10);
}
{
constexpr EFI_GUID guidTest4(guidTestRef1); // copy ctor
if ( guidTest4 != guidTestRef1 ) return breakpoint(10);

View File

@ -58,16 +58,19 @@ public:
constexpr GUID() : Data1(0), Data2(0), Data3(0), Data4{0,0,0,0,0,0,0,0} {}
// constexpr GUID(const GUID& other) : GUID{other.Data1, other.Data2, other.Data3, {other.Data4[0], other.Data4[1], other.Data4[2], other.Data4[3], other.Data4[4], other.Data4[5], other.Data4[6], other.Data4[7]}} { }
// 2022-05 : defining a copy ctor force to define a copy assignment.
//constexpr GUID(const GUID& other) : GUID{other.Data1, other.Data2, other.Data3, {other.Data4[0], other.Data4[1], other.Data4[2], other.Data4[3], other.Data4[4], other.Data4[5], other.Data4[6], other.Data4[7]}} { }
constexpr GUID(UINT32 _data1, UINT16 _data2, UINT16 _data3, const GUID_Data4& _data4) : Data1(_data1), Data2(_data2), Data3(_data3), Data4{_data4.i0, _data4.i1, _data4.i2, _data4.i3, _data4.i4, _data4.i5, _data4.i6, _data4.i7} { }
// 2022-05 : I don't know how to define a constexpr copy assignment. The compiler does it for me.
// constexpr const GUID& operator = (const GUID& other) { return /*(void)(Data1 = other.Data1), static_cast<void>(Data2 = other.Data2), (void)(Data3 = other.Data3), (void)(Data4[0] = other.Data4[0]), (void)(Data4[1] = other.Data4[1]), (void)(Data4[2] = other.Data4[2]), (void)(Data4[3] = other.Data4[3]), (void)(Data4[4] = other.Data4[4]), (void)(Data4[5] = other.Data4[5]), (void)(Data4[6] = other.Data4[6]), (void)(Data4[7] = other.Data4[7]), */*this; };
constexpr bool operator == (const GUID& other) const {
return Data1 == other.Data1 && Data2 == other.Data2 && Data3 == other.Data3 && Data4[0] == other.Data4[0] && Data4[1] == other.Data4[1] && Data4[2] == other.Data4[2] && Data4[3] == other.Data4[3] && Data4[4] == other.Data4[4] && Data4[5] == other.Data4[5] && Data4[6] == other.Data4[6] && Data4[7] == other.Data4[7];
}
constexpr bool operator != (const GUID& other) const { return ! (*this == other); }
void setNull() { *this = GUID(); }
// void setNull() {Data1 = 0; Data2 = 0; Data3 = 0; memset( (void*)&Data4[0], 0, 8);}
void setNull() { Data1 = 0; *this = GUID(); }
constexpr bool isNull() const { return Data1 == 0 && Data2 == 0 && Data3 == 0 && Data4[0] == 0 && Data4[1] == 0 && Data4[2] == 0 && Data4[3] == 0 && Data4[4] == 0 && Data4[5] == 0 && Data4[6] == 0 && Data4[7] == 0; }
constexpr bool notNull() const { return !isNull(); }