use the simplified shit

This commit is contained in:
2026-05-11 12:13:04 +00:00
parent 77f5494dd9
commit ffc1d55fde
2 changed files with 9 additions and 20 deletions

View File

@@ -19,10 +19,7 @@ void cpu_detect(struct cpu_sensors_t *t, const char *pci_dev) {
return;
}
char buf[128];
char *nt = stpncpy(buf, t->hwmon, sizeof(buf)); // nt is a pointer to the null terminator of the copied string
stpcpy(nt, "/in1_input"); // write at the null terminator address
t->module = file_exists(buf) ? zenpower : k10temp; // idk if this is reliable, we're trying to avoid just reading the name
t->module = read_file(t->hwmon, "/in1_input", NULL, 0) ? zenpower : k10temp; // if we can read zenpower file then zenpower. idk if this is reliable, we're trying to avoid just reading the name
applog(LOG_INF, "Detected %d cores, module enum #%d in path %s", t->num_cores, t->module, t->hwmon);
}

View File

@@ -2,7 +2,6 @@
#include "gpu_metrics.h"
#include <stdio.h>
#include <string.h>
#include "log.h"
#include "utils.h"
@@ -19,17 +18,13 @@ void gpu_detect(struct gpu_sensors_t *t, const char *pci) {
return;
}
char buf[128];
char *nt = stpncpy(buf, t->hwmon, sizeof(buf));
stpcpy(nt, rel_metrics_path); // write at the null terminator address
if (file_exists(buf)) {
char raw_metrics[max_metrics_length];
if (!read_file(buf, raw_metrics, sizeof(raw_metrics)))
return;
const struct metrics_table_header *header = (struct metrics_table_header *)raw_metrics;
applog(LOG_INF, "Found gpu_metrics_v%d_%d", header->format_revision, header->content_revision);
t->has_gpu_metrics = true;
}
t->has_gpu_metrics = false;
char raw_metrics[max_metrics_length];
if (!read_file(t->hwmon, rel_metrics_path, raw_metrics, sizeof(raw_metrics)))
return;
const struct metrics_table_header *header = (struct metrics_table_header *)raw_metrics;
applog(LOG_INF, "Found gpu_metrics_v%d_%d", header->format_revision, header->content_revision);
t->has_gpu_metrics = true;
}
/* some metrics are missing in gpu_metrics, we always fill them from fs, unused metrics are commented out */
@@ -55,12 +50,9 @@ void update_from_fs(struct gpu_sensors_t *g) {
}
void update_from_metrics(struct gpu_sensors_t *g) {
char buf[128];
char raw_metrics[max_metrics_length];
char *nt = stpncpy(buf, g->hwmon, sizeof(buf));
stpcpy(nt, rel_metrics_path); // write at the null terminator address
if (!read_file(buf, raw_metrics, sizeof(raw_metrics)))
if (!read_file(g->hwmon, rel_metrics_path, raw_metrics, sizeof(raw_metrics)))
return;
const struct metrics_table_header *header = (struct metrics_table_header *)raw_metrics;