NOISSUE implement more error handling

This commit is contained in:
Joona 2017-08-22 18:35:10 -07:00
parent 6e25624623
commit 59b681a174
No known key found for this signature in database
GPG Key ID: 36D6F8F3E794F2A0

View File

@ -40,9 +40,13 @@ void PrintInstanceInfo::executeTask()
int gpuline = -1; int gpuline = -1;
int cline = 0; int cline = 0;
FILE *fp = popen("lspci -k", "r"); FILE *fp = popen("lspci -k", "r");
if (fp != NULL)
{
while (fgets(buff, 512, fp) != NULL) while (fgets(buff, 512, fp) != NULL)
{ {
std::string str(buff); std::string str(buff);
if (str.length() < 9)
continue;
if (str.substr(8, 3) == "VGA") if (str.substr(8, 3) == "VGA")
{ {
gpuline = cline; gpuline = cline;
@ -59,8 +63,11 @@ void PrintInstanceInfo::executeTask()
} }
cline++; cline++;
} }
}
FILE *fp2 = popen("glxinfo", "r"); FILE *fp2 = popen("glxinfo", "r");
if (fp2 != NULL)
{
while (fgets(buff, 512, fp2) != NULL) while (fgets(buff, 512, fp2) != NULL)
{ {
if (strncmp(buff, "OpenGL version string:", 22) == 0) if (strncmp(buff, "OpenGL version string:", 22) == 0)
@ -70,6 +77,7 @@ void PrintInstanceInfo::executeTask()
break; break;
} }
} }
}
#endif #endif
logLines(lines, MessageLevel::MultiMC); logLines(lines, MessageLevel::MultiMC);