From: Michael Tremer Date: Fri, 27 Mar 2026 16:48:49 +0000 (+0000) Subject: graphs: Declare the state struct globally X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a5f1e590fb1056d20ed3e6e9a2bf3ea2968063b;p=telemetry.git graphs: Declare the state struct globally Signed-off-by: Michael Tremer --- diff --git a/src/daemon/graph.h b/src/daemon/graph.h index 2c126f0..606b752 100644 --- a/src/daemon/graph.h +++ b/src/daemon/graph.h @@ -102,6 +102,22 @@ int td_graph_require_sources(td_graph* self, int td_graph_render(td_graph* self, const char* object, const td_graph_render_options* options, char** buffer, size_t* length); +/* + This is a convenience type that can be used when the render state + has to be passed to a callback. Instead of defining it multiple times, + I felt that it was handy to define it globally. +*/ +typedef struct td_graph_render_state { + // Graph + td_graph* graph; + + // Options + const td_graph_render_options* options; + + // Args + td_args* args; +} td_graph_render_state; + /* Temperatures */ diff --git a/src/daemon/graphs/processor-temperature.c b/src/daemon/graphs/processor-temperature.c index 361b938..aa19b86 100644 --- a/src/daemon/graphs/processor-temperature.c +++ b/src/daemon/graphs/processor-temperature.c @@ -27,12 +27,6 @@ #include "graph.h" #include "processor-temperature.h" -typedef struct processor_temperature_state { - td_graph* graph; - const td_graph_render_options* options; - td_args* args; -} processor_temperature_state; - const char* supported_sensors[] = { // Intel "coretemp-*", @@ -50,7 +44,7 @@ static int processor_temperature_title(td_ctx* ctx, td_graph* graph, static int processor_temperature_render_sensor(td_ctx* ctx, td_source* source, const sensors_feature_type type, const sensors_chip_name* chip, const sensors_feature* feature, void* data) { - const processor_temperature_state* state = data; + const td_graph_render_state* state = data; char name[NAME_MAX]; int r; @@ -83,7 +77,7 @@ static int processor_temperature_render_sensor(td_ctx* ctx, td_source* source, static int processor_temperature_render(td_ctx* ctx, td_graph* graph, const td_graph_render_options* options, td_args* args, const char* object) { - processor_temperature_state state = { + td_graph_render_state state = { .graph = graph, .options = options, .args = args,