add some return values to some shit so it shuts down elegantly on crash
This commit is contained in:
10
src/gpu.cpp
10
src/gpu.cpp
@@ -14,14 +14,20 @@ const std::string rel_metrics_path = "/../../gpu_metrics"; // gpu_metrics path
|
||||
constexpr uint16_t max_metrics_length = 512; // length of the metrics buffer
|
||||
|
||||
/* takes pointer to a target gpu::sensors struct and updates its hwmon path and detects gpu_metrics */
|
||||
void detectHwmon(gpuSensors* target, const std::string& pci) {
|
||||
target->hwmon = utils::getFirstDir("/sys/bus/pci/devices/" + pci + "/hwmon");
|
||||
int detect(gpuSensors* target, const std::string& pci) {
|
||||
try {
|
||||
target->hwmon = utils::getFirstDir("/sys/bus/pci/devices/" + pci + "/hwmon");
|
||||
} catch (...) {
|
||||
applog(LOG::ERR, "Couldn't find GPU hwmon");
|
||||
return -1;
|
||||
}
|
||||
applog(LOG::INF, "Detected path \"{}\"", target->hwmon);
|
||||
|
||||
if (utils::fileExists(target->hwmon + rel_metrics_path)) {
|
||||
applog(LOG::INF, "found gpu_metrics");
|
||||
target->hasGpuMetrics = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* some metrics are missing in gpu_metrics, we always fill them from fs, unused metrics are commented out */
|
||||
|
||||
Reference in New Issue
Block a user