GCC/Clang support

This commit is contained in:
Nikolaj Schlej 2016-03-21 11:00:10 +01:00
parent 95e5ee2496
commit 1f54d73f8c
3 changed files with 40 additions and 44 deletions

View File

@ -2252,7 +2252,7 @@ STATUS FfsParser::parseSectionBody(const QModelIndex & index)
if (!index.isValid()) if (!index.isValid())
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
QByteArray header = model->header(index); QByteArray header = model->header(index);
if (header.size() < sizeof(EFI_COMMON_SECTION_HEADER)) if ((UINT32)header.size() < sizeof(EFI_COMMON_SECTION_HEADER))
return ERR_INVALID_SECTION; return ERR_INVALID_SECTION;
const EFI_COMMON_SECTION_HEADER* sectionHeader = (const EFI_COMMON_SECTION_HEADER*)(header.constData()); const EFI_COMMON_SECTION_HEADER* sectionHeader = (const EFI_COMMON_SECTION_HEADER*)(header.constData());
@ -2912,6 +2912,8 @@ STATUS FfsParser::parseNvarStorage(const QByteArray & data, const QModelIndex &
QByteArray body; QByteArray body;
QByteArray extendedData; QByteArray extendedData;
UINT32 guidAreaSize = guidsInStorage * sizeof(EFI_GUID); UINT32 guidAreaSize = guidsInStorage * sizeof(EFI_GUID);
UINT32 unparsedSize = (UINT32)data.size() - offset - guidAreaSize; UINT32 unparsedSize = (UINT32)data.size() - offset - guidAreaSize;
@ -3077,6 +3079,7 @@ STATUS FfsParser::parseNvarStorage(const QByteArray & data, const QModelIndex &
} }
// Get variable name // Get variable name
{
UINT32 nameOffset = (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_GUID) ? sizeof(EFI_GUID) : 1; // GUID can be stored with the variable or in a separate storage, so there will only be an index of it UINT32 nameOffset = (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_GUID) ? sizeof(EFI_GUID) : 1; // GUID can be stored with the variable or in a separate storage, so there will only be an index of it
CHAR8* namePtr = (CHAR8*)(variableHeader + 1) + nameOffset; CHAR8* namePtr = (CHAR8*)(variableHeader + 1) + nameOffset;
UINT32 nameSize = 0; UINT32 nameSize = 0;
@ -3108,7 +3111,7 @@ STATUS FfsParser::parseNvarStorage(const QByteArray & data, const QModelIndex &
// Include variable name and GUID into the header and remove them from body // Include variable name and GUID into the header and remove them from body
header = data.mid(offset, sizeof(NVAR_VARIABLE_HEADER) + nameOffset + nameSize); header = data.mid(offset, sizeof(NVAR_VARIABLE_HEADER) + nameOffset + nameSize);
body = body.mid(nameOffset + nameSize); body = body.mid(nameOffset + nameSize);
}
parsing_done: parsing_done:
QString info; QString info;
// Rename invalid variables according to their types // Rename invalid variables according to their types
@ -3187,8 +3190,7 @@ parsing_done:
.hexarg(extendedData.size()), varIndex); .hexarg(extendedData.size()), varIndex);
// Check variable name to be in the list of nesting variables // Check variable name to be in the list of nesting variables
for (std::vector<const CHAR8*>::const_iterator iter = nestingVariableNames.cbegin(); iter != nestingVariableNames.cend(); ++iter) if (text.toLatin1() == QString("StdDefaults") || text.toLatin1() == QString("MfgDefaults")) {
if (QString(*iter) == text.toLatin1()) {
STATUS result = parseNvarStorage(body, varIndex); STATUS result = parseNvarStorage(body, varIndex);
if (result) if (result)
msg(QObject::tr("parseNvarStorage: parsing of nested NVAR storage failed with error \"%1\"").arg(errorCodeToQString(result)), varIndex); msg(QObject::tr("parseNvarStorage: parsing of nested NVAR storage failed with error \"%1\"").arg(errorCodeToQString(result)), varIndex);

View File

@ -41,7 +41,3 @@ QString variableAttributesToQstring(UINT8 attributes)
return str.mid(2); // Remove the first comma and space return str.mid(2); // Remove the first comma and space
} }
std::vector<const CHAR8*> nestingVariableNames = {
"StdDefaults",
"MfgDefaults"
};

View File

@ -33,8 +33,6 @@ const QByteArray NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID
extern QString variableAttributesToQstring(UINT8 attributes); extern QString variableAttributesToQstring(UINT8 attributes);
extern std::vector<const CHAR8*> nestingVariableNames;
// Make sure we use right packing rules // Make sure we use right packing rules
#pragma pack(push,1) #pragma pack(push,1)