add some return values to some shit so it shuts down elegantly on crash

This commit is contained in:
2026-01-15 00:19:53 +01:00
parent 6297317f93
commit 7929a687e8
11 changed files with 105 additions and 64 deletions

View File

@@ -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 */