When parsing NVIDIA driver version, max minor version with 99.

I guess we thought these would never exceed 99, but they do.
This is a temp workaround.
This commit is contained in:
David Anderson 2020-07-09 20:27:49 -07:00 committed by Vitalii Koshura
parent e5c69dc77b
commit fe67cd96c9
No known key found for this signature in database
GPG Key ID: CE0DB1726070A5A3
1 changed files with 7 additions and 3 deletions

View File

@ -103,7 +103,8 @@ static int nvidia_driver_version() {
int (*nvml_init)() = NULL;
int (*nvml_finish)() = NULL;
int (*nvml_driver)(char *f, unsigned int len) = NULL;
int dri_ver = 0;
int dri_ver = 0;
int major=0, minor=0;
void *handle = NULL;
char driver_string[81];
@ -122,8 +123,11 @@ static int nvidia_driver_version() {
if (nvml_init()) goto end;
if (nvml_driver(driver_string, 80)) goto end;
dri_ver = (int) (100. * atof(driver_string));
sscanf(driver_string, "%d.%d", &major, &minor);
dri_ver = major*100 + std::min(minor, 99);
// minor can in fact be > 99, at least on Linux
// encoding as MMnn doesn't work.
// this is a temporary workaround.
end:
if (nvml_finish) nvml_finish();
if (handle) dlclose(handle);