Less deep nesting in ParseBlocklistDriverVersions

This commit is contained in:
def 2020-11-06 17:15:47 +01:00
parent 54946518dc
commit 5c79e9aa80

View file

@ -3819,70 +3819,58 @@ static SBackEndDriverBlockList gs_aBlockList[] = {
static const char *ParseBlocklistDriverVersions(const GLubyte *pVendorStrGL, const GLubyte *pVersionStrGL) static const char *ParseBlocklistDriverVersions(const GLubyte *pVendorStrGL, const GLubyte *pVersionStrGL)
{ {
const char *pVendorStr = (const char *)pVendorStrGL; if(str_find_nocase((const char *)pVendorStrGL, "Intel") == NULL)
const char *pVersionStr = (const char *)pVersionStrGL; return NULL;
if(str_find_nocase(pVendorStr, "Intel") != NULL)
{ const char *pVersionStrStart = str_find_nocase((const char *)pVersionStrGL, "Build ");
const char *pVersionStrStart = str_find_nocase(pVersionStr, "Build "); if(pVersionStrStart == NULL)
if(pVersionStrStart != NULL) return NULL;
{
// ignore "Build ", after that, it should directly start with the driver version // ignore "Build ", after that, it should directly start with the driver version
pVersionStrStart += (ptrdiff_t)str_length("Build "); pVersionStrStart += (ptrdiff_t)str_length("Build ");
// get the "major" version // get the "major" version
char aVersionStrHelper[MAX_PATH_LENGTH]; // the size is random, but shouldn't be too small probably char aVersionStrHelper[512]; // the size is random, but shouldn't be too small probably
const char *pIdentifier = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper) / sizeof(aVersionStrHelper[0])); const char *pIdentifier = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper));
bool CheckDriver = false; if(pIdentifier == NULL)
int VIdentifier = -1; return NULL;
int VMajor = -1;
int VMinor = -1; pVersionStrStart = pIdentifier;
int VPatch = -1; int VIdentifier = str_toint(aVersionStrHelper);
if(pIdentifier != NULL) const char *pMajor = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper));
{ if(pMajor == NULL)
pVersionStrStart = pIdentifier; return NULL;
VIdentifier = str_toint(aVersionStrHelper);
const char *pMajor = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper) / sizeof(aVersionStrHelper[0])); pVersionStrStart = pMajor;
if(pMajor != NULL) int VMajor = str_toint(aVersionStrHelper);
{ const char *pMinor = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper));
pVersionStrStart = pMajor; if(pMinor == NULL)
VMajor = str_toint(aVersionStrHelper); return NULL;
const char *pMinor = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper) / sizeof(aVersionStrHelper[0]));
if(pMinor != NULL) pVersionStrStart = pMinor;
{ int VMinor = str_toint(aVersionStrHelper);
pVersionStrStart = pMinor; const char *pPatch = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper));
VMinor = str_toint(aVersionStrHelper); if(pPatch == NULL)
const char *pPatch = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper) / sizeof(aVersionStrHelper[0])); return NULL;
if(pPatch != NULL)
{ int VPatch = str_toint(aVersionStrHelper);
//pVersionStrStart = pPatch;
VPatch = str_toint(aVersionStrHelper);
CheckDriver = true;
}
}
}
}
if(CheckDriver)
{
for(auto &BlockListItem : gs_aBlockList) for(auto &BlockListItem : gs_aBlockList)
{ {
if(VIdentifier >= BlockListItem.m_VersionIdentifierMin && VIdentifier <= BlockListItem.m_VersionIdentifierMax) if(VIdentifier < BlockListItem.m_VersionIdentifierMin || VIdentifier > BlockListItem.m_VersionIdentifierMax)
{ continue;
if(VMajor >= BlockListItem.m_VersionMajorMin && VMajor <= BlockListItem.m_VersionMajorMax)
{ if(VMajor < BlockListItem.m_VersionMajorMin || VMajor > BlockListItem.m_VersionMajorMax)
if(VMinor >= BlockListItem.m_VersionMinorMin && VMinor <= BlockListItem.m_VersionMinorMax) continue;
{
if(VPatch >= BlockListItem.m_VersionPatchMin && VPatch <= BlockListItem.m_VersionPatchMax) if(VMinor < BlockListItem.m_VersionMinorMin || VMinor > BlockListItem.m_VersionMinorMax)
{ continue;
if(VPatch < BlockListItem.m_VersionPatchMin || VPatch > BlockListItem.m_VersionPatchMax)
continue;
return BlockListItem.m_pReason; return BlockListItem.m_pReason;
} }
}
}
}
}
}
}
}
return NULL; return NULL;
} }