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