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

@@ -9,19 +9,20 @@
namespace cpu {
void detectHwmon(cpuSensors* target, const std::string& pci) {
int detect(cpuSensors* target, const std::string& pci) {
const std::string path = "/sys/bus/pci/devices/" + pci + "/hwmon";
try {
target->hwmon = utils::getFirstDir(path);
} catch (...) {
applog(LOG::ERR, "NO CPU HWMON KERNEL MODULE DETECTED");
return;
return -1;
}
target->module = utils::fileExists(target->hwmon + "/in1_input") ? zenpower : k10temp; // idk if this is reliable, we're trying to avoid just reading the name
target->num_cores = std::thread::hardware_concurrency();
applog(LOG::INF, "Detected {} cores, module enum #{} in path \"{}\"", target->num_cores, static_cast<uint8_t>(target->module), target->hwmon);
return 0;
}
void update(cpuSensors* c) {