From ad0f01095133b937a17a2c10492a55d8443e36ab Mon Sep 17 00:00:00 2001 From: jackun Date: Tue, 14 Apr 2020 00:54:44 +0300 Subject: [PATCH] Don't print that nvmlDeviceGetHandleByPciBusId failed if it wasn't even called --- src/nvml.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/nvml.cpp b/src/nvml.cpp index 5819e061..6adf634c 100644 --- a/src/nvml.cpp +++ b/src/nvml.cpp @@ -18,15 +18,14 @@ bool checkNVML(const char* pciBusId){ std::cerr << "MANGOHUD: Nvidia module not loaded\n"; } else { nvmlReturn_t ret = NVML_ERROR_UNKNOWN; - if (pciBusId) - ret = nvml.nvmlDeviceGetHandleByPciBusId(pciBusId, &nvidiaDevice); - - if (ret != NVML_SUCCESS) { + if (pciBusId && ((ret = nvml.nvmlDeviceGetHandleByPciBusId(pciBusId, &nvidiaDevice)) != NVML_SUCCESS)) { std::cerr << "MANGOHUD: Getting device handle by PCI bus ID failed: " << nvml.nvmlErrorString(ret) << "\n"; std::cerr << " Using index 0.\n"; - ret = nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice); } + if (ret != NVML_SUCCESS) + ret = nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice); + if (ret != NVML_SUCCESS) std::cerr << "MANGOHUD: Getting device handle failed: " << nvml.nvmlErrorString(ret) << "\n";